diff --git a/cmd/sti/main.go b/cmd/sti/main.go index 0ea618e7b..339f1acf1 100644 --- a/cmd/sti/main.go +++ b/cmd/sti/main.go @@ -74,6 +74,7 @@ func newCmdVersion() *cobra.Command { func newCmdBuild(cfg *api.Config) *cobra.Command { useConfig := false + oldScriptsFlag := "" buildCmd := &cobra.Command{ Use: "build []", @@ -143,6 +144,11 @@ func newCmdBuild(cfg *api.Config) *cobra.Command { cfg.Environment[k] = v } + if len(oldScriptsFlag) != 0 { + glog.Warning("Flag --scripts is deprecated, use --scripts-url instead") + cfg.ScriptsURL = oldScriptsFlag + } + if glog.V(2) { fmt.Printf("\n%s\n", describe.DescribeConfig(cfg)) } @@ -164,7 +170,8 @@ func newCmdBuild(cfg *api.Config) *cobra.Command { buildCmd.Flags().StringP("env", "e", "", "Specify an environment var NAME=VALUE,NAME2=VALUE2,...") buildCmd.Flags().StringVarP(&(cfg.Ref), "ref", "r", "", "Specify a ref to check-out") buildCmd.Flags().StringVar(&(cfg.CallbackURL), "callback-url", "", "Specify a URL to invoke via HTTP POST upon build completion") - buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts", "s", "", "Specify a URL for the assemble and run scripts") + buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble and run scripts") + buildCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "Specify a URL for the assemble and run scripts") buildCmd.Flags().StringVarP(&(cfg.Location), "location", "l", "", "Specify a destination location for untar operation") buildCmd.Flags().BoolVar(&(cfg.ForcePull), "force-pull", true, "Always pull the builder image even if it is present locally") buildCmd.Flags().BoolVar(&(cfg.PreserveWorkingDir), "save-temp-dir", false, "Save the temporary directory used by STI instead of deleting it") @@ -195,6 +202,8 @@ func newCmdCreate() *cobra.Command { } func newCmdUsage(cfg *api.Config) *cobra.Command { + oldScriptsFlag := "" + usageCmd := &cobra.Command{ Use: "usage ", Short: "Print usage of the assemble script associated with the image", @@ -210,6 +219,11 @@ func newCmdUsage(cfg *api.Config) *cobra.Command { checkErr(err) cfg.Environment = envs + if len(oldScriptsFlag) != 0 { + glog.Warning("Flag --scripts is deprecated, use --scripts-url instead") + cfg.ScriptsURL = oldScriptsFlag + } + uh, err := sti.NewUsage(cfg) checkErr(err) err = uh.Show() @@ -217,7 +231,8 @@ func newCmdUsage(cfg *api.Config) *cobra.Command { }, } usageCmd.Flags().StringP("env", "e", "", "Specify an environment var NAME=VALUE,NAME2=VALUE2,...") - usageCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts", "s", "", "Specify a URL for the assemble and run scripts") + usageCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble and run scripts") + usageCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "Specify a URL for the assemble and run scripts") usageCmd.Flags().BoolVar(&(cfg.ForcePull), "force-pull", true, "Always pull the builder image even if it is present locally") usageCmd.Flags().BoolVar(&(cfg.PreserveWorkingDir), "save-temp-dir", false, "Save the temporary directory used by STI instead of deleting it") usageCmd.Flags().StringVarP(&(cfg.Location), "location", "l", "", "Specify a destination location for untar operation") diff --git a/docs/builder_image.md b/docs/builder_image.md index 3e954c020..10c977abc 100644 --- a/docs/builder_image.md +++ b/docs/builder_image.md @@ -15,7 +15,7 @@ final docker image, the three are: sources, scripts and builder image. During th build process sti must place sources and scripts inside that builder image. To do so sti creates a tar file containing the two and then streams that file into the builder image. Before executing `assemble` script, sti untars that file and places -its contents into the location specified with `--location` flag or `io.openshift.sti.location` +its contents into the location specified with `--location` flag or `io.s2i.location` label from the builder image (default location is `/tmp`). For this to happen your image must supply tar archiving utility (command `tar` available in `$PATH`) and command line interpreter (command `/bin/sh`). Doing so will allow your image to diff --git a/docs/cli.md b/docs/cli.md index caf8fbcf6..9b5cd5f25 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -73,7 +73,7 @@ that image and add them to the tar streamed to the container into `/artifacts`. | `--rm` | Remove previous image during incremental build | | `--save-temp-dir` | Save the working directory used for fetching scripts and sources | | `--context-dir` | Allow to specify directory name with your application | -| `-s (--scripts)` | URL of STI scripts (see [STI Scripts](#sti-scripts)) | +| `-s (--scripts-url)` | URL of STI scripts (see [STI Scripts](#sti-scripts)) | | `-q (--quiet)` | Operate quietly, suppressing all non-error output | #### Context directory @@ -103,11 +103,11 @@ Example data posted will be of the form: STI supports multiple options providing `assemble`/`run`/`save-artifacts` scripts. All of these locations are checked on each build in the following order: -1. A script found at the `--scripts` URL +1. A script found at the `--scripts-url` URL 1. A script found in the application source `.sti/bin` directory -1. A script found at the default image URL (`io.openshift.sti.scripts-url` label) +1. A script found at the default image URL (`io.s2i.scripts-url` label) -Both `io.openshift.sti.scripts-url` label specified in the image and `--scripts` flag +Both `io.s2i.scripts-url` label specified in the image and `--scripts-url` flag can take one of the following form: * `image://path_to_scripts_dir` - absolute path inside the image to a directory where the STI scripts are located @@ -115,13 +115,13 @@ can take one of the following form: * `http(s)://path_to_scripts_dir` - URL to a directory where the STI scripts are located Additionally we allow specifying the location of both scripts and sources inside the image -prior executing the `assemble` script with `--location` flag or `io.openshift.sti.location` +prior executing the `assemble` script with `--location` flag or `io.s2i.location` label set inside the image. The expected value of this flag is absolute and existing path inside the image, if none is specified the default value of `/tmp` is being used. In case of both of these specified the `--location` flag takes precedence over the environment variable. -**NOTE**: In case where the scripts are already placed inside the image (using `--scripts` -or `io.openshift.sti.scripts-url` with value `image:///path/in/image`) then this value applies only to +**NOTE**: In case where the scripts are already placed inside the image (using `--scripts-url` +or `io.s2i.scripts-url` with value `image:///path/in/image`) then this value applies only to sources and artifacts. #### Example Usage @@ -145,7 +145,7 @@ builder image but overriding the scripts URL from local directory, the resulting image will be named `java-app`: ``` -$ sti build --scripts=file://stiscripts git://github.com/bparees/openshift-jee-sample openshift/wildfly-8-centos java-app +$ sti build --scripts-url=file://stiscripts git://github.com/bparees/openshift-jee-sample openshift/wildfly-8-centos java-app ``` Build a ruby application from a GIT source, specifying `ref`, using the official @@ -161,7 +161,7 @@ Build a ruby application from a GIT source, overriding the scripts URL from a lo and forcing the scripts and sources to be placed in `/opt` directory: ``` -$ sti build --scripts=file://stiscripts --location=/opt git://github.com/mfojtik/sinatra-app-example openshift/ruby-20-centos7 ruby-app +$ sti build --scripts-url=file://stiscripts --location=/opt git://github.com/mfojtik/sinatra-app-example openshift/ruby-20-centos7 ruby-app ``` @@ -176,10 +176,10 @@ the only parameter. | Name | Description | |:-------------------------- |:--------------------------------------------------------| | `-e (--env)` | Environment variables passed to the builder eg. `NAME=VALUE,NAME2=VALUE2,...`) | -| `--force-pull` | Always pull the builder image, even if it is present locally | +| `--force-pull` | Always pull the builder image, even if it is present locally | | `-l (--location)` | Location where the scripts and sources will be placed prior invoking usage (see [STI Scripts](#sti-scripts))| -| `--save-temp-dir` | Save the working directory used for fetching scripts and sources | -| `-s (--scripts)` | URL of STI scripts (see [Scripts URL](#scripts-url))| +| `--save-temp-dir` | Save the working directory used for fetching scripts and sources | +| `-s (--scripts-url)` | URL of STI scripts (see [Scripts URL](#scripts-url))| #### Example Usage diff --git a/pkg/api/scripts.go b/pkg/api/scripts.go index 871a98f50..6b06981a2 100644 --- a/pkg/api/scripts.go +++ b/pkg/api/scripts.go @@ -19,7 +19,7 @@ const ( const ( // UserScripts is the location of scripts downloaded from user provided URL (-s flag). UserScripts = "downloads/scripts" - // DefaultScripts is the location of scripts downloaded from default location (io.openshift.sti.scripts-url label). + // DefaultScripts is the location of scripts downloaded from default location (io.s2i.scripts-url label). DefaultScripts = "downloads/defaultScripts" // SourceScripts is the location of scripts downloaded with application sources. SourceScripts = "upload/src/.sti/bin" diff --git a/pkg/docker/docker.go b/pkg/docker/docker.go index 782d921f0..b1e940fb3 100644 --- a/pkg/docker/docker.go +++ b/pkg/docker/docker.go @@ -18,8 +18,8 @@ const ( ScriptsURLEnvironment = "STI_SCRIPTS_URL" LocationEnvironment = "STI_LOCATION" - ScriptsURLLabel = "io.openshift.sti.scripts-url" - LocationLabel = "io.openshift.sti.location" + ScriptsURLLabel = "io.s2i.scripts-url" + LocationLabel = "io.s2i.location" DefaultLocation = "/tmp" DefaultTag = "latest" @@ -257,8 +257,8 @@ func getScriptsURL(image *docker.Image) string { if len(scriptsURL) == 0 { scriptsURL = getVariable(image, ScriptsURLEnvironment) if len(scriptsURL) != 0 { - glog.Warningf("Image %s uses deprecated environment variable %s, please migrate it to %s label instead!", - image.ID, ScriptsURLEnvironment, ScriptsURLLabel) + glog.Warningf("BuilderImage uses deprecated environment variable %s, please migrate it to %s label instead!", + ScriptsURLEnvironment, ScriptsURLLabel) } } if len(scriptsURL) == 0 { @@ -276,8 +276,8 @@ func getLocation(image *docker.Image) string { return val } if val := getVariable(image, LocationEnvironment); len(val) != 0 { - glog.Warningf("Image %s uses deprecated environment variable %s, please migrate it to %s label instead!", - image.ID, LocationEnvironment, LocationLabel) + glog.Warningf("BuilderImage uses deprecated environment variable %s, please migrate it to %s label instead!", + LocationEnvironment, LocationLabel) return val } diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 930bc1175..185d65350 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -155,7 +155,7 @@ func NewInstallError(script string) error { Message: fmt.Sprintf("failed to install %v", script), Details: nil, ErrorCode: InstallError, - Suggestion: "provide URL with Source-To-Image scripts with -s flag or check the image if it contains io.openshift.sti.scripts-url label set", + Suggestion: "provide URL with Source-To-Image scripts with -s flag or check the image if it contains io.s2i.scripts-url label set", } } @@ -166,7 +166,7 @@ func NewInstallRequiredError(scripts []string) error { Message: fmt.Sprintf("failed to install %v", scripts), Details: nil, ErrorCode: InstallErrorRequired, - Suggestion: "provide URL with Source-To-Image scripts with -s flag or check the image if it contains io.openshift.sti.scripts-url label set", + Suggestion: "provide URL with Source-To-Image scripts with -s flag or check the image if it contains io.s2i.scripts-url label set", } } diff --git a/pkg/scripts/install.go b/pkg/scripts/install.go index 5aca9e99a..dcfb240a8 100644 --- a/pkg/scripts/install.go +++ b/pkg/scripts/install.go @@ -39,7 +39,7 @@ type installer struct { } // locationsOrder defines locations in which scripts are searched for in the following order: -// - script found at the --scripts URL +// - script found at the --scripts-url URL // - script found in the application source .sti/bin directory // - script found at the default image URL var locationsOrder = []string{api.UserScripts, api.SourceScripts, api.DefaultScripts} diff --git a/test/integration/images/sti-fake-scripts-no-save-artifacts/Dockerfile b/test/integration/images/sti-fake-scripts-no-save-artifacts/Dockerfile index aaa5c675e..791497776 100644 --- a/test/integration/images/sti-fake-scripts-no-save-artifacts/Dockerfile +++ b/test/integration/images/sti-fake-scripts-no-save-artifacts/Dockerfile @@ -12,4 +12,4 @@ ADD scripts/.sti/bin/run /tmp/scripts/ ADD scripts/.sti/bin/assemble /tmp/scripts/ # Scripts are already in the image and this is their location -LABEL io.openshift.sti.scripts-url=image:///tmp/scripts/ +LABEL io.s2i.scripts-url=image:///tmp/scripts/ diff --git a/test/integration/images/sti-fake-scripts/Dockerfile b/test/integration/images/sti-fake-scripts/Dockerfile index 4b40237f9..9f2f0df1f 100644 --- a/test/integration/images/sti-fake-scripts/Dockerfile +++ b/test/integration/images/sti-fake-scripts/Dockerfile @@ -11,4 +11,4 @@ WORKDIR / ADD scripts/.sti/bin/ /tmp/scripts/ # Scripts are already in the image and this is their location -LABEL io.openshift.sti.scripts-url=image:///tmp/scripts/ +LABEL io.s2i.scripts-url=image:///tmp/scripts/ diff --git a/test/integration/images/sti-fake/Dockerfile b/test/integration/images/sti-fake/Dockerfile index 71fa3c862..8b9914ba7 100644 --- a/test/integration/images/sti-fake/Dockerfile +++ b/test/integration/images/sti-fake/Dockerfile @@ -12,4 +12,4 @@ WORKDIR / # # Port 23456 must match the port used in the http server in STI's # integration_test.go -LABEL io.openshift.sti.scripts-url=http://127.0.0.1:23456/.sti/bin +LABEL io.s2i.scripts-url=http://127.0.0.1:23456/.sti/bin