Skip to content

Commit

Permalink
Change --docker-image to just --image
Browse files Browse the repository at this point in the history
--image is easier to type, and no need for docker adjective.
Added alias for backwards compatibility.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Aug 17, 2021
1 parent 7eebbe6 commit c00cacd
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 34 deletions.
16 changes: 8 additions & 8 deletions contrib/completions/bash/oc
Expand Up @@ -15695,10 +15695,6 @@ _oc_new-app()
two_word_flags+=("--context-dir")
local_nonpersistent_flags+=("--context-dir")
local_nonpersistent_flags+=("--context-dir=")
flags+=("--docker-image=")
two_word_flags+=("--docker-image")
local_nonpersistent_flags+=("--docker-image")
local_nonpersistent_flags+=("--docker-image=")
flags+=("--dry-run")
local_nonpersistent_flags+=("--dry-run")
flags+=("--env=")
Expand Down Expand Up @@ -15731,6 +15727,10 @@ _oc_new-app()
local_nonpersistent_flags+=("--group=")
flags+=("--ignore-unknown-parameters")
local_nonpersistent_flags+=("--ignore-unknown-parameters")
flags+=("--image=")
two_word_flags+=("--image")
local_nonpersistent_flags+=("--image")
local_nonpersistent_flags+=("--image=")
flags+=("--image-stream=")
two_word_flags+=("--image-stream")
two_word_flags+=("-i")
Expand Down Expand Up @@ -15891,10 +15891,6 @@ _oc_new-build()
two_word_flags+=("--context-dir")
local_nonpersistent_flags+=("--context-dir")
local_nonpersistent_flags+=("--context-dir=")
flags+=("--docker-image=")
two_word_flags+=("--docker-image")
local_nonpersistent_flags+=("--docker-image")
local_nonpersistent_flags+=("--docker-image=")
flags+=("--dockerfile=")
two_word_flags+=("--dockerfile")
two_word_flags+=("-D")
Expand All @@ -15915,6 +15911,10 @@ _oc_new-build()
flags_completion+=("_filedir")
local_nonpersistent_flags+=("--env-file")
local_nonpersistent_flags+=("--env-file=")
flags+=("--image=")
two_word_flags+=("--image")
local_nonpersistent_flags+=("--image")
local_nonpersistent_flags+=("--image=")
flags+=("--image-stream=")
two_word_flags+=("--image-stream")
two_word_flags+=("-i")
Expand Down
24 changes: 13 additions & 11 deletions pkg/cli/newapp/newapp.go
Expand Up @@ -67,7 +67,7 @@ var (
Create a new application by specifying source code, templates, and/or images.
This command will try to build up the components of an application using images, templates,
or code that has a public repository. It will look up the images on the local Docker installation
or code that has a public repository. It will look up the images on the local container storage
(if available), a container image registry, an integrated image stream, or stored templates.
If you specify a source code URL, it will set up a build that takes your source code and converts
Expand All @@ -85,19 +85,19 @@ var (
oc new-app --list
# Create an application based on the source code in the current git repository (with a public remote) and a container image
oc new-app . --docker-image=registry/repo/langimage
oc new-app . --image=registry/repo/langimage
# Create an application myapp with Docker based build strategy expecting binary input
oc new-app --strategy=docker --binary --name myapp
# Create a Ruby application based on the provided [image]~[source code] combination
oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
# Use the public Docker Hub MySQL image to create an app. Generated artifacts will be labeled with db=mysql
# Use the public container registry MySQL image to create an app. Generated artifacts will be labeled with db=mysql
oc new-app mysql MYSQL_USER=user MYSQL_PASSWORD=pass MYSQL_DATABASE=testdb -l db=mysql
# Use a MySQL image in a private registry to create an app and override application artifacts' names
oc new-app --docker-image=myregistry.com/mycompany/mysql --name=private
oc new-app --image=myregistry.com/mycompany/mysql --name=private
# Create an application from a remote repository using its beta4 branch
oc new-app https://github.com/openshift/ruby-hello-world#beta4
Expand All @@ -117,7 +117,7 @@ var (
# Search all templates, image streams, and container images for the ones that match "ruby"
oc new-app --search ruby
# Search for "ruby", but only in stored templates (--template, --image-stream and --docker-image
# Search for "ruby", but only in stored templates (--template, --image-stream and --image
# can be used to filter search results)
oc new-app --search --template=ruby
Expand All @@ -136,7 +136,7 @@ To search templates, image streams, and container images that match the argument
oc new-app -S php
oc new-app -S --template=rails
oc new-app -S --image-stream=mysql
oc new-app -S --docker-image=registry.access.redhat.com/ubi8/python-38
oc new-app -S --image=registry.access.redhat.com/ubi8/python-38
For details on how to use the results from those searches to provide images, image streams, templates, or source code locations as inputs into 'oc new-app', use:
Expand Down Expand Up @@ -269,7 +269,9 @@ func NewCmdNewApplication(f kcmdutil.Factory, streams genericclioptions.IOStream
cmd.Flags().StringSliceVar(&o.Config.SourceRepositories, "code", o.Config.SourceRepositories, "Source code to use to build this application.")
cmd.Flags().StringVar(&o.Config.ContextDir, "context-dir", o.Config.ContextDir, "Context directory to be used for the build.")
cmd.Flags().StringSliceVarP(&o.Config.ImageStreams, "image-stream", "i", o.Config.ImageStreams, "Name of an image stream to use in the app.")
cmd.Flags().StringSliceVar(&o.Config.DockerImages, "docker-image", o.Config.DockerImages, "Name of a container image to include in the app. Note: not specifying a registry or repository means defaults in place for client image pulls are employed.")
cmd.Flags().StringSliceVar(&o.Config.DockerImages, "image", o.Config.DockerImages, "Name of a container image to include in the app. Note: not specifying a registry or repository means defaults in place for client image pulls are employed.")
cmd.Flags().StringSliceVar(&o.Config.DockerImages, "docker-image", o.Config.DockerImages, "")
cmd.Flags().MarkDeprecated("docker-image", "Deprecated flag use --image")
cmd.Flags().StringSliceVar(&o.Config.Templates, "template", o.Config.Templates, "Name of a stored template to use in the app.")
cmd.Flags().StringSliceVarP(&o.Config.TemplateFiles, "file", "f", o.Config.TemplateFiles, "Path to a template file to use for the app.")
cmd.MarkFlagFilename("file", "yaml", "yml", "json")
Expand Down Expand Up @@ -650,12 +652,12 @@ func getDockerClient() (*docker.Client, error) {
dockerClient, _, err := dockerutil.NewHelper().GetClient()
if err == nil {
if err = dockerClient.Ping(); err != nil {
klog.V(4).Infof("Docker client did not respond to a ping: %v", err)
klog.V(4).Infof("Container service did not respond to a ping: %v", err)
return nil, err
}
return dockerClient, nil
}
klog.V(2).Infof("No local Docker daemon detected: %v", err)
klog.V(2).Infof("No local container engine detected: %v", err)
return nil, err
}

Expand Down Expand Up @@ -972,7 +974,7 @@ func TransformRunError(err error, commandPath string, groups ErrorGroups, config
1. Images tagged into image streams in the current project or the 'openshift' project
- if you don't specify a tag, we'll add ':latest'
2. Images in the Docker Hub, on remote registries, or on the local Docker engine
2. Images in the container storage, on remote registries, or on the local container engine
3. Templates in the current project or the 'openshift' project
4. Git repository URLs or local paths that point to Git repositories
Expand Down Expand Up @@ -1156,7 +1158,7 @@ func printHumanReadableQueryResult(r *newcmd.QueryResult, out io.Writer) error {
}

if len(dockerImages) > 0 {
fmt.Fprintf(out, "container images (oc new-app --docker-image=<docker-image> [--code=<source>])\n")
fmt.Fprintf(out, "container images (oc new-app --image=<image> [--code=<source>])\n")
fmt.Fprintln(out, "-----")
for _, match := range dockerImages {
image := match.DockerImage
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/newapp/newapp_test.go
Expand Up @@ -45,8 +45,8 @@ func TestNewAppDefaultFlags(t *testing.T) {
flagName: "image-stream",
defaultVal: "[" + strings.Join(config.ImageStreams, ",") + "]",
},
"docker-image": {
flagName: "docker-image",
"image": {
flagName: "image",
defaultVal: "[" + strings.Join(config.DockerImages, ",") + "]",
},
"template": {
Expand Down
10 changes: 6 additions & 4 deletions pkg/cli/newbuild/newbuild.go
Expand Up @@ -29,7 +29,7 @@ var (
Create a new build by specifying source code.
This command will try to create a build configuration for your application using images and
code that has a public repository. It will look up the images on the local Docker installation
code that has a public repository. It will look up the images on the local container storage
(if available), a container image registry, or an image stream.
If you specify a source code URL, it will set up a build that takes your source code and converts
Expand All @@ -42,7 +42,7 @@ var (
newBuildExample = templates.Examples(`
# Create a build config based on the source code in the current git repository (with a public
# remote) and a container image
oc new-build . --docker-image=repo/langimage
oc new-build . --image=repo/langimage
# Create a NodeJS build config based on the provided [image]~[source code] combination
oc new-build centos/nodejs-8-centos7~https://github.com/sclorg/nodejs-ex.git
Expand Down Expand Up @@ -83,7 +83,7 @@ default container image registry.
oc new-build https://github.com/sclorg/nodejs-ex.git
will look for an image called "nodejs" in your current project, the 'openshift' project, or
on the Docker Hub.
on the configured container registries.
`
)

Expand Down Expand Up @@ -124,7 +124,9 @@ func NewCmdNewBuild(f kcmdutil.Factory, streams genericclioptions.IOStreams) *co

cmd.Flags().StringSliceVar(&o.Config.SourceRepositories, "code", o.Config.SourceRepositories, "Source code in the build configuration.")
cmd.Flags().StringSliceVarP(&o.Config.ImageStreams, "image-stream", "i", o.Config.ImageStreams, "Name of an image stream to to use as a builder.")
cmd.Flags().StringSliceVar(&o.Config.DockerImages, "image", o.Config.DockerImages, "Name of a container image to use as a builder.")
cmd.Flags().StringSliceVar(&o.Config.DockerImages, "docker-image", o.Config.DockerImages, "Name of a container image to use as a builder.")
cmd.Flags().MarkDeprecated("docker-image", "Deprecated flag use --image")
cmd.Flags().StringSliceVar(&o.Config.ConfigMaps, "build-config-map", o.Config.ConfigMaps, "ConfigMap and destination to use as an input for the build.")
cmd.Flags().StringSliceVar(&o.Config.Secrets, "build-secret", o.Config.Secrets, "Secret and destination to use as an input for the build.")
cmd.Flags().StringVar(&o.Config.SourceSecret, "source-secret", o.Config.SourceSecret, "The name of an existing secret that should be used for cloning a private git repository.")
Expand Down Expand Up @@ -257,7 +259,7 @@ func transformBuildError(err error, commandPath string, groups ocnewapp.ErrorGro
1. Images tagged into image streams in the current project or the 'openshift' project
- if you don't specify a tag, we'll add ':latest'
2. Images in the Docker Hub, on remote registries, or on the local Docker engine
2. Images in the container registry, on remote registries, or on the local container engine
3. Git repository URLs or local paths that point to Git repositories
--allow-missing-images can be used to force the use of an image that was not matched
Expand Down
6 changes: 3 additions & 3 deletions pkg/helpers/newapp/app/dockerimagelookup.go
Expand Up @@ -144,7 +144,7 @@ func (r DockerClientSearcher) Search(precise bool, terms ...string) (ComponentMa

updated := &ComponentMatch{
Value: match.Value,
Argument: fmt.Sprintf("--docker-image=%q", match.Value),
Argument: fmt.Sprintf("--image=%q", match.Value),
Name: match.Value,
Description: descriptionFor(dockerImage, match.Value, ref.Registry, ""),
Score: match.Score,
Expand Down Expand Up @@ -329,7 +329,7 @@ func (s ImageImportSearcher) Search(precise bool, terms ...string) (ComponentMat

match := &ComponentMatch{
Value: term,
Argument: fmt.Sprintf("--docker-image=%q", term),
Argument: fmt.Sprintf("--image=%q", term),
Name: term,
Description: descriptionFor(dockerImage, term, ref.Registry, ref.Tag),
Score: 0,
Expand Down Expand Up @@ -389,7 +389,7 @@ func (r DockerRegistrySearcher) Search(precise bool, terms ...string) (Component

match := &ComponentMatch{
Value: term,
Argument: fmt.Sprintf("--docker-image=%q", term),
Argument: fmt.Sprintf("--image=%q", term),
Name: term,
Description: descriptionFor(image, term, ref.Registry, ref.Tag),
Score: 0,
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/newapp/cmd/resolve.go
Expand Up @@ -299,7 +299,7 @@ func AddComponentInputsToRefBuilder(b *app.ReferenceBuilder, r *Resolvers, c *Co
return err
}
b.AddComponents(c.DockerImages, func(input *app.ComponentInput) app.ComponentReference {
input.Argument = fmt.Sprintf("--docker-image=%q", input.From)
input.Argument = fmt.Sprintf("--image=%q", input.From)
input.Searcher = r.DockerSearcher
if r.DockerSearcher != nil {
resolver := app.PerfectMatchWeightedResolver{}
Expand Down
10 changes: 5 additions & 5 deletions pkg/helpers/newapp/newapptest/newapp_test.go
Expand Up @@ -291,7 +291,7 @@ func (r *ExactMatchDockerSearcher) Search(precise bool, terms ...string) (app.Co
matches = append(matches, &app.ComponentMatch{
Value: value,
Name: value,
Argument: fmt.Sprintf("--docker-image=%q", value),
Argument: fmt.Sprintf("--image=%q", value),
Description: fmt.Sprintf("Container image %q", value),
Score: 0.0,
})
Expand All @@ -316,7 +316,7 @@ func (r *ExactMatchDirectTagDockerSearcher) Search(precise bool, terms ...string
matches = append(matches, &app.ComponentMatch{
Value: value,
Name: value,
Argument: fmt.Sprintf("--docker-image=%q", value),
Argument: fmt.Sprintf("--image=%q", value),
Description: fmt.Sprintf("Container image %q", value),
Score: 0.0,
DockerImage: &dockerv10.DockerImage{},
Expand Down Expand Up @@ -1576,7 +1576,7 @@ func TestNewAppBuildOutputCycleDetection(t *testing.T) {
checkOutput func(stdout, stderr io.Reader) error
}{
{
name: "successful build with warning that output docker-image may trigger input ImageStream change; legacy ImageStream without tags",
name: "successful build with warning that output image may trigger input ImageStream change; legacy ImageStream without tags",
config: &cmd.AppConfig{
GenerationInputs: cmd.GenerationInputs{
OutputDocker: true,
Expand Down Expand Up @@ -1677,7 +1677,7 @@ func TestNewAppBuildOutputCycleDetection(t *testing.T) {
},
},
{
name: "successful build with warning that output docker-image may trigger input ImageStream change",
name: "successful build with warning that output image may trigger input ImageStream change",
config: &cmd.AppConfig{
GenerationInputs: cmd.GenerationInputs{
OutputDocker: true,
Expand Down Expand Up @@ -1709,7 +1709,7 @@ func TestNewAppBuildOutputCycleDetection(t *testing.T) {
},
},
{
name: "successful build with warning that output docker-image may trigger input ImageStream change; latest variation",
name: "successful build with warning that output image may trigger input ImageStream change; latest variation",
config: &cmd.AppConfig{
GenerationInputs: cmd.GenerationInputs{
OutputDocker: true,
Expand Down

0 comments on commit c00cacd

Please sign in to comment.