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
827a9231
Commit
827a9231
authored
Mar 10, 2015
by
Brian Grant
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5251 from derekwaynecarr/namespace_lifecycle
Add a NamespacePhase to Namespace
parents
7ce402a9
7de138a9
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
104 additions
and
2 deletions
+104
-2
fuzzer.go
pkg/api/testing/fuzzer.go
+3
-0
types.go
pkg/api/types.go
+12
-0
conversion.go
pkg/api/v1beta1/conversion.go
+3
-0
defaults.go
pkg/api/v1beta1/defaults.go
+5
-0
defaults_test.go
pkg/api/v1beta1/defaults_test.go
+10
-0
types.go
pkg/api/v1beta1/types.go
+12
-0
conversion.go
pkg/api/v1beta2/conversion.go
+3
-0
defaults.go
pkg/api/v1beta2/defaults.go
+5
-0
defaults_test.go
pkg/api/v1beta2/defaults_test.go
+10
-0
types.go
pkg/api/v1beta2/types.go
+12
-0
defaults.go
pkg/api/v1beta3/defaults.go
+5
-0
defaults_test.go
pkg/api/v1beta3/defaults_test.go
+10
-0
types.go
pkg/api/v1beta3/types.go
+12
-0
resource_printer.go
pkg/kubectl/resource_printer.go
+2
-2
No files found.
pkg/api/testing/fuzzer.go
View file @
827a9231
...
...
@@ -198,6 +198,9 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
c
.
FuzzNoCustom
(
s
)
// fuzz self without calling this function again
s
.
Type
=
api
.
SecretTypeOpaque
},
func
(
s
*
api
.
NamespaceStatus
,
c
fuzz
.
Continue
)
{
s
.
Phase
=
api
.
NamespaceActive
},
func
(
ep
*
api
.
Endpoint
,
c
fuzz
.
Continue
)
{
// TODO: If our API used a particular type for IP fields we could just catch that here.
ep
.
IP
=
fmt
.
Sprintf
(
"%d.%d.%d.%d"
,
c
.
Rand
.
Intn
(
256
),
c
.
Rand
.
Intn
(
256
),
c
.
Rand
.
Intn
(
256
),
c
.
Rand
.
Intn
(
256
))
...
...
pkg/api/types.go
View file @
827a9231
...
...
@@ -914,8 +914,20 @@ type NamespaceSpec struct {
// NamespaceStatus is information about the current status of a Namespace.
type
NamespaceStatus
struct
{
// Phase is the current lifecycle phase of the namespace.
Phase
NamespacePhase
`json:"phase,omitempty"`
}
type
NamespacePhase
string
// These are the valid phases of a namespace.
const
(
// NamespaceActive means the namespace is available for use in the system
NamespaceActive
NamespacePhase
=
"Active"
// NamespaceTerminating means the namespace is undergoing graceful termination
NamespaceTerminating
NamespacePhase
=
"Terminating"
)
// A namespace provides a scope for Names.
// Use of multiple namespaces is optional
type
Namespace
struct
{
...
...
pkg/api/v1beta1/conversion.go
View file @
827a9231
...
...
@@ -779,6 +779,9 @@ func init() {
if
err
:=
s
.
Convert
(
&
in
.
Spec
,
&
out
.
Spec
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
Convert
(
&
in
.
Status
,
&
out
.
Status
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
Convert
(
&
in
.
Labels
,
&
out
.
ObjectMeta
.
Labels
,
0
);
err
!=
nil
{
return
err
}
...
...
pkg/api/v1beta1/defaults.go
View file @
827a9231
...
...
@@ -95,5 +95,10 @@ func init() {
obj
.
Path
=
"/"
}
},
func
(
obj
*
NamespaceStatus
)
{
if
obj
.
Phase
==
""
{
obj
.
Phase
=
NamespaceActive
}
},
)
}
pkg/api/v1beta1/defaults_test.go
View file @
827a9231
...
...
@@ -112,3 +112,13 @@ func TestSetDefaulEndpointsProtocol(t *testing.T) {
t
.
Errorf
(
"Expected protocol %s, got %s"
,
current
.
ProtocolTCP
,
out
.
Protocol
)
}
}
func
TestSetDefaultNamespace
(
t
*
testing
.
T
)
{
s
:=
&
current
.
Namespace
{}
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
s
))
s2
:=
obj2
.
(
*
current
.
Namespace
)
if
s2
.
Status
.
Phase
!=
current
.
NamespaceActive
{
t
.
Errorf
(
"Expected phase %v, got %v"
,
current
.
NamespaceActive
,
s2
.
Status
.
Phase
)
}
}
pkg/api/v1beta1/types.go
View file @
827a9231
...
...
@@ -746,8 +746,20 @@ type NamespaceSpec struct {
// NamespaceStatus is information about the current status of a Namespace.
type
NamespaceStatus
struct
{
// Phase is the current lifecycle phase of the namespace.
Phase
NamespacePhase
`json:"phase,omitempty" description:"phase is the current lifecycle phase of the namespace"`
}
type
NamespacePhase
string
// These are the valid phases of a namespace.
const
(
// NamespaceActive means the namespace is available for use in the system
NamespaceActive
NamespacePhase
=
"Active"
// NamespaceTerminating means the namespace is undergoing graceful termination
NamespaceTerminating
NamespacePhase
=
"Terminating"
)
// A namespace provides a scope for Names.
// Use of multiple namespaces is optional
type
Namespace
struct
{
...
...
pkg/api/v1beta2/conversion.go
View file @
827a9231
...
...
@@ -699,6 +699,9 @@ func init() {
if
err
:=
s
.
Convert
(
&
in
.
Spec
,
&
out
.
Spec
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
Convert
(
&
in
.
Status
,
&
out
.
Status
,
0
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
Convert
(
&
in
.
Labels
,
&
out
.
ObjectMeta
.
Labels
,
0
);
err
!=
nil
{
return
err
}
...
...
pkg/api/v1beta2/defaults.go
View file @
827a9231
...
...
@@ -97,5 +97,10 @@ func init() {
obj
.
Path
=
"/"
}
},
func
(
obj
*
NamespaceStatus
)
{
if
obj
.
Phase
==
""
{
obj
.
Phase
=
NamespaceActive
}
},
)
}
pkg/api/v1beta2/defaults_test.go
View file @
827a9231
...
...
@@ -112,3 +112,13 @@ func TestSetDefaulEndpointsProtocol(t *testing.T) {
t
.
Errorf
(
"Expected protocol %s, got %s"
,
current
.
ProtocolTCP
,
out
.
Protocol
)
}
}
func
TestSetDefaultNamespace
(
t
*
testing
.
T
)
{
s
:=
&
current
.
Namespace
{}
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
s
))
s2
:=
obj2
.
(
*
current
.
Namespace
)
if
s2
.
Status
.
Phase
!=
current
.
NamespaceActive
{
t
.
Errorf
(
"Expected phase %v, got %v"
,
current
.
NamespaceActive
,
s2
.
Status
.
Phase
)
}
}
pkg/api/v1beta2/types.go
View file @
827a9231
...
...
@@ -762,8 +762,20 @@ type NamespaceSpec struct {
// NamespaceStatus is information about the current status of a Namespace.
type
NamespaceStatus
struct
{
// Phase is the current lifecycle phase of the namespace.
Phase
NamespacePhase
`json:"phase,omitempty" description:"phase is the current lifecycle phase of the namespace"`
}
type
NamespacePhase
string
// These are the valid phases of a namespace.
const
(
// NamespaceActive means the namespace is available for use in the system
NamespaceActive
NamespacePhase
=
"Active"
// NamespaceTerminating means the namespace is undergoing graceful termination
NamespaceTerminating
NamespacePhase
=
"Terminating"
)
// A namespace provides a scope for Names.
// Use of multiple namespaces is optional.
//
...
...
pkg/api/v1beta3/defaults.go
View file @
827a9231
...
...
@@ -96,5 +96,10 @@ func init() {
obj
.
ContainerPort
=
util
.
NewIntOrStringFromInt
(
obj
.
Port
)
}
},
func
(
obj
*
NamespaceStatus
)
{
if
obj
.
Phase
==
""
{
obj
.
Phase
=
NamespaceActive
}
},
)
}
pkg/api/v1beta3/defaults_test.go
View file @
827a9231
...
...
@@ -129,3 +129,13 @@ func TestSetDefaulServiceDestinationPort(t *testing.T) {
t
.
Errorf
(
"Expected ContainerPort to be unchanged, got %s"
,
out
.
Spec
.
ContainerPort
)
}
}
func
TestSetDefaultNamespace
(
t
*
testing
.
T
)
{
s
:=
&
current
.
Namespace
{}
obj2
:=
roundTrip
(
t
,
runtime
.
Object
(
s
))
s2
:=
obj2
.
(
*
current
.
Namespace
)
if
s2
.
Status
.
Phase
!=
current
.
NamespaceActive
{
t
.
Errorf
(
"Expected phase %v, got %v"
,
current
.
NamespaceActive
,
s2
.
Status
.
Phase
)
}
}
pkg/api/v1beta3/types.go
View file @
827a9231
...
...
@@ -935,8 +935,20 @@ type NamespaceSpec struct {
// NamespaceStatus is information about the current status of a Namespace.
type
NamespaceStatus
struct
{
// Phase is the current lifecycle phase of the namespace.
Phase
NamespacePhase
`json:"phase,omitempty" description:"phase is the current lifecycle phase of the namespace"`
}
type
NamespacePhase
string
// These are the valid phases of a namespace.
const
(
// NamespaceActive means the namespace is available for use in the system
NamespaceActive
NamespacePhase
=
"Active"
// NamespaceTerminating means the namespace is undergoing graceful termination
NamespaceTerminating
NamespacePhase
=
"Terminating"
)
// A namespace provides a scope for Names.
// Use of multiple namespaces is optional
type
Namespace
struct
{
...
...
pkg/kubectl/resource_printer.go
View file @
827a9231
...
...
@@ -237,7 +237,7 @@ var statusColumns = []string{"STATUS"}
var
eventColumns
=
[]
string
{
"FIRSTSEEN"
,
"LASTSEEN"
,
"COUNT"
,
"NAME"
,
"KIND"
,
"SUBOBJECT"
,
"REASON"
,
"SOURCE"
,
"MESSAGE"
}
var
limitRangeColumns
=
[]
string
{
"NAME"
}
var
resourceQuotaColumns
=
[]
string
{
"NAME"
}
var
namespaceColumns
=
[]
string
{
"NAME"
,
"LABELS"
}
var
namespaceColumns
=
[]
string
{
"NAME"
,
"LABELS"
,
"STATUS"
}
var
secretColumns
=
[]
string
{
"NAME"
,
"DATA"
}
// addDefaultHandlers adds print handlers for default Kubernetes types.
...
...
@@ -402,7 +402,7 @@ func printEndpointsList(list *api.EndpointsList, w io.Writer) error {
}
func
printNamespace
(
item
*
api
.
Namespace
,
w
io
.
Writer
)
error
{
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\
n
"
,
item
.
Name
,
formatLabels
(
item
.
Labels
)
)
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s
\
t
%s
\n
"
,
item
.
Name
,
formatLabels
(
item
.
Labels
),
item
.
Status
.
Phase
)
return
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