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
d1c99590
Unverified
Commit
d1c99590
authored
Jun 12, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Jun 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78772 from liggitt/automated-cherry-pick-of-#78770-upstream-release-1.14
Automated cherry pick of #78770: Fix kubectl apply skew test with extra properties
parents
0020140b
1ba69b16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletion
+71
-1
BUILD
test/e2e/kubectl/BUILD
+1
-0
kubectl.go
test/e2e/kubectl/kubectl.go
+70
-1
No files found.
test/e2e/kubectl/BUILD
View file @
d1c99590
...
...
@@ -37,6 +37,7 @@ go_library(
"//test/utils/crd:go_default_library",
"//test/utils/image:go_default_library",
"//vendor/github.com/elazarl/goproxy:go_default_library",
"//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/golang.org/x/net/websocket:go_default_library",
...
...
test/e2e/kubectl/kubectl.go
View file @
d1c99590
...
...
@@ -40,6 +40,7 @@ import (
"time"
"github.com/elazarl/goproxy"
openapi_v2
"github.com/googleapis/gnostic/OpenAPIv2"
"sigs.k8s.io/yaml"
"k8s.io/api/core/v1"
...
...
@@ -821,6 +822,56 @@ metadata:
})
})
// definitionMatchesGVK returns true if the specified GVK is listed as an x-kubernetes-group-version-kind extension
definitionMatchesGVK
:=
func
(
extensions
[]
*
openapi_v2
.
NamedAny
,
desiredGVK
schema
.
GroupVersionKind
)
bool
{
for
_
,
extension
:=
range
extensions
{
if
extension
.
GetValue
()
.
GetYaml
()
==
""
||
extension
.
GetName
()
!=
"x-kubernetes-group-version-kind"
{
continue
}
var
values
[]
map
[
string
]
string
err
:=
yaml
.
Unmarshal
([]
byte
(
extension
.
GetValue
()
.
GetYaml
()),
&
values
)
if
err
!=
nil
{
framework
.
Logf
(
"%v
\n
%s"
,
err
,
string
(
extension
.
GetValue
()
.
GetYaml
()))
continue
}
for
_
,
value
:=
range
values
{
if
value
[
"group"
]
!=
desiredGVK
.
Group
{
continue
}
if
value
[
"version"
]
!=
desiredGVK
.
Version
{
continue
}
if
value
[
"kind"
]
!=
desiredGVK
.
Kind
{
continue
}
return
true
}
}
return
false
}
// schemaForGVK returns a schema (if defined) for the specified GVK
schemaForGVK
:=
func
(
desiredGVK
schema
.
GroupVersionKind
)
*
openapi_v2
.
Schema
{
d
,
err
:=
f
.
ClientSet
.
Discovery
()
.
OpenAPISchema
()
if
err
!=
nil
{
framework
.
Failf
(
"%v"
,
err
)
}
if
d
==
nil
||
d
.
Definitions
==
nil
{
return
nil
}
for
_
,
p
:=
range
d
.
Definitions
.
AdditionalProperties
{
if
p
==
nil
||
p
.
Value
==
nil
{
continue
}
if
!
definitionMatchesGVK
(
p
.
Value
.
VendorExtension
,
desiredGVK
)
{
continue
}
return
p
.
Value
}
return
nil
}
framework
.
KubeDescribe
(
"Kubectl client-side validation"
,
func
()
{
ginkgo
.
It
(
"should create/apply a CR with unknown fields for CRD with no validation schema"
,
func
()
{
ginkgo
.
By
(
"create CRD with no validation schema"
)
...
...
@@ -875,10 +926,28 @@ metadata:
ginkgo
.
By
(
"sleep for 10s to wait for potential crd openapi publishing alpha feature"
)
time
.
Sleep
(
10
*
time
.
Second
)
publishedSchema
:=
schemaForGVK
(
schema
.
GroupVersionKind
{
Group
:
crd
.
APIGroup
,
Version
:
crd
.
Versions
[
0
]
.
Name
,
Kind
:
crd
.
Kind
})
expectSuccess
:=
false
if
publishedSchema
==
nil
||
publishedSchema
.
Properties
==
nil
||
publishedSchema
.
Properties
.
AdditionalProperties
==
nil
||
len
(
publishedSchema
.
Properties
.
AdditionalProperties
)
==
0
{
// expect success in the following cases:
// - no schema was published
// - a schema was published with no properties
expectSuccess
=
true
framework
.
Logf
(
"no schema with properties found, expect apply with extra properties to succeed"
)
}
else
{
framework
.
Logf
(
"schema with properties found, expect apply with extra properties to fail"
)
}
meta
:=
fmt
.
Sprintf
(
metaPattern
,
crd
.
Kind
,
crd
.
APIGroup
,
crd
.
Versions
[
0
]
.
Name
,
"test-cr"
)
validArbitraryCR
:=
fmt
.
Sprintf
(
`{%s,"spec":{"bars":[{"name":"test-bar"}],"extraProperty":"arbitrary-value"}}`
,
meta
)
if
err
:=
createApplyCustomResource
(
validArbitraryCR
,
f
.
Namespace
.
Name
,
"test-cr"
,
crd
);
err
!=
nil
{
framework
.
Failf
(
"%v"
,
err
)
if
expectSuccess
{
framework
.
Failf
(
"%v"
,
err
)
}
}
else
{
if
!
expectSuccess
{
framework
.
Failf
(
"expected error, got none"
)
}
}
})
...
...
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