1
0
mirror of https://github.com/openshift/source-to-image.git synced 2026-02-05 12:44:54 +01:00

.sti/environment -> .s2i/environment

This commit is contained in:
Maciej Szulik
2016-02-03 09:25:25 +01:00
parent 74bc307980
commit 05eee4936c
2 changed files with 20 additions and 7 deletions

View File

@@ -78,7 +78,7 @@ README.md, if filtered by any prior rules, but then put back in by `!README.md`,
Users can also set extra environment variables in the application source code.
They are passed to the build, and the `assemble` script consumes them. All
environment variables are also present in the output application image. These
variables are defined in the `.sti/environment` file inside the application sources.
variables are defined in the `.s2i/environment` file inside the application sources.
The format of this file is a simple key-value, for example:
```
@@ -98,7 +98,7 @@ The `s2i build` workflow is:
1. `s2i` creates a container based on the build image and passes it a tar file that contains:
1. The application source in `src`, excluding any files selected by `.s2iignore`
1. The build artifacts in `artifacts` (if applicable - see [incremental builds](#incremental-builds))
1. `s2i` sets the environment variables from `.sti/environment` (optional)
1. `s2i` sets the environment variables from `.s2i/environment` (optional)
1. `s2i` starts the container and runs its `assemble` script
1. `s2i` waits for the container to finish
1. `s2i` commits the container, setting the CMD for the output image to be the `run` script and tagging the image with the name provided.

View File

@@ -18,17 +18,30 @@ type Environment struct {
Value string
}
// GetEnvironment gets the .sti/environment file located in the sources and
// getEnvPath returns prefix/environment path.
func getEnvPath(config *api.Config, prefix string) (string, error) {
envPath := filepath.Join(config.WorkingDir, api.Source, prefix, api.Environment)
if _, err := os.Stat(envPath); os.IsNotExist(err) {
return "", errors.New("no environment file found in application sources")
}
return envPath, nil
}
// GetEnvironment gets the .s2i/environment file located in the sources and
// parse it into []environment
func GetEnvironment(config *api.Config) ([]Environment, error) {
envPath := filepath.Join(config.WorkingDir, api.Source, ".sti", api.Environment)
if _, err := os.Stat(envPath); os.IsNotExist(err) {
return nil, errors.New("no environment file found in application sources")
envPath, err := getEnvPath(config, ".s2i")
if err != nil {
envPath, err = getEnvPath(config, ".sti")
if err != nil {
return nil, err
}
glog.Infof("DEPRECATED: Use .s2i/environment instead of .sti/environment")
}
f, err := os.Open(envPath)
if err != nil {
return nil, errors.New("unable to read .sti/environment file")
return nil, errors.New("unable to read environment file")
}
defer f.Close()