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
bc86b31a
Commit
bc86b31a
authored
Jan 03, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove createall now that create supports directories and sources
parent
d1ab2776
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
133 deletions
+15
-133
README.md
contrib/flags2yaml/README.md
+1
-1
README.md
contrib/simplegen/README.md
+2
-2
simplegen.go
contrib/simplegen/simplegen.go
+2
-2
srvexpand.go
contrib/srvexpand/srvexpand.go
+2
-2
cmd.go
pkg/kubectl/cmd/cmd.go
+0
-1
cmd_test.go
pkg/kubectl/cmd/cmd_test.go
+5
-1
create_test.go
pkg/kubectl/cmd/create_test.go
+1
-1
createall.go
pkg/kubectl/cmd/createall.go
+0
-121
get_test.go
pkg/kubectl/cmd/get_test.go
+2
-2
No files found.
contrib/flags2yaml/README.md
View file @
bc86b31a
...
@@ -4,5 +4,5 @@
...
@@ -4,5 +4,5 @@
### Usage
### Usage
```
```
$ flags2yaml image=dockerfile/nginx | simplegen - | cluster/kubectl.sh create
all
-f -
$ flags2yaml image=dockerfile/nginx | simplegen - | cluster/kubectl.sh create -f -
```
```
contrib/simplegen/README.md
View file @
bc86b31a
...
@@ -41,8 +41,8 @@ portSpec: 10001:6379
...
@@ -41,8 +41,8 @@ portSpec: 10001:6379
```
```
Output:
Output:
```
```
$ simplegen redismaster.yaml | cluster/kubectl.sh create
all
-f -
$ simplegen redismaster.yaml | cluster/kubectl.sh create -f -
$ simplegen redisslave.yaml | cluster/kubectl.sh create
all
-f -
$ simplegen redisslave.yaml | cluster/kubectl.sh create -f -
$ cluster/kubectl.sh get services
$ cluster/kubectl.sh get services
NAME LABELS SELECTOR IP PORT
NAME LABELS SELECTOR IP PORT
kubernetes-ro component=apiserver,provider=kubernetes 10.0.0.2 80
kubernetes-ro component=apiserver,provider=kubernetes 10.0.0.2 80
...
...
contrib/simplegen/simplegen.go
View file @
bc86b31a
...
@@ -16,8 +16,8 @@ limitations under the License.
...
@@ -16,8 +16,8 @@ limitations under the License.
// simplegen is a tool to generate simple services from a simple description
// simplegen is a tool to generate simple services from a simple description
//
//
// $ simplegen myservice.json | kubectl create
all
-f -
// $ simplegen myservice.json | kubectl create -f -
// $ simplegen myservice.yaml | kubectl create
all
-f -
// $ simplegen myservice.yaml | kubectl create -f -
//
//
// This is completely separate from kubectl at the moment, until we figure out
// This is completely separate from kubectl at the moment, until we figure out
// what the right integration approach is.
// what the right integration approach is.
...
...
contrib/srvexpand/srvexpand.go
View file @
bc86b31a
...
@@ -17,8 +17,8 @@ limitations under the License.
...
@@ -17,8 +17,8 @@ limitations under the License.
// srvexpand is a tool to generate non-trivial but regular services
// srvexpand is a tool to generate non-trivial but regular services
// from a description free of most boilerplate
// from a description free of most boilerplate
//
//
// $ srvexpand myservice.json | kubectl create
all
-f -
// $ srvexpand myservice.json | kubectl create -f -
// $ srvexpand myservice.yaml | kubectl create
all
-f -
// $ srvexpand myservice.yaml | kubectl create -f -
//
//
// This is completely separate from kubectl at the moment, until we figure out
// This is completely separate from kubectl at the moment, until we figure out
// what the right integration approach is.
// what the right integration approach is.
...
...
pkg/kubectl/cmd/cmd.go
View file @
bc86b31a
...
@@ -165,7 +165,6 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
...
@@ -165,7 +165,6 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
cmds
.
AddCommand
(
f
.
NewCmdGet
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdGet
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdDescribe
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdDescribe
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdCreate
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdCreate
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdCreateAll
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdUpdate
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdUpdate
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdDelete
(
out
))
cmds
.
AddCommand
(
f
.
NewCmdDelete
(
out
))
...
...
pkg/kubectl/cmd/cmd_test.go
View file @
bc86b31a
...
@@ -92,6 +92,8 @@ func (t *testDescriber) Describe(namespace, name string) (output string, err err
...
@@ -92,6 +92,8 @@ func (t *testDescriber) Describe(namespace, name string) (output string, err err
}
}
type
testFactory
struct
{
type
testFactory
struct
{
Mapper
meta
.
RESTMapper
Typer
runtime
.
ObjectTyper
Client
kubectl
.
RESTClient
Client
kubectl
.
RESTClient
Describer
kubectl
.
Describer
Describer
kubectl
.
Describer
Printer
kubectl
.
ResourcePrinter
Printer
kubectl
.
ResourcePrinter
...
@@ -103,10 +105,12 @@ func NewTestFactory() (*Factory, *testFactory, runtime.Codec) {
...
@@ -103,10 +105,12 @@ func NewTestFactory() (*Factory, *testFactory, runtime.Codec) {
scheme
,
mapper
,
codec
:=
newExternalScheme
()
scheme
,
mapper
,
codec
:=
newExternalScheme
()
t
:=
&
testFactory
{
t
:=
&
testFactory
{
Validator
:
validation
.
NullSchema
{},
Validator
:
validation
.
NullSchema
{},
Mapper
:
mapper
,
Typer
:
scheme
,
}
}
return
&
Factory
{
return
&
Factory
{
Object
:
func
(
*
cobra
.
Command
)
(
meta
.
RESTMapper
,
runtime
.
ObjectTyper
)
{
Object
:
func
(
*
cobra
.
Command
)
(
meta
.
RESTMapper
,
runtime
.
ObjectTyper
)
{
return
mapper
,
scheme
return
t
.
Mapper
,
t
.
Typer
},
},
RESTClient
:
func
(
*
cobra
.
Command
,
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
RESTClient
:
func
(
*
cobra
.
Command
,
*
meta
.
RESTMapping
)
(
resource
.
RESTClient
,
error
)
{
return
t
.
Client
,
t
.
Err
return
t
.
Client
,
t
.
Err
...
...
pkg/kubectl/cmd/create_test.go
View file @
bc86b31a
...
@@ -99,7 +99,7 @@ func TestCreateDirectory(t *testing.T) {
...
@@ -99,7 +99,7 @@ func TestCreateDirectory(t *testing.T) {
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
pods
.
Items
[
0
])},
nil
case
p
==
"/ns/test/services"
&&
m
==
"POST"
:
case
p
==
"/ns/test/services"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
case
p
==
"/ns/test/replication
C
ontrollers"
&&
m
==
"POST"
:
case
p
==
"/ns/test/replication
c
ontrollers"
&&
m
==
"POST"
:
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
return
&
http
.
Response
{
StatusCode
:
201
,
Body
:
objBody
(
codec
,
&
svc
.
Items
[
0
])},
nil
default
:
default
:
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
t
.
Fatalf
(
"unexpected request: %#v
\n
%#v"
,
req
.
URL
,
req
)
...
...
pkg/kubectl/cmd/createall.go
deleted
100644 → 0
View file @
d1ab2776
/*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
cmd
import
(
"fmt"
"io"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta"
"github.com/GoogleCloudPlatform/kubernetes/pkg/config"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/spf13/cobra"
)
// DataToObjects converts the raw JSON data into API objects
func
DataToObjects
(
m
meta
.
RESTMapper
,
t
runtime
.
ObjectTyper
,
data
[]
byte
)
(
result
[]
runtime
.
Object
,
errors
[]
error
)
{
configObj
:=
[]
runtime
.
RawExtension
{}
if
err
:=
yaml
.
Unmarshal
(
data
,
&
configObj
);
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"config unmarshal: %v"
,
err
))
return
result
,
errors
}
for
i
,
in
:=
range
configObj
{
version
,
kind
,
err
:=
t
.
DataVersionAndKind
(
in
.
RawJSON
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"item[%d] kind: %v"
,
i
,
err
))
continue
}
mapping
,
err
:=
m
.
RESTMapping
(
kind
,
version
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"item[%d] mapping: %v"
,
i
,
err
))
continue
}
obj
,
err
:=
mapping
.
Codec
.
Decode
(
in
.
RawJSON
)
if
err
!=
nil
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"item[%d] decode: %v"
,
i
,
err
))
continue
}
result
=
append
(
result
,
obj
)
}
return
}
func
(
f
*
Factory
)
NewCmdCreateAll
(
out
io
.
Writer
)
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"createall [-d directory] [-f filename]"
,
Short
:
"Create all resources specified in a directory, filename or stdin"
,
Long
:
`Create all resources contained in JSON file specified in a directory, filename or stdin
JSON and YAML formats are accepted.
Examples:
$ kubectl createall -d configs/
<creates all resources listed in JSON or YAML files, found recursively under the configs directory>
$ kubectl createall -f config.json
<creates all resources listed in config.json>
$ cat config.json | kubectl apply -f -
<creates all resources listed in config.json>`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
clientFunc
:=
func
(
mapping
*
meta
.
RESTMapping
)
(
config
.
RESTClientPoster
,
error
)
{
client
,
err
:=
f
.
RESTClient
(
cmd
,
mapping
)
checkErr
(
err
)
return
client
,
nil
}
filename
:=
GetFlagString
(
cmd
,
"filename"
)
directory
:=
GetFlagString
(
cmd
,
"directory"
)
if
(
len
(
filename
)
==
0
&&
len
(
directory
)
==
0
)
||
(
len
(
filename
)
!=
0
&&
len
(
directory
)
!=
0
)
{
usageError
(
cmd
,
"Must pass a directory or filename to update"
)
}
files
:=
[]
string
{}
if
len
(
filename
)
!=
0
{
files
=
append
(
files
,
filename
)
}
else
{
files
=
append
(
GetFilesFromDir
(
directory
,
".json"
),
GetFilesFromDir
(
directory
,
".yaml"
)
...
)
}
mapper
,
typer
:=
f
.
Object
(
cmd
)
for
_
,
filename
:=
range
files
{
data
,
err
:=
ReadConfigData
(
filename
)
checkErr
(
err
)
items
,
errs
:=
DataToObjects
(
mapper
,
typer
,
data
)
applyErrs
:=
config
.
CreateObjects
(
typer
,
mapper
,
clientFunc
,
items
)
errs
=
append
(
errs
,
applyErrs
...
)
if
len
(
errs
)
>
0
{
for
_
,
e
:=
range
errs
{
glog
.
Error
(
e
)
}
}
}
},
}
cmd
.
Flags
()
.
StringP
(
"directory"
,
"d"
,
""
,
"Directory of JSON or YAML files to use to update the resource"
)
cmd
.
Flags
()
.
StringP
(
"filename"
,
"f"
,
""
,
"Filename or URL to file to use to update the resource"
)
return
cmd
}
pkg/kubectl/cmd/get_test.go
View file @
bc86b31a
...
@@ -90,8 +90,8 @@ func TestGetUnknownSchemaObject(t *testing.T) {
...
@@ -90,8 +90,8 @@ func TestGetUnknownSchemaObject(t *testing.T) {
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
// Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get.
func
TestGetSchemaObject
(
t
*
testing
.
T
)
{
func
TestGetSchemaObject
(
t
*
testing
.
T
)
{
f
,
tf
,
_
:=
NewTestFactory
()
f
,
tf
,
_
:=
NewTestFactory
()
f
.
Mapper
=
latest
.
RESTMapper
t
f
.
Mapper
=
latest
.
RESTMapper
f
.
Typer
=
api
.
Scheme
t
f
.
Typer
=
api
.
Scheme
codec
:=
latest
.
Codec
codec
:=
latest
.
Codec
tf
.
Printer
=
&
testPrinter
{}
tf
.
Printer
=
&
testPrinter
{}
tf
.
Client
=
&
client
.
FakeRESTClient
{
tf
.
Client
=
&
client
.
FakeRESTClient
{
...
...
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