Skip to content

Commit 77e3b72

Browse files
author
OpenShift Bot
committed
Merge pull request #207 from soltysh/issue205
Merged by openshift-bot
2 parents e2e4148 + fee5e48 commit 77e3b72

File tree

18 files changed

+126
-102
lines changed

18 files changed

+126
-102
lines changed

cmd/sti/main.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ func newCmdVersion() *cobra.Command {
7474

7575
func newCmdBuild(cfg *api.Config) *cobra.Command {
7676
useConfig := false
77+
oldScriptsFlag := ""
78+
oldDestination := ""
7779

7880
buildCmd := &cobra.Command{
7981
Use: "build <source> <image> [<tag>]",
@@ -143,6 +145,15 @@ func newCmdBuild(cfg *api.Config) *cobra.Command {
143145
cfg.Environment[k] = v
144146
}
145147

148+
if len(oldScriptsFlag) != 0 {
149+
glog.Warning("Flag --scripts is deprecated, use --scripts-url instead")
150+
cfg.ScriptsURL = oldScriptsFlag
151+
}
152+
if len(oldDestination) != 0 {
153+
glog.Warning("Flag --location is deprecated, use --destination instead")
154+
cfg.Destination = oldDestination
155+
}
156+
146157
if glog.V(2) {
147158
fmt.Printf("\n%s\n", describe.DescribeConfig(cfg))
148159
}
@@ -164,8 +175,10 @@ func newCmdBuild(cfg *api.Config) *cobra.Command {
164175
buildCmd.Flags().StringP("env", "e", "", "Specify an environment var NAME=VALUE,NAME2=VALUE2,...")
165176
buildCmd.Flags().StringVarP(&(cfg.Ref), "ref", "r", "", "Specify a ref to check-out")
166177
buildCmd.Flags().StringVar(&(cfg.CallbackURL), "callback-url", "", "Specify a URL to invoke via HTTP POST upon build completion")
167-
buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts", "s", "", "Specify a URL for the assemble and run scripts")
168-
buildCmd.Flags().StringVarP(&(cfg.Location), "location", "l", "", "Specify a destination location for untar operation")
178+
buildCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble and run scripts")
179+
buildCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "Specify a URL for the assemble and run scripts")
180+
buildCmd.Flags().StringVarP(&(oldDestination), "location", "l", "", "Specify a destination location for untar operation")
181+
buildCmd.Flags().StringVarP(&(cfg.Destination), "destination", "d", "", "Specify a destination location for untar operation")
169182
buildCmd.Flags().BoolVar(&(cfg.ForcePull), "force-pull", true, "Always pull the builder image even if it is present locally")
170183
buildCmd.Flags().BoolVar(&(cfg.PreserveWorkingDir), "save-temp-dir", false, "Save the temporary directory used by STI instead of deleting it")
171184
buildCmd.Flags().BoolVar(&(useConfig), "use-config", false, "Store command line options to .stifile")
@@ -195,6 +208,9 @@ func newCmdCreate() *cobra.Command {
195208
}
196209

197210
func newCmdUsage(cfg *api.Config) *cobra.Command {
211+
oldScriptsFlag := ""
212+
oldDestination := ""
213+
198214
usageCmd := &cobra.Command{
199215
Use: "usage <image>",
200216
Short: "Print usage of the assemble script associated with the image",
@@ -210,17 +226,24 @@ func newCmdUsage(cfg *api.Config) *cobra.Command {
210226
checkErr(err)
211227
cfg.Environment = envs
212228

229+
if len(oldScriptsFlag) != 0 {
230+
glog.Warning("Flag --scripts is deprecated, use --scripts-url instead")
231+
cfg.ScriptsURL = oldScriptsFlag
232+
}
233+
213234
uh, err := sti.NewUsage(cfg)
214235
checkErr(err)
215236
err = uh.Show()
216237
checkErr(err)
217238
},
218239
}
219240
usageCmd.Flags().StringP("env", "e", "", "Specify an environment var NAME=VALUE,NAME2=VALUE2,...")
220-
usageCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts", "s", "", "Specify a URL for the assemble and run scripts")
241+
usageCmd.Flags().StringVarP(&(cfg.ScriptsURL), "scripts-url", "s", "", "Specify a URL for the assemble and run scripts")
242+
usageCmd.Flags().StringVar(&(oldScriptsFlag), "scripts", "", "Specify a URL for the assemble and run scripts")
221243
usageCmd.Flags().BoolVar(&(cfg.ForcePull), "force-pull", true, "Always pull the builder image even if it is present locally")
222244
usageCmd.Flags().BoolVar(&(cfg.PreserveWorkingDir), "save-temp-dir", false, "Save the temporary directory used by STI instead of deleting it")
223-
usageCmd.Flags().StringVarP(&(cfg.Location), "location", "l", "", "Specify a destination location for untar operation")
245+
usageCmd.Flags().StringVarP(&(oldDestination), "location", "l", "", "Specify a destination location for untar operation")
246+
usageCmd.Flags().StringVarP(&(cfg.Destination), "destination", "d", "", "Specify a destination location for untar operation")
224247
return usageCmd
225248
}
226249

docs/builder_image.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ final docker image, the three are: sources, scripts and builder image. During th
1515
build process sti must place sources and scripts inside that builder image. To do
1616
so sti creates a tar file containing the two and then streams that file into the
1717
builder image. Before executing `assemble` script, sti untars that file and places
18-
its contents into the location specified with `--location` flag or `io.openshift.sti.location`
19-
label from the builder image (default location is `/tmp`). For this
18+
its contents into the destination specified with `--destination` flag or `io.s2i.destination`
19+
label from the builder image (default destination is `/tmp`). For this
2020
to happen your image must supply tar archiving utility (command `tar` available in `$PATH`)
2121
and command line interpreter (command `/bin/sh`). Doing so will allow your image to
2222
use the fastest possible build path, because in all other cases when either
@@ -55,7 +55,7 @@ and place them into appropriate directories inside the image. The workflow for `
5555

5656
1. Restore build artifacts (in case you want to support incremental builds, make sure
5757
to define [save-artifacts](#save-artifacts)) as well.
58-
1. Place the application source in desired location.
58+
1. Place the application source in desired destination.
5959
1. Build application artifacts.
6060
1. Install the artifacts into locations appropriate for running.
6161

docs/cli.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ that image and add them to the tar streamed to the container into `/artifacts`.
6464
| Name | Description |
6565
|:-------------------------- |:--------------------------------------------------------|
6666
| `--callback-url` | URL to be invoked after successful build (see [Callback URL](#callback-url)) |
67+
| `-d (--destination)` | Location where the scripts and sources will be placed prior doing build (see [STI Scripts](#sti-scripts))|
6768
| `--dockercfg-path` | Specify the path to the Docker configuration file |
6869
| `--incremental` | Try performing an incremental build |
6970
| `-e (--env)` | Environment variables passed to the builder eg. `NAME=VALUE,NAME2=VALUE2,...` |
7071
| `--force-pull` | Always pull the builder image, even if it is present locally |
71-
| `-l (--location)` | Location where the scripts and sources will be placed prior doing build (see [STI Scripts](#sti-scripts))|
7272
| `-r (--ref)` | A branch/tag from which the build should happen (applies only to GIT source) |
7373
| `--rm` | Remove previous image during incremental build |
7474
| `--save-temp-dir` | Save the working directory used for fetching scripts and sources |
7575
| `--context-dir` | Allow to specify directory name with your application |
76-
| `-s (--scripts)` | URL of STI scripts (see [STI Scripts](#sti-scripts)) |
76+
| `-s (--scripts-url)` | URL of STI scripts (see [STI Scripts](#sti-scripts)) |
7777
| `-q (--quiet)` | Operate quietly, suppressing all non-error output |
7878

7979
#### Context directory
@@ -103,25 +103,25 @@ Example data posted will be of the form:
103103
STI supports multiple options providing `assemble`/`run`/`save-artifacts` scripts.
104104
All of these locations are checked on each build in the following order:
105105

106-
1. A script found at the `--scripts` URL
106+
1. A script found at the `--scripts-url` URL
107107
1. A script found in the application source `.sti/bin` directory
108-
1. A script found at the default image URL (`io.openshift.sti.scripts-url` label)
108+
1. A script found at the default image URL (`io.s2i.scripts-url` label)
109109

110-
Both `io.openshift.sti.scripts-url` label specified in the image and `--scripts` flag
110+
Both `io.s2i.scripts-url` label specified in the image and `--scripts-url` flag
111111
can take one of the following form:
112112

113113
* `image://path_to_scripts_dir` - absolute path inside the image to a directory where the STI scripts are located
114114
* `file://path_to_scripts_dir` - relative or absolute path to a directory on the host where the STI scripts are located
115115
* `http(s)://path_to_scripts_dir` - URL to a directory where the STI scripts are located
116116

117117
Additionally we allow specifying the location of both scripts and sources inside the image
118-
prior executing the `assemble` script with `--location` flag or `io.openshift.sti.location`
118+
prior executing the `assemble` script with `--destination` flag or `io.s2i.destination`
119119
label set inside the image. The expected value of this flag is absolute and existing path
120120
inside the image, if none is specified the default value of `/tmp` is being used.
121-
In case of both of these specified the `--location` flag takes precedence over the environment variable.
121+
In case of both of these specified the `--destination` flag takes precedence over the environment variable.
122122

123-
**NOTE**: In case where the scripts are already placed inside the image (using `--scripts`
124-
or `io.openshift.sti.scripts-url` with value `image:///path/in/image`) then this value applies only to
123+
**NOTE**: In case where the scripts are already placed inside the image (using `--scripts-url`
124+
or `io.s2i.scripts-url` with value `image:///path/in/image`) then this value applies only to
125125
sources and artifacts.
126126

127127
#### Example Usage
@@ -145,7 +145,7 @@ builder image but overriding the scripts URL from local directory, the resulting
145145
image will be named `java-app`:
146146

147147
```
148-
$ sti build --scripts=file://stiscripts git://github.com/bparees/openshift-jee-sample openshift/wildfly-8-centos java-app
148+
$ sti build --scripts-url=file://stiscripts git://github.com/bparees/openshift-jee-sample openshift/wildfly-8-centos java-app
149149
```
150150

151151
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
161161
and forcing the scripts and sources to be placed in `/opt` directory:
162162

163163
```
164-
$ sti build --scripts=file://stiscripts --location=/opt git://github.com/mfojtik/sinatra-app-example openshift/ruby-20-centos7 ruby-app
164+
$ sti build --scripts-url=file://stiscripts --destination=/opt git://github.com/mfojtik/sinatra-app-example openshift/ruby-20-centos7 ruby-app
165165
```
166166

167167

@@ -175,11 +175,11 @@ the only parameter.
175175

176176
| Name | Description |
177177
|:-------------------------- |:--------------------------------------------------------|
178+
| `-d (--destination)` | Location where the scripts and sources will be placed prior invoking usage (see [STI Scripts](#sti-scripts))|
178179
| `-e (--env)` | Environment variables passed to the builder eg. `NAME=VALUE,NAME2=VALUE2,...`) |
179-
| `--force-pull` | Always pull the builder image, even if it is present locally |
180-
| `-l (--location)` | Location where the scripts and sources will be placed prior invoking usage (see [STI Scripts](#sti-scripts))|
181-
| `--save-temp-dir` | Save the working directory used for fetching scripts and sources |
182-
| `-s (--scripts)` | URL of STI scripts (see [Scripts URL](#scripts-url))|
180+
| `--force-pull` | Always pull the builder image, even if it is present locally |
181+
| `--save-temp-dir` | Save the working directory used for fetching scripts and sources |
182+
| `-s (--scripts-url)` | URL of STI scripts (see [Scripts URL](#scripts-url))|
183183

184184
#### Example Usage
185185

pkg/api/describe/describer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ func DescribeConfig(config *api.Config) string {
3131
fmt.Fprintf(out, "Remove Old Build:\t%s\n", printBool(config.RemovePreviousImage))
3232
fmt.Fprintf(out, "Force Pull:\t%s\n", printBool(config.ForcePull))
3333
fmt.Fprintf(out, "Quiet:\t%s\n", printBool(config.Quiet))
34-
// fmt.Fprintf(out, "Layered Build:\t%s\n", printBool(config.LayeredBuild))
35-
if len(config.Location) > 0 {
36-
fmt.Fprintf(out, "Artifacts Location:\t%s\n", config.Location)
34+
fmt.Fprintf(out, "Layered Build:\t%s\n", printBool(config.LayeredBuild))
35+
if len(config.Destination) > 0 {
36+
fmt.Fprintf(out, "Artifacts Destination:\t%s\n", config.Destination)
3737
}
3838
if len(config.CallbackURL) > 0 {
3939
fmt.Fprintf(out, "Callback URL:\t%s\n", config.CallbackURL)

pkg/api/scripts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
const (
2020
// UserScripts is the location of scripts downloaded from user provided URL (-s flag).
2121
UserScripts = "downloads/scripts"
22-
// DefaultScripts is the location of scripts downloaded from default location (io.openshift.sti.scripts-url label).
22+
// DefaultScripts is the location of scripts downloaded from default location (io.s2i.scripts-url label).
2323
DefaultScripts = "downloads/defaultScripts"
2424
// SourceScripts is the location of scripts downloaded with application sources.
2525
SourceScripts = "upload/src/.sti/bin"

pkg/api/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ type Config struct {
5050
// ScriptsURL is a URL describing the localization of STI scripts used during build process.
5151
ScriptsURL string
5252

53-
// Location specifies a location where the untar operation will place its artifacts.
54-
Location string
53+
// Destination specifies a location where the untar operation will place its artifacts.
54+
Destination string
5555

5656
// ForcePull describes if the builder should pull the images from registry prior to building.
5757
ForcePull bool

pkg/build/strategies/layered/layered.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/openshift/source-to-image/pkg/util"
1818
)
1919

20-
const defaultLocation = "/tmp"
20+
const defaultDestination = "/tmp"
2121

2222
type Layered struct {
2323
config *api.Config
@@ -41,12 +41,12 @@ func New(config *api.Config, scripts build.ScriptsHandler) (*Layered, error) {
4141
}, nil
4242
}
4343

44-
func getLocation(config *api.Config) string {
45-
location := config.Location
46-
if len(location) == 0 {
47-
location = defaultLocation
44+
func getDestination(config *api.Config) string {
45+
destination := config.Destination
46+
if len(destination) == 0 {
47+
destination = defaultDestination
4848
}
49-
return location
49+
return destination
5050
}
5151

5252
func (b *Layered) CreateDockerfile(config *api.Config) error {
@@ -58,8 +58,8 @@ func (b *Layered) CreateDockerfile(config *api.Config) error {
5858
}
5959

6060
locations := []string{
61-
filepath.Join(getLocation(config), "scripts"),
62-
filepath.Join(getLocation(config), "src"),
61+
filepath.Join(getDestination(config), "scripts"),
62+
filepath.Join(getDestination(config), "src"),
6363
}
6464

6565
buffer.WriteString(fmt.Sprintf("FROM %s\n", b.config.BuilderImage))
@@ -140,7 +140,7 @@ func (b *Layered) Build(config *api.Config) (*api.Result, error) {
140140
// new image name
141141
b.config.BuilderImage = newBuilderImage
142142
// the scripts are inside the image
143-
b.config.ScriptsURL = "image://" + filepath.Join(getLocation(config), "scripts")
143+
b.config.ScriptsURL = "image://" + filepath.Join(getDestination(config), "scripts")
144144

145145
glog.V(2).Infof("Building %s using sti-enabled image", b.config.Tag)
146146
if err := b.scripts.Execute(api.Assemble, b.config); err != nil {

pkg/build/strategies/layered/layered_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func TestBuildOK(t *testing.T) {
4141
if l.config.ScriptsURL != "image:///tmp/scripts" {
4242
t.Error("Expected ScriptsURL image:///tmp/scripts, but got %s", l.config.ScriptsURL)
4343
}
44-
if len(l.config.Location) != 0 {
45-
t.Errorf("Unexpected Location %s", l.config.Location)
44+
if len(l.config.Destination) != 0 {
45+
t.Errorf("Unexpected Destination %s", l.config.Destination)
4646
}
4747
}
4848

pkg/build/strategies/sti/sti.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
const (
2323
// maxErrorOutput is the maximum length of the error output saved for processing
2424
maxErrorOutput = 1024
25-
// defaultLocation is the default location of the scripts and sources in image
26-
defaultLocation = "/tmp"
2725
)
2826

2927
var (
@@ -307,7 +305,7 @@ func (b *STI) Save(config *api.Config) (err error) {
307305
Image: image,
308306
ExternalScripts: b.externalScripts[api.SaveArtifacts],
309307
ScriptsURL: config.ScriptsURL,
310-
Location: config.Location,
308+
Destination: config.Destination,
311309
Command: api.SaveArtifacts,
312310
Stdout: outWriter,
313311
Stderr: errWriter,
@@ -365,7 +363,7 @@ func (b *STI) Execute(command string, config *api.Config) error {
365363
PullImage: config.ForcePull,
366364
ExternalScripts: externalScripts,
367365
ScriptsURL: config.ScriptsURL,
368-
Location: config.Location,
366+
Destination: config.Destination,
369367
Command: command,
370368
Env: buildEnv,
371369
PostExec: b.postExecutor,

pkg/build/strategies/sti/sti_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type FakeSTI struct {
3232
ExpectedError bool
3333
LayeredBuildCalled bool
3434
LayeredBuildError error
35-
PostExecuteLocation string
35+
PostExecuteDestination string
3636
PostExecuteContainerID string
3737
PostExecuteError error
3838
}
@@ -114,9 +114,9 @@ func (f *FakeSTI) wasExpectedError(text string) bool {
114114
return f.ExpectedError
115115
}
116116

117-
func (f *FakeSTI) PostExecute(id, location string) error {
117+
func (f *FakeSTI) PostExecute(id, destination string) error {
118118
f.PostExecuteContainerID = id
119-
f.PostExecuteLocation = location
119+
f.PostExecuteDestination = destination
120120
return f.PostExecuteError
121121
}
122122

@@ -681,8 +681,8 @@ func TestExecuteOK(t *testing.T) {
681681
t.Errorf("PostExecutor not called with expected ID: %s",
682682
pe.PostExecuteContainerID)
683683
}
684-
if !reflect.DeepEqual(pe.PostExecuteLocation, "test-command") {
685-
t.Errorf("PostExecutor not called with expected command: %s", pe.PostExecuteLocation)
684+
if !reflect.DeepEqual(pe.PostExecuteDestination, "test-command") {
685+
t.Errorf("PostExecutor not called with expected command: %s", pe.PostExecuteDestination)
686686
}
687687
}
688688

0 commit comments

Comments
 (0)