Skip to content

oc new-build should have a --to option that sets the name of the output image tag #4980

Closed

Description

@smarterclayton

It should be possible to do

oc new-build <source> --to=somenamespace/some:other

which should define the build output image and this should work in concert with --to-docker. It should also be possible to have no output for a build.

Activity

  1. rhcarvalho commented on Oct 11, 2015

    @rhcarvalho
    Contributor

    I have a few questions about how this interacts with the -D argument to new-build.

    Should this create a BuildConfig without setting its Output.To field?

    $ oc new-build -D $'FROM centos:7\nRUN yum install -y httpd'
    

    To have a build output to an image stream from a oneliner Dockerfile, is it required to pass --to?

    $ oc new-build -D $'FROM centos:7\nRUN yum install -y httpd' --to=openshift/httpd:latest
    

    Given that we should never come up with names the user has not provided, shall we replace this with an error or is it an exception and should stay as is?
    https://github.com/openshift/origin/blob/master/pkg/generate/app/pipeline.go#L45-L47

  2. smarterclayton commented on Oct 11, 2015

    @smarterclayton
    ContributorAuthor

    On Oct 11, 2015, at 9:07 AM, Rodolfo Carvalho [email protected]
    wrote:

    I have a few questions about how this interacts with the -D argument to
    new-build.

    Should this create a BuildConfig without setting its Output.To field?

    $ oc new-build -D $'FROM centos:7\nRUN yum install -y httpd'

    No, the output name should be centos:latest. The input tag should be
    centos:7

    If the one liner was FROM centos, then the names would be identical and the
    CLI should display an error "the default image output name for the build %q
    is the same as the source image location - specify a unique destination
    with --to or change the name of your build with --name"

    To have a build output to an image stream from a oneliner Dockerfile, is it
    required to pass --to?

    $ oc new-build -D $'FROM centos:7\nRUN yum install -y httpd'
    --to=openshift/httpd:latest

    Given that we should never come up with names the user has not provided,
    shall we replace this with an error or is it an exception and should stay
    as is?
    https://github.com/openshift/origin/blob/master/pkg/generate/app/pipeline.go#L45-L47

    if !ok {
    name = fmt.Sprintf("app%d", rand.Intn(10000))
    }

    It probably shouldn't be "app%d" but instead a typed error
    (NameRequiredForBuild), and the cli above it should report to the use "you
    must specify a name for your output image with --name".

  3. rhcarvalho commented on Oct 12, 2015

    @rhcarvalho
    Contributor

    @smarterclayton thanks for the answers above. I've got one more related to how --to and --name would interact.

    What should be the outcome (stdout output + what is created on the server) of this:

    $ oc new-build \
      -D $'FROM centos:7\nRUN yum install -y httpd' \
      --name=mybuild \
      --to=openshift/httpd:latest
    

    I imagine --to would take precedence over --name in defining the name of the output image stream, such that stdout would be:

    imagestreams/centos
    imagestreams/httpd
    buildconfigs/mybuild
    Build configuration "mybuild" created and build triggered.
    Run 'oc status' to check the progress.
    

    Do you think differently?

  4. smarterclayton commented on Oct 12, 2015

    @smarterclayton
    ContributorAuthor

    Yes, that's correct.

    On Oct 12, 2015, at 7:28 AM, Rodolfo Carvalho [email protected]
    wrote:

    @smarterclayton https://github.com/smarterclayton thanks for the answers
    above. I've got one more related to how --to and --name would interact.

    What should be the outcome (stdout output + what is created on the server)
    of this:

    $ oc new-build
    -D $'FROM centos:7\nRUN yum install -y httpd'
    --name=mybuild
    --to=openshift/httpd:latest

    I imagine --to would take precedence over --name in defining the name of
    the output image stream, such that stdout would be:

    imagestreams/centos
    imagestreams/httpd
    buildconfigs/mybuild
    Build configuration "mybuild" created and build triggered.
    Run 'oc status' to check the progress.

    Do you think differently?

    —
    Reply to this email directly or view it on GitHub
    #4980 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions