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
fb8dd392
Commit
fb8dd392
authored
May 05, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #645 from adamreese/feat/kube-delete
feat(kube): add delete method
parents
d644c220
00ff8acf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
client.go
pkg/kube/client.go
+12
-0
client_test.go
pkg/kube/client_test.go
+11
-0
No files found.
pkg/kube/client.go
View file @
fb8dd392
...
@@ -32,6 +32,14 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
...
@@ -32,6 +32,14 @@ func (c *Client) Create(namespace string, reader io.Reader) error {
return
perform
(
f
,
namespace
,
reader
,
createResource
)
return
perform
(
f
,
namespace
,
reader
,
createResource
)
}
}
// Delete deletes kubernetes resources from an io.reader
//
// Namespace will set the namespace
func
(
c
*
Client
)
Delete
(
namespace
string
,
reader
io
.
Reader
)
error
{
f
:=
cmdutil
.
NewFactory
(
c
.
config
)
return
perform
(
f
,
namespace
,
reader
,
deleteResource
)
}
const
includeThirdPartyAPIs
=
false
const
includeThirdPartyAPIs
=
false
func
perform
(
f
*
cmdutil
.
Factory
,
namespace
string
,
reader
io
.
Reader
,
fn
ResourceActorFunc
)
error
{
func
perform
(
f
*
cmdutil
.
Factory
,
namespace
string
,
reader
io
.
Reader
,
fn
ResourceActorFunc
)
error
{
...
@@ -73,3 +81,7 @@ func createResource(info *resource.Info) error {
...
@@ -73,3 +81,7 @@ func createResource(info *resource.Info) error {
_
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
info
.
Object
)
_
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
info
.
Object
)
return
err
return
err
}
}
func
deleteResource
(
info
*
resource
.
Info
)
error
{
return
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Delete
(
info
.
Namespace
,
info
.
Name
)
}
pkg/kube/client_test.go
View file @
fb8dd392
...
@@ -65,6 +65,17 @@ func TestPerform(t *testing.T) {
...
@@ -65,6 +65,17 @@ func TestPerform(t *testing.T) {
}
}
}
}
func
TestReal
(
t
*
testing
.
T
)
{
t
.
Skip
(
"This is a live test, comment this line to run"
)
if
err
:=
New
(
nil
)
.
Create
(
"test"
,
strings
.
NewReader
(
guestbookManifest
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
New
(
nil
)
.
Delete
(
"test"
,
strings
.
NewReader
(
guestbookManifest
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
const
guestbookManifest
=
`
const
guestbookManifest
=
`
apiVersion: v1
apiVersion: v1
kind: Service
kind: Service
...
...
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