Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
94adb5bb
Commit
94adb5bb
authored
Apr 25, 2019
by
Morten Torkildsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(helm): Only validate new manifests
Signed-off-by:
Morten Torkildsen
<
mortent@google.com
>
parent
b06b5ef4
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
4 deletions
+39
-4
client.go
pkg/kube/client.go
+15
-2
environment.go
pkg/tiller/environment/environment.go
+17
-0
environment_test.go
pkg/tiller/environment/environment_test.go
+3
-0
release_server.go
pkg/tiller/release_server.go
+1
-2
release_server_test.go
pkg/tiller/release_server_test.go
+3
-0
No files found.
pkg/kube/client.go
View file @
94adb5bb
...
...
@@ -141,7 +141,7 @@ func (c *Client) validator() validation.Schema {
return
schema
}
// BuildUnstructured
validates for
Kubernetes objects and returns unstructured infos.
// BuildUnstructured
reads
Kubernetes objects and returns unstructured infos.
func
(
c
*
Client
)
BuildUnstructured
(
namespace
string
,
reader
io
.
Reader
)
(
Result
,
error
)
{
var
result
Result
...
...
@@ -150,13 +150,26 @@ func (c *Client) BuildUnstructured(namespace string, reader io.Reader) (Result,
ContinueOnError
()
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
Schema
(
c
.
validator
())
.
Stream
(
reader
,
""
)
.
Flatten
()
.
Do
()
.
Infos
()
return
result
,
scrubValidationError
(
err
)
}
// Validate reads Kubernetes manifests and validates the content.
func
(
c
*
Client
)
Validate
(
namespace
string
,
reader
io
.
Reader
)
error
{
_
,
err
:=
c
.
NewBuilder
()
.
Unstructured
()
.
ContinueOnError
()
.
NamespaceParam
(
namespace
)
.
DefaultNamespace
()
.
Schema
(
c
.
validator
())
.
Stream
(
reader
,
""
)
.
Flatten
()
.
Do
()
.
Infos
()
return
scrubValidationError
(
err
)
}
// Build validates for Kubernetes objects and returns resource Infos from a io.Reader.
func
(
c
*
Client
)
Build
(
namespace
string
,
reader
io
.
Reader
)
(
Result
,
error
)
{
var
result
Result
...
...
pkg/tiller/environment/environment.go
View file @
94adb5bb
...
...
@@ -147,8 +147,20 @@ type KubeClient interface {
UpdateWithOptions
(
namespace
string
,
originalReader
,
modifiedReader
io
.
Reader
,
opts
kube
.
UpdateOptions
)
error
Build
(
namespace
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
// BuildUnstructured reads a stream of manifests from a reader and turns them into
// info objects. Manifests are not validated against the schema, but it will fail if
// any resoures types are not known by the apiserver.
//
// reader must contain a YAML stream (one or more YAML documents separated by "\n---\n").
BuildUnstructured
(
namespace
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
// Validate reads a stream of manifests from a reader and validates them against
// the schema from the apiserver. It returns an error if any of the manifests does not validate.
//
// reader must contain a YAML stream (one or more YAML documents separated by "\n---\n").
Validate
(
namespace
string
,
reader
io
.
Reader
)
error
// WaitAndGetCompletedPodPhase waits up to a timeout until a pod enters a completed phase
// and returns said phase (PodSucceeded or PodFailed qualify).
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
...
...
@@ -214,6 +226,11 @@ func (p *PrintingKubeClient) BuildUnstructured(ns string, reader io.Reader) (kub
return
[]
*
resource
.
Info
{},
nil
}
// Validate implements KubeClient Validate
func
(
p
*
PrintingKubeClient
)
Validate
(
ns
string
,
reader
io
.
Reader
)
error
{
return
nil
}
// WaitAndGetCompletedPodPhase implements KubeClient WaitAndGetCompletedPodPhase.
func
(
p
*
PrintingKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
_
,
err
:=
io
.
Copy
(
p
.
Out
,
reader
)
...
...
pkg/tiller/environment/environment_test.go
View file @
94adb5bb
...
...
@@ -64,6 +64,9 @@ func (k *mockKubeClient) Build(ns string, reader io.Reader) (kube.Result, error)
func
(
k
*
mockKubeClient
)
BuildUnstructured
(
ns
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
{
return
[]
*
resource
.
Info
{},
nil
}
func
(
k
*
mockKubeClient
)
Validate
(
ns
string
,
reader
io
.
Reader
)
error
{
return
nil
}
func
(
k
*
mockKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodUnknown
,
nil
}
...
...
pkg/tiller/release_server.go
View file @
94adb5bb
...
...
@@ -436,8 +436,7 @@ func (s *ReleaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
func
validateManifest
(
c
environment
.
KubeClient
,
ns
string
,
manifest
[]
byte
)
error
{
r
:=
bytes
.
NewReader
(
manifest
)
_
,
err
:=
c
.
BuildUnstructured
(
ns
,
r
)
return
err
return
c
.
Validate
(
ns
,
r
)
}
func
validateReleaseName
(
releaseName
string
)
error
{
...
...
pkg/tiller/release_server_test.go
View file @
94adb5bb
...
...
@@ -650,6 +650,9 @@ func (kc *mockHooksKubeClient) Build(ns string, reader io.Reader) (kube.Result,
func
(
kc
*
mockHooksKubeClient
)
BuildUnstructured
(
ns
string
,
reader
io
.
Reader
)
(
kube
.
Result
,
error
)
{
return
[]
*
resource
.
Info
{},
nil
}
func
(
kc
*
mockHooksKubeClient
)
Validate
(
ns
string
,
reader
io
.
Reader
)
error
{
return
nil
}
func
(
kc
*
mockHooksKubeClient
)
WaitAndGetCompletedPodPhase
(
namespace
string
,
reader
io
.
Reader
,
timeout
time
.
Duration
)
(
v1
.
PodPhase
,
error
)
{
return
v1
.
PodUnknown
,
nil
}
...
...
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