mirror of
https://github.com/openshift/source-to-image.git
synced 2026-02-05 12:44:54 +01:00
Minor code improvements.
- sti -> s2i - fix a couple of typos - remove useless fmt.Sprintf() usage - use api.Assemble constant - UploadToContainer: rename argument - docs/cli.md: correct the number of log levels - docs/debugging-s2i.md: fix a typo
This commit is contained in:
@@ -24,7 +24,7 @@ at common flags that can be used with all of the subcommands.
|
|||||||
|
|
||||||
#### Log levels
|
#### Log levels
|
||||||
|
|
||||||
There are four log levels:
|
There are six log levels:
|
||||||
* Level `0` - produces output from containers running `assemble` script and all encountered errors
|
* Level `0` - produces output from containers running `assemble` script and all encountered errors
|
||||||
* Level `1` - produces basic information about the executed process
|
* Level `1` - produces basic information about the executed process
|
||||||
* Level `2` - produces very detailed information about the executed process
|
* Level `2` - produces very detailed information about the executed process
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ Properly reference the script location with the methods described in the above l
|
|||||||
At various points when executing ONBUILD instructions (these are defined in the Dockerfile of the builder image you are using with s2i), if those instructions result in the need for root user access, but your builder image is not configured to run as root,
|
At various points when executing ONBUILD instructions (these are defined in the Dockerfile of the builder image you are using with s2i), if those instructions result in the need for root user access, but your builder image is not configured to run as root,
|
||||||
then attempts to reference that image in another Dockerfile will result in permission errors.
|
then attempts to reference that image in another Dockerfile will result in permission errors.
|
||||||
|
|
||||||
If you consider the following Dockerfile psuedo-example:
|
If you consider the following Dockerfile pseudo-example:
|
||||||
|
|
||||||
```
|
```
|
||||||
FROM foo
|
FROM foo
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// Provides types used for processing sti builds.
|
// Provides types used for processing s2i builds.
|
||||||
package api
|
package api
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (builder *OnBuild) CreateDockerfile(config *api.Config) error {
|
|||||||
// If there is an assemble script present, run it as part of the build process
|
// If there is an assemble script present, run it as part of the build process
|
||||||
// as the last thing.
|
// as the last thing.
|
||||||
if builder.hasAssembleScript(config) {
|
if builder.hasAssembleScript(config) {
|
||||||
buffer.WriteString(fmt.Sprintf("RUN sh assemble\n"))
|
buffer.WriteString("RUN sh assemble\n")
|
||||||
}
|
}
|
||||||
// FIXME: This assumes that the WORKDIR is set to the application source root
|
// FIXME: This assumes that the WORKDIR is set to the application source root
|
||||||
// directory.
|
// directory.
|
||||||
@@ -184,7 +184,7 @@ func (builder *OnBuild) copySTIScripts(config *api.Config) {
|
|||||||
|
|
||||||
// hasAssembleScript checks if the the assemble script is available
|
// hasAssembleScript checks if the the assemble script is available
|
||||||
func (builder *OnBuild) hasAssembleScript(config *api.Config) bool {
|
func (builder *OnBuild) hasAssembleScript(config *api.Config) bool {
|
||||||
assemblePath := filepath.Join(config.WorkingDir, "upload", "src", "assemble")
|
assemblePath := filepath.Join(config.WorkingDir, "upload", "src", api.Assemble)
|
||||||
_, err := builder.fs.Stat(assemblePath)
|
_, err := builder.fs.Stat(assemblePath)
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// STI strategy executes the STI build.
|
// STI strategy executes the S2I build.
|
||||||
// For more details about STI, visit https://github.com/openshift/source-to-image
|
// For more details about S2I, visit https://github.com/openshift/source-to-image
|
||||||
type STI struct {
|
type STI struct {
|
||||||
config *api.Config
|
config *api.Config
|
||||||
result *api.Result
|
result *api.Result
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
// DefaultConfigPath specifies the default location of the S2I config file
|
// DefaultConfigPath specifies the default location of the S2I config file
|
||||||
const DefaultConfigPath = ".s2ifile"
|
const DefaultConfigPath = ".s2ifile"
|
||||||
|
|
||||||
// Config represents a basic serialization for the STI build options
|
// Config represents a basic serialization for the S2I build options.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Source string `json:"source" yaml:"source"`
|
Source string `json:"source" yaml:"source"`
|
||||||
BuilderImage string `json:"builderImage" yaml:"builderImage"`
|
BuilderImage string `json:"builderImage" yaml:"builderImage"`
|
||||||
@@ -22,7 +22,7 @@ type Config struct {
|
|||||||
Flags map[string]string `json:"flags,omitempty" yaml:"flags,omitempty"`
|
Flags map[string]string `json:"flags,omitempty" yaml:"flags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save persists the STI command line arguments into disk
|
// Save persists the S2I command line arguments into disk.
|
||||||
func Save(config *api.Config, cmd *cobra.Command) {
|
func Save(config *api.Config, cmd *cobra.Command) {
|
||||||
c := Config{
|
c := Config{
|
||||||
BuilderImage: config.BuilderImage,
|
BuilderImage: config.BuilderImage,
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ type Docker interface {
|
|||||||
BuildImage(opts BuildImageOptions) error
|
BuildImage(opts BuildImageOptions) error
|
||||||
GetImageUser(name string) (string, error)
|
GetImageUser(name string) (string, error)
|
||||||
GetLabels(name string) (map[string]string, error)
|
GetLabels(name string) (map[string]string, error)
|
||||||
UploadToContainer(srcPath, destPath, name string) error
|
UploadToContainer(srcPath, destPath, container string) error
|
||||||
Ping() error
|
Ping() error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ func (d *stiDocker) GetImageWorkdir(name string) (string, error) {
|
|||||||
// out the WORKDIR of the image that the container was created from and use that
|
// out the WORKDIR of the image that the container was created from and use that
|
||||||
// as a destination. If the WORKDIR is not set, then we copy files into "/"
|
// as a destination. If the WORKDIR is not set, then we copy files into "/"
|
||||||
// folder (docker upload default).
|
// folder (docker upload default).
|
||||||
func (d *stiDocker) UploadToContainer(src, dest, name string) error {
|
func (d *stiDocker) UploadToContainer(src, dest, container string) error {
|
||||||
path := filepath.Dir(dest)
|
path := filepath.Dir(dest)
|
||||||
f, err := os.Open(src)
|
f, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -288,7 +288,7 @@ func (d *stiDocker) UploadToContainer(src, dest, name string) error {
|
|||||||
}
|
}
|
||||||
glog.V(3).Infof("Uploading %q to %q ...", src, path)
|
glog.V(3).Infof("Uploading %q to %q ...", src, path)
|
||||||
opts := docker.UploadToContainerOptions{Path: path, InputStream: r}
|
opts := docker.UploadToContainerOptions{Path: path, InputStream: r}
|
||||||
return d.client.UploadToContainer(name, opts)
|
return d.client.UploadToContainer(container, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsImageInLocalRegistry determines whether the supplied image is in the local registry.
|
// IsImageInLocalRegistry determines whether the supplied image is in the local registry.
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func (f *FakeDocker) RunContainer(opts RunContainerOptions) error {
|
|||||||
return f.RunContainerError
|
return f.RunContainerError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeDocker) UploadToContainer(srcPath, destPath, name string) error {
|
func (f *FakeDocker) UploadToContainer(srcPath, destPath, container string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type DockerRunner struct {
|
|||||||
ContainerClient docker.Docker
|
ContainerClient docker.Docker
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a DockerRunner for executing the methods assoicated with running
|
// New creates a DockerRunner for executing the methods associated with running
|
||||||
// the produced image in a docker container for verification purposes.
|
// the produced image in a docker container for verification purposes.
|
||||||
func New(config *api.Config) (*DockerRunner, error) {
|
func New(config *api.Config) (*DockerRunner, error) {
|
||||||
client, err := docker.New(config.DockerConfig, config.PullAuthentication)
|
client, err := docker.New(config.DockerConfig, config.PullAuthentication)
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ func ParseURL(source string) (*url.URL, error) {
|
|||||||
return nil, fmt.Errorf("unsupported protocol specfied: %s", uri.Scheme)
|
return nil, fmt.Errorf("unsupported protocol specfied: %s", uri.Scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// have a valid protocol, return sucess
|
// have a valid protocol, return success
|
||||||
return uri, nil
|
return uri, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ func (h *stiGit) Clone(source, target string, c api.CloneConfig) error {
|
|||||||
// git, sending of stdout/stderr to the Pipes created here, and the glog routines sent to pipeToLog
|
// git, sending of stdout/stderr to the Pipes created here, and the glog routines sent to pipeToLog
|
||||||
//
|
//
|
||||||
// It was agreed that we wanted to keep --quiet and no stdout output ....leaving stderr only since
|
// It was agreed that we wanted to keep --quiet and no stdout output ....leaving stderr only since
|
||||||
// --quiet does not surpress that anyway reduced the frequency of the hang, but it still occurred.
|
// --quiet does not suppress that anyway reduced the frequency of the hang, but it still occurred.
|
||||||
// the pipeToLog method has been left for now for historical purposes, but if this implemenetation
|
// the pipeToLog method has been left for now for historical purposes, but if this implemenetation
|
||||||
// of git clone holds, we'll want to delete that at some point.
|
// of git clone holds, we'll want to delete that at some point.
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TimeoutError is error returned after timeout occured.
|
// TimeoutError is error returned after timeout occurred.
|
||||||
type TimeoutError struct {
|
type TimeoutError struct {
|
||||||
after time.Duration
|
after time.Duration
|
||||||
message string
|
message string
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// Package version supplies version information for STI collected at build time.
|
// Package version supplies version information for S2I collected at build time.
|
||||||
package version
|
package version
|
||||||
|
|||||||
Reference in New Issue
Block a user