scripts

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 108

Documentation

Index

Constants

View Source
const (

	// ScriptURLHandler is the name of the script URL handler
	ScriptURLHandler = "script URL handler"

	// ImageURLHandler is the name of the image URL handler
	ImageURLHandler = "image URL handler"

	// SourceHandler is the name of the source script handler
	SourceHandler = "source handler"
)

Variables

View Source
var (
	// RequiredScripts must be present to do an s2i build
	RequiredScripts = []string{constants.Assemble, constants.Run}

	// OptionalScripts may be provided when doing an s2i build
	OptionalScripts = []string{constants.SaveArtifacts}
)

Functions

func ConvertEnvironmentList added in v1.1.0

func ConvertEnvironmentList(env api.EnvironmentList) (result []string)

ConvertEnvironmentList converts the EnvironmentList to "key=val" strings.

func ConvertEnvironmentToDocker

func ConvertEnvironmentToDocker(env api.EnvironmentList) (result string)

ConvertEnvironmentToDocker converts the EnvironmentList into Dockerfile format.

func GetEnvironment

func GetEnvironment(path string) (api.EnvironmentList, error)

GetEnvironment gets the .s2i/environment file located in the sources and parse it into EnvironmentList.

Types

type DefaultScriptSourceManager added in v1.0.5

type DefaultScriptSourceManager struct {
	Image      string
	ScriptsURL string
	// contains filtered or unexported fields
}

DefaultScriptSourceManager manages the default script lookup and installation for source-to-image.

func (*DefaultScriptSourceManager) Add added in v1.0.5

Add registers a new script source handler.

func (*DefaultScriptSourceManager) InstallOptional added in v1.0.5

func (m *DefaultScriptSourceManager) InstallOptional(scripts []string, dstDir string) []api.InstallResult

InstallOptional downloads and installs a set of scripts into dstDir, the result is a map of scripts with detailed information about each of the scripts install process

func (*DefaultScriptSourceManager) InstallRequired added in v1.0.5

func (m *DefaultScriptSourceManager) InstallRequired(scripts []string, dstDir string) ([]api.InstallResult, error)

InstallRequired Downloads and installs required scripts into dstDir, the result is a map of scripts with detailed information about each of the scripts install process with error if installing some of them failed

type Downloader

type Downloader interface {
	Download(url *url.URL, target string) (*git.SourceInfo, error)
}

Downloader downloads the specified URL to the target file location

func NewDownloader

func NewDownloader(proxyConfig *api.ProxyConfig) Downloader

NewDownloader creates an instance of the default Downloader implementation

type FileURLReader

type FileURLReader struct{}

FileURLReader opens a specified file and returns its stream

func (*FileURLReader) Read

func (*FileURLReader) Read(url *url.URL) (io.ReadCloser, error)

Read produces an io.Reader from a file URL

type HTTPURLReader added in v1.1.0

type HTTPURLReader struct {
	Get func(url string) (*http.Response, error)
}

HTTPURLReader retrieves a response from a given HTTP(S) URL.

func NewHTTPURLReader added in v1.1.0

func NewHTTPURLReader(proxyConfig *api.ProxyConfig) *HTTPURLReader

NewHTTPURLReader returns a new HTTPURLReader.

func (*HTTPURLReader) Read added in v1.1.0

func (h *HTTPURLReader) Read(url *url.URL) (io.ReadCloser, error)

Read produces an io.Reader from an http(s) URL.

type ImageReader

type ImageReader struct{}

ImageReader just returns information the URL is from inside the image

func (*ImageReader) Read

func (*ImageReader) Read(url *url.URL) (io.ReadCloser, error)

Read throws Not implemented error

type Installer

type Installer interface {
	InstallRequired(scripts []string, dstDir string) ([]api.InstallResult, error)
	InstallOptional(scripts []string, dstDir string) []api.InstallResult
}

Installer interface is responsible for installing scripts needed to run the build.

func NewInstaller

func NewInstaller(image string, scriptsURL string, proxyConfig *api.ProxyConfig, docker docker.Docker, auth api.AuthConfig, fs fs.FileSystem, config *api.Config) Installer

NewInstaller returns a new instance of the default Installer implementation

type ScriptHandler added in v1.0.5

type ScriptHandler interface {
	Get(script string) *api.InstallResult
	Install(*api.InstallResult) error
	SetDestinationDir(string)
	String() string
}

ScriptHandler provides an interface for various scripts source handlers.

type ScriptSourceManager added in v1.0.5

type ScriptSourceManager interface {
	Add(ScriptHandler)
	SetDownloader(Downloader)
	Installer
}

ScriptSourceManager manages various script handlers.

type SourceScriptHandler added in v1.0.5

type SourceScriptHandler struct {
	DestinationDir string
	// contains filtered or unexported fields
}

SourceScriptHandler handles the case when the scripts are contained in the source code directory.

func (*SourceScriptHandler) Get added in v1.0.5

func (s *SourceScriptHandler) Get(script string) *api.InstallResult

Get verifies if the script is present in the source directory and get the installation result.

func (*SourceScriptHandler) Install added in v1.0.5

func (s *SourceScriptHandler) Install(r *api.InstallResult) error

Install copies the script into upload directory and fix its permissions.

func (*SourceScriptHandler) SetDestinationDir added in v1.0.5

func (s *SourceScriptHandler) SetDestinationDir(baseDir string)

SetDestinationDir sets the directory where the scripts should be uploaded. In case of SourceScriptHandler this is a source directory root.

func (*SourceScriptHandler) String added in v1.0.5

func (s *SourceScriptHandler) String() string

String implements the String() function.

type URLScriptHandler added in v1.0.6

type URLScriptHandler struct {
	URL            string
	DestinationDir string
	Download       Downloader
	FS             fs.FileSystem
	Name           string
}

URLScriptHandler handles script download using URL.

func (*URLScriptHandler) Get added in v1.0.6

func (s *URLScriptHandler) Get(script string) *api.InstallResult

Get parses the provided URL and the script name.

func (*URLScriptHandler) Install added in v1.0.6

func (s *URLScriptHandler) Install(r *api.InstallResult) error

Install downloads the script and fix its permissions.

func (*URLScriptHandler) SetDestinationDir added in v1.0.6

func (s *URLScriptHandler) SetDestinationDir(baseDir string)

SetDestinationDir sets the destination where the scripts should be downloaded.

func (*URLScriptHandler) String added in v1.0.6

func (s *URLScriptHandler) String() string

String implements the String() function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL