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
55791e22
Commit
55791e22
authored
Apr 03, 2017
by
Matt Butcher
Committed by
GitHub
Apr 03, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2148 from technosophos/fix/2118-broken-status
fix(tiller): fix helm status failure on missing resource
parents
e8f5d4de
27c3ff59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
client.go
pkg/kube/client.go
+10
-1
client_test.go
pkg/kube/client_test.go
+44
-0
No files found.
pkg/kube/client.go
View file @
55791e22
...
...
@@ -151,11 +151,14 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
if
err
!=
nil
{
return
""
,
err
}
missing
:=
[]
string
{}
err
=
perform
(
c
,
namespace
,
infos
,
func
(
info
*
resource
.
Info
)
error
{
log
.
Printf
(
"Doing get for %s: %q"
,
info
.
Mapping
.
GroupVersionKind
.
Kind
,
info
.
Name
)
obj
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Get
(
info
.
Namespace
,
info
.
Name
,
info
.
Export
)
if
err
!=
nil
{
return
err
log
.
Printf
(
"WARNING: Failed Get for resource %q: %s"
,
info
.
Name
,
err
)
missing
=
append
(
missing
,
fmt
.
Sprintf
(
"%v
\t\t
%s"
,
info
.
Mapping
.
Resource
,
info
.
Name
))
return
nil
}
// We need to grab the ObjectReference so we can correctly group the objects.
or
,
err
:=
api
.
GetReference
(
obj
)
...
...
@@ -194,6 +197,12 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
return
""
,
err
}
}
if
len
(
missing
)
>
0
{
buf
.
WriteString
(
"==> MISSING
\n
KIND
\t\t
NAME
\n
"
)
for
_
,
s
:=
range
missing
{
fmt
.
Fprintln
(
buf
,
s
)
}
}
return
buf
.
String
(),
nil
}
...
...
pkg/kube/client_test.go
View file @
55791e22
...
...
@@ -59,6 +59,7 @@ func newPodWithStatus(name string, status api.PodStatus, namespace string) api.P
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
name
,
Namespace
:
ns
,
SelfLink
:
"/api/v1/namespaces/default/pods/"
+
name
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{{
...
...
@@ -279,6 +280,49 @@ func TestBuild(t *testing.T) {
}
}
func
TestGet
(
t
*
testing
.
T
)
{
list
:=
newPodList
(
"starfish"
,
"otter"
)
f
,
tf
,
_
,
ns
:=
cmdtesting
.
NewAPIFactory
()
tf
.
Client
=
&
fake
.
RESTClient
{
NegotiatedSerializer
:
ns
,
Client
:
fake
.
CreateHTTPClient
(
func
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
{
p
,
m
:=
req
.
URL
.
Path
,
req
.
Method
//actions = append(actions, p+":"+m)
t
.
Logf
(
"got request %s %s"
,
p
,
m
)
switch
{
case
p
==
"/namespaces/default/pods/starfish"
&&
m
==
"GET"
:
return
newResponse
(
404
,
notFoundBody
())
case
p
==
"/namespaces/default/pods/otter"
&&
m
==
"GET"
:
return
newResponse
(
200
,
&
list
.
Items
[
1
])
default
:
t
.
Fatalf
(
"unexpected request: %s %s"
,
req
.
Method
,
req
.
URL
.
Path
)
return
nil
,
nil
}
}),
}
c
:=
&
Client
{
Factory
:
f
}
// Test Success
data
:=
strings
.
NewReader
(
"kind: Pod
\n
apiVersion: v1
\n
metadata:
\n
name: otter"
)
o
,
err
:=
c
.
Get
(
"default"
,
data
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected missing results, got %q"
,
err
)
}
if
!
strings
.
Contains
(
o
,
"==> v1/Pod"
)
&&
!
strings
.
Contains
(
o
,
"otter"
)
{
t
.
Errorf
(
"Expected v1/Pod otter, got %s"
,
o
)
}
// Test failure
data
=
strings
.
NewReader
(
"kind: Pod
\n
apiVersion: v1
\n
metadata:
\n
name: starfish"
)
o
,
err
=
c
.
Get
(
"default"
,
data
)
if
err
!=
nil
{
t
.
Errorf
(
"Expected missing results, got %q"
,
err
)
}
if
!
strings
.
Contains
(
o
,
"MISSING"
)
&&
!
strings
.
Contains
(
o
,
"pods
\t\t
starfish"
)
{
t
.
Errorf
(
"Expected missing starfish, got %s"
,
o
)
}
}
func
TestPerform
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
...
...
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