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
afb9a896
Commit
afb9a896
authored
Apr 22, 2015
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce container ID type.
parent
c303c055
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
runtime.go
pkg/kubelet/container/runtime.go
+36
-0
No files found.
pkg/kubelet/container/runtime.go
View file @
afb9a896
...
@@ -87,6 +87,42 @@ type Pod struct {
...
@@ -87,6 +87,42 @@ type Pod struct {
Status
api
.
PodStatus
Status
api
.
PodStatus
}
}
// ContainerID is a type that identifies a container.
type
ContainerID
struct
{
// The type of the container runtime. e.g. 'docker', 'rkt'.
Type
string
// The identification of the container, this is comsumable by
// the underlying container runtime. (Note that the container
// runtime interface still takes the whole struct as input).
ID
string
}
func
BuildContainerID
(
typ
,
ID
string
)
ContainerID
{
return
ContainerID
{
Type
:
typ
,
ID
:
ID
}
}
func
(
c
*
ContainerID
)
ParseString
(
data
string
)
error
{
// Trim the quotes and split the type and ID.
parts
:=
strings
.
Split
(
strings
.
Trim
(
data
,
"
\"
"
),
"://"
)
if
len
(
parts
)
!=
2
{
return
fmt
.
Errorf
(
"invalid container ID: %q"
,
data
)
}
c
.
Type
,
c
.
ID
=
parts
[
0
],
parts
[
1
]
return
nil
}
func
(
c
*
ContainerID
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s://%s"
,
c
.
Type
,
c
.
ID
)
}
func
(
c
*
ContainerID
)
MarshalJSON
()
([]
byte
,
error
)
{
return
[]
byte
(
fmt
.
Sprintf
(
"%q"
,
c
.
String
())),
nil
}
func
(
c
*
ContainerID
)
UnmarshalJSON
(
data
[]
byte
)
error
{
return
c
.
ParseString
(
string
(
data
))
}
// Container provides the runtime information for a container, such as ID, hash,
// Container provides the runtime information for a container, such as ID, hash,
// status of the container.
// status of the container.
type
Container
struct
{
type
Container
struct
{
...
...
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