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
2eb60f43
Commit
2eb60f43
authored
Sep 24, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14319 from nikhiljindal/deploymentExamplew
Adding an example deployment yaml
parents
50f8f0c7
60bd4012
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
examples_test.go
examples/examples_test.go
+15
-1
deployment.yaml
examples/experimental/deployment.yaml
+20
-0
testapi.go
pkg/api/testapi/testapi.go
+19
-0
No files found.
examples/examples_test.go
View file @
2eb60f43
...
@@ -29,6 +29,8 @@ import (
...
@@ -29,6 +29,8 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/apis/experimental"
expValidation
"k8s.io/kubernetes/pkg/apis/experimental/validation"
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/capabilities"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/yaml"
"k8s.io/kubernetes/pkg/util/yaml"
...
@@ -99,6 +101,11 @@ func validateObject(obj runtime.Object) (errors []error) {
...
@@ -99,6 +101,11 @@ func validateObject(obj runtime.Object) (errors []error) {
t
.
Namespace
=
api
.
NamespaceDefault
t
.
Namespace
=
api
.
NamespaceDefault
}
}
errors
=
validation
.
ValidateResourceQuota
(
t
)
errors
=
validation
.
ValidateResourceQuota
(
t
)
case
*
experimental
.
Deployment
:
if
t
.
Namespace
==
""
{
t
.
Namespace
=
api
.
NamespaceDefault
}
errors
=
expValidation
.
ValidateDeployment
(
t
)
default
:
default
:
return
[]
error
{
fmt
.
Errorf
(
"no validation defined for %#v"
,
obj
)}
return
[]
error
{
fmt
.
Errorf
(
"no validation defined for %#v"
,
obj
)}
}
}
...
@@ -343,6 +350,9 @@ func TestExampleObjectSchemas(t *testing.T) {
...
@@ -343,6 +350,9 @@ func TestExampleObjectSchemas(t *testing.T) {
"../examples/fibre_channel"
:
{
"../examples/fibre_channel"
:
{
"fc"
:
&
api
.
Pod
{},
"fc"
:
&
api
.
Pod
{},
},
},
"../examples/experimental"
:
{
"deployment"
:
&
experimental
.
Deployment
{},
},
}
}
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
...
@@ -369,7 +379,11 @@ func TestExampleObjectSchemas(t *testing.T) {
...
@@ -369,7 +379,11 @@ func TestExampleObjectSchemas(t *testing.T) {
}
}
//TODO: Add validate method for &schedulerapi.Policy
//TODO: Add validate method for &schedulerapi.Policy
}
else
{
}
else
{
if
err
:=
testapi
.
Default
.
Codec
()
.
DecodeInto
(
data
,
expectedType
);
err
!=
nil
{
codec
,
err
:=
testapi
.
GetCodecForObject
(
expectedType
)
if
err
!=
nil
{
t
.
Errorf
(
"Could not get codec for %s: %s"
,
expectedType
,
err
)
}
if
err
:=
codec
.
DecodeInto
(
data
,
expectedType
);
err
!=
nil
{
t
.
Errorf
(
"%s did not decode correctly: %v
\n
%s"
,
path
,
err
,
string
(
data
))
t
.
Errorf
(
"%s did not decode correctly: %v
\n
%s"
,
path
,
err
,
string
(
data
))
return
return
}
}
...
...
examples/experimental/deployment.yaml
0 → 100644
View file @
2eb60f43
apiVersion
:
v1
kind
:
Deployment
metadata
:
name
:
nginx-deployment
labels
:
name
:
nginx-deployment
spec
:
replicas
:
3
selector
:
name
:
nginx
template
:
metadata
:
labels
:
name
:
nginx
spec
:
containers
:
-
name
:
nginx
image
:
nginx
ports
:
-
containerPort
:
80
pkg/api/testapi/testapi.go
View file @
2eb60f43
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
"os"
"os"
"strings"
"strings"
"k8s.io/kubernetes/pkg/api"
_
"k8s.io/kubernetes/pkg/api/install"
_
"k8s.io/kubernetes/pkg/api/install"
_
"k8s.io/kubernetes/pkg/apis/experimental/install"
_
"k8s.io/kubernetes/pkg/apis/experimental/install"
...
@@ -208,3 +209,21 @@ func (g TestGroup) ResourcePath(resource, namespace, name string) string {
...
@@ -208,3 +209,21 @@ func (g TestGroup) ResourcePath(resource, namespace, name string) string {
func
(
g
TestGroup
)
RESTMapper
()
meta
.
RESTMapper
{
func
(
g
TestGroup
)
RESTMapper
()
meta
.
RESTMapper
{
return
latest
.
GroupOrDie
(
g
.
Group
)
.
RESTMapper
return
latest
.
GroupOrDie
(
g
.
Group
)
.
RESTMapper
}
}
// Get codec based on runtime.Object
func
GetCodecForObject
(
obj
runtime
.
Object
)
(
runtime
.
Codec
,
error
)
{
_
,
kind
,
err
:=
api
.
Scheme
.
ObjectVersionAndKind
(
obj
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unexpected encoding error: %v"
,
err
)
}
// TODO: caesarxuchao: we should detect which group an object belongs to
// by using the version returned by Schem.ObjectVersionAndKind() once we
// split the schemes for internal objects.
// TODO: caesarxuchao: we should add a map from kind to group in Scheme.
for
_
,
group
:=
range
Groups
{
if
api
.
Scheme
.
Recognizes
(
group
.
GroupAndVersion
(),
kind
)
{
return
group
.
Codec
(),
nil
}
}
return
nil
,
fmt
.
Errorf
(
"unexpected kind: %v"
,
kind
)
}
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