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
ccdc20d9
Commit
ccdc20d9
authored
Jan 14, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore empty objects from streams and error when nothing passed to create
Passing zero objects to create should be an error
parent
31413c87
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
test-cmd.sh
hack/test-cmd.sh
+5
-5
create.go
pkg/kubectl/cmd/create.go
+5
-0
visitor.go
pkg/kubectl/resource/visitor.go
+5
-0
No files found.
hack/test-cmd.sh
View file @
ccdc20d9
...
...
@@ -115,6 +115,9 @@ for version in "${kube_api_versions[@]}"; do
[
"
$(
kubectl get minions
-t
$'{{ .apiVersion }}'
"
${
kube_flags
[@]
}
"
)
"
==
"
${
version
}
"
]
fi
# passing no arguments to create is an error
[
!
$(
kubectl create
)
]
kube::log::status
"Testing kubectl(
${
version
}
:pods)"
kubectl get pods
"
${
kube_flags
[@]
}
"
kubectl create
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
...
...
@@ -144,14 +147,11 @@ for version in "${kube_api_versions[@]}"; do
"apiVersion": "v1beta1",
"id": "service-
${
version
}
-test",
"port": 80,
"protocol": "TCP",
"labels": {
"name": "
${
version
}
"
}
"protocol": "TCP"
}
__EOF__
kubectl get services
"something-
${
version
}
"
"
${
kube_flags
[@]
}
"
kubectl get services
"
${
kube_flags
[@]
}
"
kubectl get services
"service-
${
version
}
-test"
"
${
kube_flags
[@]
}
"
kubectl delete service frontend
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(
${
version
}
:replicationcontrollers)"
...
...
pkg/kubectl/cmd/create.go
View file @
ccdc20d9
...
...
@@ -55,6 +55,7 @@ Examples:
Flatten
()
.
Do
()
count
:=
0
err
=
r
.
Visit
(
func
(
info
*
resource
.
Info
)
error
{
data
,
err
:=
info
.
Mapping
.
Codec
.
Encode
(
info
.
Object
)
if
err
!=
nil
{
...
...
@@ -66,11 +67,15 @@ Examples:
if
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
data
);
err
!=
nil
{
return
err
}
count
++
// TODO: if generation of names added to server side, change this to use the server's name
fmt
.
Fprintf
(
out
,
"%s
\n
"
,
info
.
Name
)
return
nil
})
checkErr
(
err
)
if
count
==
0
{
checkErr
(
fmt
.
Errorf
(
"no objects passed to create"
))
}
},
}
cmd
.
Flags
()
.
VarP
(
&
flags
.
Filenames
,
"filename"
,
"f"
,
"Filename, directory, or URL to file to use to create the resource"
)
...
...
pkg/kubectl/resource/visitor.go
View file @
ccdc20d9
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
resource
import
(
"bytes"
"fmt"
"io"
"io/ioutil"
...
...
@@ -356,6 +357,10 @@ func (v *StreamVisitor) Visit(fn VisitorFunc) error {
}
return
err
}
ext
.
RawJSON
=
bytes
.
TrimSpace
(
ext
.
RawJSON
)
if
len
(
ext
.
RawJSON
)
==
0
||
bytes
.
Equal
(
ext
.
RawJSON
,
[]
byte
(
"null"
))
{
continue
}
info
,
err
:=
v
.
InfoForData
(
ext
.
RawJSON
,
v
.
Source
)
if
err
!=
nil
{
if
v
.
IgnoreErrors
{
...
...
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