| ... | ... |
@@ -139,12 +139,14 @@ echo "templates: ok" |
| 139 | 139 |
[ "$(openshift cli get --help 2>&1 | grep 'Display one or many resources')" ] |
| 140 | 140 |
[ "$(openshift kubectl get --help 2>&1 | grep 'Display one or many resources')" ] |
| 141 | 141 |
[ "$(openshift start --help 2>&1 | grep 'Start an OpenShift server')" ] |
| 142 |
+[ "$(osc get --help 2>&1 | grep 'osc')" ] |
|
| 142 | 143 |
|
| 143 | 144 |
# help for given command through help command must be consistent |
| 144 | 145 |
[ "$(osc help get 2>&1 | grep 'Display one or many resources')" ] |
| 145 | 146 |
[ "$(openshift cli help get 2>&1 | grep 'Display one or many resources')" ] |
| 146 | 147 |
[ "$(openshift kubectl help get 2>&1 | grep 'Display one or many resources')" ] |
| 147 | 148 |
[ "$(openshift help start 2>&1 | grep 'Start an OpenShift server')" ] |
| 149 |
+[ "$(openshift cli help update 2>&1 | grep 'openshift')" ] |
|
| 148 | 150 |
|
| 149 | 151 |
# runnable commands with required flags must error consistently |
| 150 | 152 |
[ "$(osc get 2>&1 | grep 'you must provide one or more resources')" ] |
| ... | ... |
@@ -66,15 +66,15 @@ func NewCommandCLI(name, fullName string) *cobra.Command {
|
| 66 | 66 |
cmds.AddCommand(cmd.NewCmdBuildLogs(f, out)) |
| 67 | 67 |
cmds.AddCommand(cmd.NewCmdRollback(name, "rollback", f, out)) |
| 68 | 68 |
|
| 69 |
- cmds.AddCommand(f.NewCmdGet(out)) |
|
| 69 |
+ cmds.AddCommand(cmd.NewCmdGet(fullName, f, out)) |
|
| 70 | 70 |
cmds.AddCommand(f.NewCmdDescribe(out)) |
| 71 | 71 |
// Deprecate 'osc apply' with 'osc create' command. |
| 72 |
- cmds.AddCommand(applyToCreate(f.NewCmdCreate(out))) |
|
| 72 |
+ cmds.AddCommand(applyToCreate(cmd.NewCmdCreate(fullName, f, out))) |
|
| 73 | 73 |
cmds.AddCommand(cmd.NewCmdProcess(f, out)) |
| 74 |
- cmds.AddCommand(f.NewCmdUpdate(out)) |
|
| 75 |
- cmds.AddCommand(f.NewCmdDelete(out)) |
|
| 74 |
+ cmds.AddCommand(cmd.NewCmdUpdate(fullName, f, out)) |
|
| 75 |
+ cmds.AddCommand(cmd.NewCmdDelete(fullName, f, out)) |
|
| 76 | 76 |
|
| 77 |
- cmds.AddCommand(f.NewCmdLog(out)) |
|
| 77 |
+ cmds.AddCommand(cmd.NewCmdLog(fullName, f, out)) |
|
| 78 | 78 |
cmds.AddCommand(f.NewCmdProxy(out)) |
| 79 | 79 |
|
| 80 | 80 |
cmds.AddCommand(kubecmd.NewCmdNamespace(out)) |
| 81 | 81 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,123 @@ |
| 0 |
+package cmd |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "io" |
|
| 5 |
+ |
|
| 6 |
+ "github.com/spf13/cobra" |
|
| 7 |
+ |
|
| 8 |
+ "github.com/openshift/origin/pkg/cmd/util/clientcmd" |
|
| 9 |
+) |
|
| 10 |
+ |
|
| 11 |
+func NewCmdGet(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
|
| 12 |
+ cmd := f.NewCmdGet(out) |
|
| 13 |
+ longDesc := `Display one or many resources. |
|
| 14 |
+ |
|
| 15 |
+Possible resources include builds, buildConfigs, services, pods, etc. |
|
| 16 |
+ |
|
| 17 |
+Examples: |
|
| 18 |
+ |
|
| 19 |
+ # List all pods in ps output format. |
|
| 20 |
+ $ %[1]s get pods |
|
| 21 |
+ |
|
| 22 |
+ # List a single replication controller with specified ID in ps output format. |
|
| 23 |
+ $ %[1]s get replicationController 1234-56-7890-234234-456456 |
|
| 24 |
+ |
|
| 25 |
+ # List a single pod in JSON output format. |
|
| 26 |
+ $ %[1]s get -o json pod 1234-56-7890-234234-456456 |
|
| 27 |
+ |
|
| 28 |
+ # Return only the status value of the specified pod. |
|
| 29 |
+ $ %[1]s get -o template pod 1234-56-7890-234234-456456 --template={{.currentState.status}}
|
|
| 30 |
+` |
|
| 31 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 32 |
+ return cmd |
|
| 33 |
+} |
|
| 34 |
+ |
|
| 35 |
+func NewCmdUpdate(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
|
| 36 |
+ cmd := f.NewCmdUpdate(out) |
|
| 37 |
+ longDesc := `Update a resource by filename or stdin. |
|
| 38 |
+ |
|
| 39 |
+JSON and YAML formats are accepted. |
|
| 40 |
+ |
|
| 41 |
+Examples: |
|
| 42 |
+ |
|
| 43 |
+ # Update a pod using the data in pod.json. |
|
| 44 |
+ $ %[1]s update -f pod.json |
|
| 45 |
+ |
|
| 46 |
+ # Update a pod based on the JSON passed into stdin. |
|
| 47 |
+ $ cat pod.json | %[1]s update -f - |
|
| 48 |
+ |
|
| 49 |
+ # Update a pod by downloading it, applying the patch, then updating. Requires apiVersion be specified. |
|
| 50 |
+ $ %[1]s update pods my-pod --patch='{ "apiVersion": "v1beta1", "desiredState": { "manifest": [{ "cpu": 100 }]}}'
|
|
| 51 |
+` |
|
| 52 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 53 |
+ return cmd |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+func NewCmdDelete(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
|
| 57 |
+ cmd := f.NewCmdDelete(out) |
|
| 58 |
+ longDesc := `Delete a resource by filename, stdin, resource and ID, or by resources and label selector. |
|
| 59 |
+ |
|
| 60 |
+JSON and YAML formats are accepted. |
|
| 61 |
+ |
|
| 62 |
+If both a filename and command line arguments are passed, the command line |
|
| 63 |
+arguments are used and the filename is ignored. |
|
| 64 |
+ |
|
| 65 |
+Note that the delete command does NOT do resource version checks, so if someone |
|
| 66 |
+submits an update to a resource right when you submit a delete, their update |
|
| 67 |
+will be lost along with the rest of the resource. |
|
| 68 |
+ |
|
| 69 |
+Examples: |
|
| 70 |
+ |
|
| 71 |
+ # Delete a pod using the type and ID specified in pod.json. |
|
| 72 |
+ $ %[1]s delete -f pod.json |
|
| 73 |
+ |
|
| 74 |
+ # Delete a pod based on the type and ID in the JSON passed into stdin. |
|
| 75 |
+ $ cat pod.json | %[1]s delete -f - |
|
| 76 |
+ |
|
| 77 |
+ # Delete pods and services with label name=myLabel. |
|
| 78 |
+ $ %[1]s delete pods,services -l name=myLabel |
|
| 79 |
+ |
|
| 80 |
+ # Delete a pod with ID 1234-56-7890-234234-456456. |
|
| 81 |
+ $ %[1]s delete pod 1234-56-7890-234234-456456 |
|
| 82 |
+ |
|
| 83 |
+ # Delete all pods |
|
| 84 |
+ $ %[1]s delete pods --all |
|
| 85 |
+` |
|
| 86 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 87 |
+ return cmd |
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+func NewCmdLog(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
|
| 91 |
+ cmd := f.NewCmdLog(out) |
|
| 92 |
+ longDesc := `Print the logs for a container in a pod. If the pod has only one container, the container name is optional. |
|
| 93 |
+ |
|
| 94 |
+Examples: |
|
| 95 |
+ |
|
| 96 |
+ # Returns snapshot of ruby-container logs from pod 123456-7890. |
|
| 97 |
+ $ %[1]s log 123456-7890 ruby-container |
|
| 98 |
+ |
|
| 99 |
+ # Starts streaming of ruby-container logs from pod 123456-7890. |
|
| 100 |
+ $ %[1]s log -f 123456-7890 ruby-container |
|
| 101 |
+` |
|
| 102 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 103 |
+ return cmd |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 106 |
+func NewCmdCreate(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
|
|
| 107 |
+ cmd := f.NewCmdCreate(out) |
|
| 108 |
+ longDesc := `Create a resource by filename or stdin. |
|
| 109 |
+ |
|
| 110 |
+JSON and YAML formats are accepted. |
|
| 111 |
+ |
|
| 112 |
+Examples: |
|
| 113 |
+ |
|
| 114 |
+ # Create a pod using the data in pod.json. |
|
| 115 |
+ $ %[1]s create -f pod.json |
|
| 116 |
+ |
|
| 117 |
+ # Create a pod based on the JSON passed into stdin. |
|
| 118 |
+ $ cat pod.json | %[1]s create -f - |
|
| 119 |
+` |
|
| 120 |
+ cmd.Long = fmt.Sprintf(longDesc, fullName) |
|
| 121 |
+ return cmd |
|
| 122 |
+} |