Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
70b5ed26
Commit
70b5ed26
authored
Aug 12, 2016
by
Tamer Tas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/kubelet/rktshim: deprecate kubelet/container API usage
parent
72f41ff8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
31 deletions
+36
-31
imagestore.go
pkg/kubelet/rktshim/imagestore.go
+7
-7
imagestore_test.go
pkg/kubelet/rktshim/imagestore_test.go
+29
-24
No files found.
pkg/kubelet/rktshim/imagestore.go
View file @
70b5ed26
...
@@ -19,7 +19,7 @@ package rktshim
...
@@ -19,7 +19,7 @@ package rktshim
import
(
import
(
"errors"
"errors"
"k8s.io/kubernetes/pkg/kubelet/container
"
runtimeApi
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime
"
)
)
// TODO(tmrts): Move these errors to the container API for code re-use.
// TODO(tmrts): Move these errors to the container API for code re-use.
...
@@ -27,7 +27,7 @@ var (
...
@@ -27,7 +27,7 @@ var (
ErrImageNotFound
=
errors
.
New
(
"rktshim: image not found"
)
ErrImageNotFound
=
errors
.
New
(
"rktshim: image not found"
)
)
)
var
_
container
.
Image
Service
=
(
*
ImageStore
)(
nil
)
// var _ kubeletApi.ImageManager
Service = (*ImageStore)(nil)
// ImageStore supports CRUD operations for images.
// ImageStore supports CRUD operations for images.
type
ImageStore
struct
{}
type
ImageStore
struct
{}
...
@@ -36,26 +36,26 @@ type ImageStore struct{}
...
@@ -36,26 +36,26 @@ type ImageStore struct{}
type
ImageStoreConfig
struct
{}
type
ImageStoreConfig
struct
{}
// NewImageStore creates an image storage that allows CRUD operations for images.
// NewImageStore creates an image storage that allows CRUD operations for images.
func
NewImageStore
(
ImageStoreConfig
)
(
container
.
ImageServic
e
,
error
)
{
func
NewImageStore
(
ImageStoreConfig
)
(
*
ImageStor
e
,
error
)
{
return
&
ImageStore
{},
nil
return
&
ImageStore
{},
nil
}
}
// List lists the images residing in the image store.
// List lists the images residing in the image store.
func
(
*
ImageStore
)
List
()
([]
container
.
Image
,
error
)
{
func
(
*
ImageStore
)
List
()
([]
runtimeApi
.
Image
,
error
)
{
panic
(
"not implemented"
)
panic
(
"not implemented"
)
}
}
// Pull pulls an image into the image store and uses the given authentication method.
// Pull pulls an image into the image store and uses the given authentication method.
func
(
*
ImageStore
)
Pull
(
container
.
ImageSpec
,
container
.
AuthConfig
,
*
container
.
PodSandboxConfig
)
error
{
func
(
*
ImageStore
)
Pull
(
runtimeApi
.
ImageSpec
,
runtimeApi
.
AuthConfig
,
*
runtimeApi
.
PodSandboxConfig
)
error
{
panic
(
"not implemented"
)
panic
(
"not implemented"
)
}
}
// Remove removes the image from the image store.
// Remove removes the image from the image store.
func
(
*
ImageStore
)
Remove
(
container
.
ImageSpec
)
error
{
func
(
*
ImageStore
)
Remove
(
runtimeApi
.
ImageSpec
)
error
{
panic
(
"not implemented"
)
panic
(
"not implemented"
)
}
}
// Status returns the status of the image.
// Status returns the status of the image.
func
(
*
ImageStore
)
Status
(
container
.
ImageSpec
)
(
container
.
Image
,
error
)
{
func
(
*
ImageStore
)
Status
(
runtimeApi
.
ImageSpec
)
(
runtimeApi
.
Image
,
error
)
{
panic
(
"not implemented"
)
panic
(
"not implemented"
)
}
}
pkg/kubelet/rktshim/imagestore_test.go
View file @
70b5ed26
...
@@ -21,72 +21,77 @@ import (
...
@@ -21,72 +21,77 @@ import (
"reflect"
"reflect"
"testing"
"testing"
"k8s.io/kubernetes/pkg/kubelet/container
"
runtimeApi
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime
"
)
)
var
(
var
(
emptyImgStoreConfig
=
ImageStoreConfig
{}
emptyImgStoreConfig
=
ImageStoreConfig
{}
// TODO(tmrts): fill the pod configuration
// TODO(tmrts): fill the pod configuration
testPodConfig
*
container
.
PodSandboxConfig
=
nil
testPodConfig
*
runtimeApi
.
PodSandboxConfig
=
nil
)
)
type
imageTestCase
struct
{
type
imageTestCase
struct
{
Spec
*
container
.
ImageSpec
Spec
*
runtimeApi
.
ImageSpec
ExpectedStatus
*
container
.
Image
ExpectedStatus
*
runtimeApi
.
Image
}
}
func
compareContainerImages
(
got
,
expected
container
.
Image
)
error
{
func
compareContainerImages
(
got
,
expected
runtimeApi
.
Image
)
error
{
if
got
.
I
D
!=
expected
.
ID
{
if
got
.
I
d
!=
expected
.
Id
{
return
fmt
.
Errorf
(
"mismatching I
Ds -> expected %q, got %q"
,
got
.
ID
,
expected
.
ID
)
return
fmt
.
Errorf
(
"mismatching I
ds -> expected %q, got %q"
,
got
.
Id
,
expected
.
Id
)
}
}
if
!
reflect
.
DeepEqual
(
got
.
RepoTags
,
expected
.
RepoTags
)
{
if
!
reflect
.
DeepEqual
(
got
.
RepoTags
,
expected
.
RepoTags
)
{
return
fmt
.
Errorf
(
"mismatching RepoTags -> expected %q, got %q"
,
got
.
I
D
,
expected
.
ID
)
return
fmt
.
Errorf
(
"mismatching RepoTags -> expected %q, got %q"
,
got
.
I
d
,
expected
.
Id
)
}
}
if
!
reflect
.
DeepEqual
(
got
.
RepoDigests
,
expected
.
RepoDigests
)
{
if
!
reflect
.
DeepEqual
(
got
.
RepoDigests
,
expected
.
RepoDigests
)
{
return
fmt
.
Errorf
(
"mismatching RepoDigests -> expected %q, got %q"
,
got
.
I
D
,
expected
.
ID
)
return
fmt
.
Errorf
(
"mismatching RepoDigests -> expected %q, got %q"
,
got
.
I
d
,
expected
.
Id
)
}
}
if
got
.
Size
!=
expected
.
Size
{
if
got
.
Size
_
!=
expected
.
Size_
{
return
fmt
.
Errorf
(
"mismatching Sizes -> expected %q, got %q"
,
got
.
I
D
,
expected
.
ID
)
return
fmt
.
Errorf
(
"mismatching Sizes -> expected %q, got %q"
,
got
.
I
d
,
expected
.
Id
)
}
}
return
nil
return
nil
}
}
var
(
busyboxStr
=
"busybox"
gibberishStr
=
"XXXX_GIBBERISH_XXXX"
)
var
testImgSpecs
=
map
[
string
]
imageTestCase
{
var
testImgSpecs
=
map
[
string
]
imageTestCase
{
"non-existent-image"
:
{
"non-existent-image"
:
{
&
container
.
ImageSpec
{
&
runtimeApi
.
ImageSpec
{
Image
:
"XXXX_GIBBERISH_XXXX"
,
Image
:
&
gibberishStr
,
},
},
nil
,
nil
,
},
},
"busybox"
:
{
"busybox"
:
{
&
container
.
ImageSpec
{
&
runtimeApi
.
ImageSpec
{
Image
:
"busybox"
,
Image
:
&
busyboxStr
,
},
},
&
container
.
Image
{
&
runtimeApi
.
Image
{
I
D
:
""
,
I
d
:
nil
,
RepoTags
:
[]
string
{},
RepoTags
:
[]
string
{},
RepoDigests
:
[]
string
{},
RepoDigests
:
[]
string
{},
Size
:
0
,
Size
_
:
nil
,
},
},
},
},
}
}
var
testAuthConfig
=
map
[
string
]
container
.
AuthConfig
{
var
testAuthConfig
=
map
[
string
]
runtimeApi
.
AuthConfig
{
"no-auth"
:
{},
"no-auth"
:
{},
}
}
func
testNewImageStore
(
t
*
testing
.
T
,
cfg
ImageStoreConfig
)
container
.
ImageServic
e
{
func
testNewImageStore
(
t
*
testing
.
T
,
cfg
ImageStoreConfig
)
*
ImageStor
e
{
imgStore
,
err
:=
NewImageStore
(
cfg
)
s
,
err
:=
NewImageStore
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
// TODO(tmrts): Implement stringer for rktshim.ImageStoreConfig for test readability.
// TODO(tmrts): Implement stringer for rktshim.ImageStoreConfig for test readability.
t
.
Fatalf
(
"rktshim.NewImageStore(%s) got error %q"
,
cfg
,
err
)
t
.
Fatalf
(
"rktshim.NewImageStore(%s) got error %q"
,
cfg
,
err
)
}
}
return
imgStore
return
s
}
}
func
TestPullsImageWithoutAuthentication
(
t
*
testing
.
T
)
{
func
TestPullsImageWithoutAuthentication
(
t
*
testing
.
T
)
{
...
@@ -196,10 +201,10 @@ func TestListsImages(t *testing.T) {
...
@@ -196,10 +201,10 @@ func TestListsImages(t *testing.T) {
}
}
for
_
,
img
:=
range
imgs
{
for
_
,
img
:=
range
imgs
{
expectedImg
:=
*
testImgSpecs
[
img
.
ID
]
.
ExpectedStatus
expectedImg
:=
*
testImgSpecs
[
*
img
.
Id
]
.
ExpectedStatus
if
err
:=
compareContainerImages
(
img
,
expectedImg
);
err
!=
nil
{
if
err
:=
compareContainerImages
(
img
,
expectedImg
);
err
!=
nil
{
t
.
Errorf
(
"rktshim.ImageStore.List() for %q, %v"
,
img
.
I
D
,
err
)
t
.
Errorf
(
"rktshim.ImageStore.List() for %q, %v"
,
img
.
I
d
,
err
)
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment