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
e6d907ed
Commit
e6d907ed
authored
Nov 12, 2017
by
Federico Gimenez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if resource is present before adding it to remaining or keep on deletion
parent
15053e67
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
client.go
pkg/kube/client.go
+6
-1
release_modules.go
pkg/tiller/release_modules.go
+1
-1
resource_policy.go
pkg/tiller/resource_policy.go
+10
-1
No files found.
pkg/kube/client.go
View file @
e6d907ed
...
...
@@ -53,6 +53,11 @@ import (
"k8s.io/kubernetes/pkg/printers"
)
const
(
// MissingGetHeader is added to Get's outout when a resource is not found.
MissingGetHeader
=
"==> MISSING
\n
KIND
\t\t
NAME
\n
"
)
// ErrNoObjectsVisited indicates that during a visit operation, no matching objects were found.
var
ErrNoObjectsVisited
=
goerrors
.
New
(
"no objects visited"
)
...
...
@@ -217,7 +222,7 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
}
}
if
len
(
missing
)
>
0
{
buf
.
WriteString
(
"==> MISSING
\n
KIND
\t\t
NAME
\n
"
)
buf
.
WriteString
(
MissingGetHeader
)
for
_
,
s
:=
range
missing
{
fmt
.
Fprintln
(
buf
,
s
)
}
...
...
pkg/tiller/release_modules.go
View file @
e6d907ed
...
...
@@ -159,7 +159,7 @@ func DeleteRelease(rel *release.Release, vs chartutil.VersionSet, kubeClient env
return
rel
.
Manifest
,
[]
error
{
fmt
.
Errorf
(
"corrupted release record. You must manually delete the resources: %s"
,
err
)}
}
filesToKeep
,
filesToDelete
:=
filterManifestsToKeep
(
files
)
filesToKeep
,
filesToDelete
:=
filterManifestsToKeep
(
files
,
kubeClient
,
rel
.
Namespace
)
if
len
(
filesToKeep
)
>
0
{
kept
=
summarizeKeptManifests
(
filesToKeep
)
}
...
...
pkg/tiller/resource_policy.go
View file @
e6d907ed
...
...
@@ -17,7 +17,11 @@ limitations under the License.
package
tiller
import
(
"bytes"
"strings"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/tiller/environment"
)
// resourcePolicyAnno is the annotation name for a resource policy
...
...
@@ -29,11 +33,16 @@ const resourcePolicyAnno = "helm.sh/resource-policy"
// during an uninstallRelease action.
const
keepPolicy
=
"keep"
func
filterManifestsToKeep
(
manifests
[]
Manifest
)
([]
Manifest
,
[]
Manifest
)
{
func
filterManifestsToKeep
(
manifests
[]
Manifest
,
kubeClient
environment
.
KubeClient
,
namespace
string
)
([]
Manifest
,
[]
Manifest
)
{
remaining
:=
[]
Manifest
{}
keep
:=
[]
Manifest
{}
for
_
,
m
:=
range
manifests
{
// check if m is in fact present from k8s client's POV.
output
,
err
:=
kubeClient
.
Get
(
namespace
,
bytes
.
NewBufferString
(
m
.
Content
))
if
err
!=
nil
||
strings
.
Contains
(
output
,
kube
.
MissingGetHeader
)
{
continue
}
if
m
.
Head
.
Metadata
==
nil
||
m
.
Head
.
Metadata
.
Annotations
==
nil
||
len
(
m
.
Head
.
Metadata
.
Annotations
)
==
0
{
remaining
=
append
(
remaining
,
m
)
...
...
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