Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPSTREAM: 38112: Add json,yaml output format support to oc create, oc apply #12015

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Nov 23, 2016

Upstream: kubernetes/kubernetes#38112
Related upstream issue: kubernetes/kubernetes#37390

This patch adds the ability to specify an output format other than
"name" to oc create .... It can be used in conjunction with the
--dry-run option.

Will add upstream PR

Due to the mapper being an UnstructuredObject, using a wide format option results in the error:

error: unknown type &runtime.Unstructured{Object:map[string]interface {}{"status":map[string]interface {}{"lastVersion":1}, "kind":"BuildConfig", "apiVersion":"v1", "metadata":map[string]interface {}{"name":"gitauthtest", "namespace":"default", "selfLink":"/oapi/v1/namespaces/default/buildconfigs/gitauthtest", "uid":"39b2c5a1-b1b3-11e6-9a01-507b9dac96e1", "resourceVersion":"800167", "creationTimestamp":"2016-11-23T19:30:00Z", "labels":map[string]interface {}{"app":"gitauthtest", "template":"gitserver"}, "annotations":map[string]interface {}{"openshift.io/generated-by":"OpenShiftNewApp"}}, "spec":map[string]interface {}{"runPolicy":"Serial", "source":map[string]interface {}{"type":"Git", "git":map[string]interface {}{"uri":"http://gitserver-tokenauth.linux.xip.io/ruby-hello-world"}, "sourceSecret":map[string]interface {}{"name":"builder-token-nbme5"}}, "strategy":map[string]interface {}{"type":"Source", "sourceStrategy":map[string]interface {}{"from":map[string]interface {}{"kind":"ImageStreamTag", "namespace":"openshift", "name":"ruby:latest"}}}, "output":map[string]interface {}{}, "resources":map[string]interface {}{}, "postCommit":map[string]interface {}{}, "nodeSelector":interface {}(nil), "triggers":[]interface {}{}}}}

To mitigate this, an unsupported output format error message is printed when a format like this one is specified.

Example

$ oc create -f pkg/api/graph/test/bc-missing-output.yaml --dry-run -o yaml
apiVersion: v1
kind: BuildConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: 2015-11-18T14:41:17Z
  labels:
    app: gitauthtest
    template: gitserver
  name: gitauthtest
  namespace: default
spec:
  output: {}
  resources: {}
  source:
    git:
      uri: http://gitserver-tokenauth.linux.xip.io/ruby-hello-world
    sourceSecret:
      name: builder-token-nbme5
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: ruby:latest
        namespace: openshift
    type: Source
  triggers: []
status:
  lastVersion: 1
$ oc create -f pkg/api/graph/test/bc-missing-output.yaml --dry-run -o wide
error: That output format is not supoported

cc @openshift/cli-review

@fabianofranz
Copy link
Member

[test]

@fabianofranz
Copy link
Member

conformance flaked on #11747 re[test]

@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch 4 times, most recently from f713021 to 1177067 Compare November 28, 2016 19:37
if !decoded {
return fmt.Errorf("Unsupported output format for the current object")
}
return f.PrintObject(cmd, registered.RESTMapper(), decodedObj, out)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabianofranz Added support for printing unstructured objects with a wide printer. PTAL
Sample output:

$ oc create -f pkg/api/graph/test/bc-missing-output.yaml --dry-run -o wide
NAME          TYPE      FROM      LATEST
gitauthtest   Source    Git       1

@juanvallejo
Copy link
Contributor Author

networking check flaked on #12091 re[test]

@juanvallejo
Copy link
Contributor Author

@fabianofranz I can go ahead and open an Upstream PR if everything looks okay

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Dec 5, 2016

Related upstream PR: kubernetes/kubernetes#38112

@juanvallejo juanvallejo changed the title Add json,yaml output format support to oc create UPSTREAM: 38112: Add json,yaml output format support to oc create Dec 5, 2016
This patch adds the ability to specify an output format other than
"name" to `oc create ...`. It can be used in conjunction with the
`--dry-run` option.
@juanvallejo
Copy link
Contributor Author

conformance check flaked on #11662 re[test]

@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch 2 times, most recently from 7e0a6b2 to c054309 Compare December 5, 2016 21:06
@juanvallejo juanvallejo changed the title UPSTREAM: 38112: Add json,yaml output format support to oc create UPSTREAM: 38112: Add json,yaml output format support to oc create, oc apply Dec 5, 2016
@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch from c054309 to 1b1722a Compare December 5, 2016 22:32
This patch adds the same printer output format support that was added to
`oc create` to the `apply` command.
@juanvallejo
Copy link
Contributor Author

check flaked on #12157 re[test]

1 similar comment
@juanvallejo
Copy link
Contributor Author

check flaked on #12157 re[test]

@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch from db098d5 to fb45bd6 Compare December 7, 2016 14:57
@juanvallejo
Copy link
Contributor Author

integration flaked on #8571
re[test]

@juanvallejo
Copy link
Contributor Author

integration flaked on #8571
re[test]

@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch from fb45bd6 to aaaae1b Compare December 8, 2016 20:39
@juanvallejo juanvallejo force-pushed the jvallejo/add-output-format-support-oc-create branch from aaaae1b to 971c51c Compare December 9, 2016 17:08
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 971c51c

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12205/) (Base Commit: 79fdfb4)

@juanvallejo
Copy link
Contributor Author

@fabianofranz Upstream merged!
This patch is up to date with upstream PR, however this PR also adds this block to resource_printer, which handles unstructured objects. It is missing from the current version of go we vendor, but already exists upstream.

@fabianofranz
Copy link
Member

@juanvallejo cool, are you ok with tagging this as post-rebase and waiting until the next one?

@juanvallejo
Copy link
Contributor Author

@fabianofranz definitely, it would remove the need to modify resource_printer if we wait until the rebase

@fabianofranz
Copy link
Member

@juanvallejo actually this is just UPSTREAM commits. Are there any Origin issues or bugs this fixes? Otherwise I think it's just closing this one and waiting for the rebase. :)

@juanvallejo
Copy link
Contributor Author

@fabianofranz

@juanvallejo actually this is just UPSTREAM commits. Are there any Origin issues or bugs this fixes?

Looks like we'll get all of the changes with the next rebase, closing this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants