Documentation ¶
Index ¶
- Constants
- func AppendToFile(source string, to string) error
- func AppendToFilename(fn string, suffix string) (string, error)
- func BuildDestination(base string, gitURL string) (string, error)
- func BuildPipelinePrompt(name string, reader ParamReader, resolver ParamResolver) (*prompt.Prompt, error)
- func ConfigOptions(config *mapstructure.DecoderConfig)
- func CreateCliRunner(cmd *cobra.Command, cfg *ServiceConfig) (*atkmod.CliModuleRunner, error)
- func DoContainerizedStep(cmd *cobra.Command, step string, inHandler InputHandlerFunc, ...) error
- func ExecPipelineRun(pipeline *v1beta1.Pipeline, run *v1beta1.PipelineRun, runScript string, ...) error
- func FindClusterByName(in *Project, name string) (*string, error)
- func FindParam(in v1beta1.Params, name string) (*v1beta1.Param, bool)
- func FlattenCommandName(cmd *cobra.Command, suffix string) string
- func GetITZHomeDir() (string, error)
- func HomeTempFile(base string, name string) string
- func ImageFound(out *bytes.Buffer, name string) bool
- func IsPipeline(p v1beta1.Pipeline) bool
- func IsPipelineRun(p v1beta1.PipelineRun) bool
- func Keyify(name string) string
- func Lookup(parm JobParam, vars map[string]string) (string, bool)
- func MapGitUrlToRaw(id string) (string, error)
- func MergePipelineRun(run *v1beta1.PipelineRun, pl *v1beta1.Pipeline, reader ParamReader, ...) (*v1beta1.PipelineRun, error)
- func MustITZHomeDir() string
- func NewRunContext(svc *ServiceConfig, cmd *cobra.Command) *atkmod.RunContext
- func ReadFile(path string) ([]byte, error)
- func ReadHttpGetB(url string, user string, password string, handler ReturnCodeHandlerFunc) ([]byte, error)
- func ReadHttpGetBWithFunc(url string, user string, password string, handler ReturnCodeHandlerFunc) ([]byte, error)
- func ReadHttpGetT(url string, token string) ([]byte, error)
- func ReadHttpGetTWithFunc(url string, token string, handler ReturnCodeHandlerFunc) ([]byte, error)
- func ResolveInterpolation(cmd *cobra.Command, s string) (string, error)
- func ResolveVars(ref interface{}, cfg *ResolveVarConfig) (map[string]string, error)
- func Sluggify(s string) string
- func StringSliceContains(s []string, e string) bool
- func ToEnvVar(prefix, k string) string
- func UnmarshalPipeline(yamlFile []byte) (interface{}, error)
- func UnmarshalPipelineRun(content []byte) (interface{}, error)
- func Unzip(src, dest string) error
- func WriteFile(path string, data []byte) error
- func WriteMessage(msg string, w io.Writer)
- func WriteToFile(fn string, create bool, obj runtime.Object) error
- type ArgsParamParser
- type AuthHandlerFunc
- type BuildParamResolver
- type ChainedResolver
- type ClusterInfo
- type CredInfo
- type EnvParamResolver
- type GitServiceClient
- type InputHandlerFunc
- type JobParam
- type MarshallerFunc
- type MetaInfo
- type OutputHandlerFunc
- type ParamBuilderFunc
- type ParamReader
- type ParamResolver
- type PipelineParamOption
- type PipelineParamOptions
- type PipelineParamParts
- type PipelineResolver
- type Project
- type PromptResolver
- type ResolveVarConfig
- type ResolverOption
- type ResponseHandlerFunc
- type ReturnCodeHandlerFunc
- type ServiceClient
- type ServiceClientAuthType
- type ServiceConfig
- type ServiceType
Constants ¶
const ( ContentTypeMultiPart string = "multipart/form-data; boundary=\"========\"" Boundary string = "========" )
const DefaultParseOptions = UseEnvironmentVars
const DefaultPrefix = "ITZ_"
const RawGitHubUrlHost = "raw.githubusercontent.com"
Variables ¶
This section is empty.
Functions ¶
func AppendToFile ¶
func AppendToFilename ¶ added in v0.1.26
AppendToFilename appends the suffix to the name of the file. The file is expected to be a URL
func BuildDestination ¶ added in v0.1.26
BuildDestination builds the destination path using the git path to the pipeline.
func BuildPipelinePrompt ¶ added in v0.1.26
func BuildPipelinePrompt(name string, reader ParamReader, resolver ParamResolver) (*prompt.Prompt, error)
func ConfigOptions ¶ added in v0.1.26
func ConfigOptions(config *mapstructure.DecoderConfig)
func CreateCliRunner ¶
func CreateCliRunner(cmd *cobra.Command, cfg *ServiceConfig) (*atkmod.CliModuleRunner, error)
CreateCliRunner creates an instance of a atkmod.CliModuleRunner for the given cobra.Command and ServiceConfig. The cobra.Command is used for variable substitution in the ServiceConfig. For example, you can use {{solution}} in the environment variables and it will substitute the value used for `--solution` on the command line.
func DoContainerizedStep ¶
func DoContainerizedStep(cmd *cobra.Command, step string, inHandler InputHandlerFunc, outHandler OutputHandlerFunc) error
DoContainerizedStep is a function that acts as a Facade and does several operations. First, it loads the configuration for the cmd and the step from the CLI configuration file. It configures the CLI further using the ServiceConfig structure loaded from the CLI configuration file, then it sets up handler functions for handling STDIN and STDOUT in the container, then calls the Run method on the CliModuleRunner to run the container.
func ExecPipelineRun ¶ added in v0.1.26
func ExecPipelineRun(pipeline *v1beta1.Pipeline, run *v1beta1.PipelineRun, runScript string, useContainer bool, cluster ClusterInfo, cred CredInfo, in io.Reader, out io.Writer) error
ExecPipelineRun
func FlattenCommandName ¶
FlattenCommandName returns a string, such as "command.subcommand.step"
func GetITZHomeDir ¶ added in v0.1.26
GetITZHomeDir returns the home directory or the ITZ command
func HomeTempFile ¶ added in v0.1.26
HomeTempFile returns the path name of a file based on the metadata
func ImageFound ¶
ImageFound returns true if the name of the image was found in the output. TODO: create a different function for finding the exact image, or add a flag here...
func IsPipeline ¶ added in v0.1.26
func IsPipelineRun ¶ added in v0.1.26
func IsPipelineRun(p v1beta1.PipelineRun) bool
func MapGitUrlToRaw ¶ added in v0.1.26
MapGitUrlToRaw updates the URL that you see in the browser to one that contains the raw git URL. For example, https://github.com/cloud-native-toolkit/deployer-cloud-pak-deployer/blob/main/openshift-4.10/cp4d-4.6.4/cloud-pak-deployer.yaml is really https://raw.githubusercontent.com/cloud-native-toolkit/deployer-cloud-pak-deployer/main/openshift-4.10/cp4d-4.6.4/cloud-pak-deployer.yaml
func MergePipelineRun ¶ added in v0.1.26
func MergePipelineRun(run *v1beta1.PipelineRun, pl *v1beta1.Pipeline, reader ParamReader, resolver ParamResolver) (*v1beta1.PipelineRun, error)
func MustITZHomeDir ¶ added in v0.1.26
func MustITZHomeDir() string
func NewRunContext ¶
func NewRunContext(svc *ServiceConfig, cmd *cobra.Command) *atkmod.RunContext
NewRunContext propertly creates the atkmod.RunContext for the given ServiceConfig and cobra.Command
func ReadHttpGetB ¶
func ReadHttpGetBWithFunc ¶
func ReadHttpGetTWithFunc ¶
func ReadHttpGetTWithFunc(url string, token string, handler ReturnCodeHandlerFunc) ([]byte, error)
func ResolveInterpolation ¶
ResolveInterpolation resolves the tokens in the string using the arguments configured in the cmd.
func ResolveVars ¶
func ResolveVars(ref interface{}, cfg *ResolveVarConfig) (map[string]string, error)
ResolveVars looks through the given structure and returns a map of the values If cfg is nil, a default set of configuration options (see NewDefaultResolveVarConfig) are used.
func StringSliceContains ¶
func UnmarshalPipeline ¶ added in v0.1.26
func UnmarshalPipelineRun ¶ added in v0.1.26
func WriteMessage ¶
WriteMessage writes the given message to the output writer.
Types ¶
type ArgsParamParser ¶ added in v0.1.26
type ArgsParamParser struct {
// contains filtered or unexported fields
}
func (*ArgsParamParser) EnabledFor ¶ added in v0.1.26
func (p *ArgsParamParser) EnabledFor(opt ResolverOption) bool
func (*ArgsParamParser) Lookup ¶ added in v0.1.26
func (p *ArgsParamParser) Lookup(k string) (string, bool)
func (*ArgsParamParser) Supports ¶ added in v0.1.26
func (p *ArgsParamParser) Supports() ResolverOption
type AuthHandlerFunc ¶
type BuildParamResolver ¶
type BuildParamResolver struct {
// contains filtered or unexported fields
}
BuildParamResolver is used to resolve missing parameters
func NewBuildParamResolver ¶
func NewBuildParamResolver(project *Project, cluster string, params []JobParam) (*BuildParamResolver, error)
func (*BuildParamResolver) BuildPrompter ¶
func (r *BuildParamResolver) BuildPrompter(solution string) (*prompt.Prompt, error)
func (*BuildParamResolver) ResolvedParams ¶
func (r *BuildParamResolver) ResolvedParams() map[string]string
type ChainedResolver ¶ added in v0.1.26
type ChainedResolver struct {
// contains filtered or unexported fields
}
ChainedResolver is a Resolver itself that resolves the variables from different locations, such as a Pipeline defaults, the command line, or environment variables.
func NewChainedResolver ¶ added in v0.1.26
func NewChainedResolver(opt ResolverOption, enabled ...ParamResolver) *ChainedResolver
func (*ChainedResolver) EnabledFor ¶ added in v0.1.26
func (p *ChainedResolver) EnabledFor(opt ResolverOption) bool
EnabledFor returns true if the `ParamResolver` is enabled for the given option.
func (*ChainedResolver) Lookup ¶ added in v0.1.26
func (p *ChainedResolver) Lookup(k string) (string, bool)
func (*ChainedResolver) Supports ¶ added in v0.1.26
func (p *ChainedResolver) Supports() ResolverOption
type ClusterInfo ¶
type ClusterInfo struct { State string `yaml:"state"` URL string `yaml:"api_url" tfvar:"server_url"` Name string `yaml:"name"` CName string `yaml:"cluster_name"` CredId string `yaml:"credentialId"` Id string `yaml:"cluster_id"` PubSvcEndpointURL string `yaml:"public_service_endpoint_url"` Infra string `yaml:"infra_host"` Region string `yaml:"region" tfvar:"region"` }
type EnvParamResolver ¶ added in v0.1.26
type EnvParamResolver struct {
Prefix string
}
func (*EnvParamResolver) EnabledFor ¶ added in v0.1.26
func (p *EnvParamResolver) EnabledFor(opt ResolverOption) bool
func (*EnvParamResolver) Lookup ¶ added in v0.1.26
func (p *EnvParamResolver) Lookup(k string) (string, bool)
func (*EnvParamResolver) Supports ¶ added in v0.1.26
func (p *EnvParamResolver) Supports() ResolverOption
type GitServiceClient ¶ added in v0.1.26
type GitServiceClient struct {
BaseDest string
}
GitServiceClient can download (get) the objects from a Git repository location
func (*GitServiceClient) Get ¶ added in v0.1.26
func (g *GitServiceClient) Get(gitURL string, marshaller MarshallerFunc) (interface{}, error)
Get the Pipeline from the Git repository
type InputHandlerFunc ¶
InputHandlerFunc is a handler for working with the input of a command.
type MarshallerFunc ¶ added in v0.1.26
type OutputHandlerFunc ¶
OutputHandlerFunc is a handler for working with the output of a command.
type ParamBuilderFunc ¶
type ParamReader ¶ added in v0.1.26
type ParamReader interface { // Params gets all `ParamSpec` objects Params() ([]v1beta1.ParamSpec, error) }
ParamReader reads the `ParamSpec` objects from a source.
type ParamResolver ¶ added in v0.1.26
type ParamResolver interface { Supports() ResolverOption // EnabledFor returns true if the `ParamResolver` is enabled for the given // option. EnabledFor(opt ResolverOption) bool // Lookup returns the value of the parameter, if found, as well as // a bool that indicates if it was found. Lookup(p string) (string, bool) }
ParamResolver resolves the parameter values from a source.
func NewArgsParamParser ¶ added in v0.1.26
func NewArgsParamParser(args []string) ParamResolver
func NewEnvParamResolver ¶ added in v0.1.26
func NewEnvParamResolver() ParamResolver
func NewPromptResolver ¶ added in v0.1.26
func NewPromptResolver(p *prompt.Prompt) ParamResolver
type PipelineParamOption ¶ added in v0.1.26
func (*PipelineParamOption) IsDefault ¶ added in v0.1.26
func (o *PipelineParamOption) IsDefault() bool
type PipelineParamOptions ¶ added in v0.1.26
type PipelineParamOptions struct {
Options []PipelineParamOption
}
type PipelineParamParts ¶ added in v0.1.26
type PipelineParamParts struct { Description string ParamOptions PipelineParamOptions }
func ParseParamDescription ¶ added in v0.1.26
func ParseParamDescription(from string) (*PipelineParamParts, error)
func (*PipelineParamParts) HasOptions ¶ added in v0.1.26
func (p *PipelineParamParts) HasOptions() bool
type PipelineResolver ¶ added in v0.1.26
type PipelineResolver struct {
// contains filtered or unexported fields
}
func NewPipelineResolver ¶ added in v0.1.26
func NewPipelineResolver(p *v1beta1.Pipeline) *PipelineResolver
NewPipelineResolver creates a new pipeline resolver that will resolve the parameters so long as they have default values. This is useful when accepting the defaults and not prompting the user unnecessarily.
func (*PipelineResolver) EnabledFor ¶ added in v0.1.26
func (p *PipelineResolver) EnabledFor(opt ResolverOption) bool
EnabledFor returns true if the `ParamResolver` is enabled for the given option.
func (*PipelineResolver) Lookup ¶ added in v0.1.26
func (p *PipelineResolver) Lookup(k string) (string, bool)
Lookup returns the value of the parameter, if found, as well as a bool that indicates if it was found. In the case of the `PipelineResolver`, this returns true if the `Pipeline` parameter has a default value.
func (*PipelineResolver) Params ¶ added in v0.1.26
func (p *PipelineResolver) Params() ([]v1beta1.ParamSpec, error)
func (*PipelineResolver) Supports ¶ added in v0.1.26
func (p *PipelineResolver) Supports() ResolverOption
type Project ¶
type Project struct { Clusters map[string]ClusterInfo `yaml:"clusters"` Meta MetaInfo `yaml:"general"` Credentials map[string]CredInfo `yaml:"credentials"` }
func LoadProject ¶
LoadProject loads the given project from the yaml file.
type PromptResolver ¶ added in v0.1.26
type PromptResolver struct {
// contains filtered or unexported fields
}
func (*PromptResolver) EnabledFor ¶ added in v0.1.26
func (p *PromptResolver) EnabledFor(opt ResolverOption) bool
func (*PromptResolver) Lookup ¶ added in v0.1.26
func (p *PromptResolver) Lookup(k string) (string, bool)
func (*PromptResolver) Supports ¶ added in v0.1.26
func (p *PromptResolver) Supports() ResolverOption
type ResolveVarConfig ¶
ResolveVarConfig are the configuration options for the ResolveVars func.
func NewDefaultResolveVarConfig ¶
func NewDefaultResolveVarConfig() *ResolveVarConfig
type ResolverOption ¶ added in v0.1.26
type ResolverOption uint32
const ( UsePipelineDefaults ResolverOption = 1 << iota UseEnvironmentVars UseCommandLineArgs UsePromptAnswers )
func (ResolverOption) Includes ¶ added in v0.1.26
func (o ResolverOption) Includes(opt ResolverOption) bool
type ResponseHandlerFunc ¶
type ResponseHandlerFunc func(reader io.ReadCloser) error
type ReturnCodeHandlerFunc ¶
type ServiceClient ¶
type ServiceClient struct { Method string BaseURL string QParams ParamBuilderFunc FParams ParamBuilderFunc ResponseHandler ResponseHandlerFunc AuthHandler AuthHandlerFunc Body io.Reader ExpectedStatusCode int ContentType string }
ServiceClient is a client operation that provides more structure-driven interaction with the backend APIs so there don't have to be so many variations of HTTP methods.
type ServiceClientAuthType ¶
type ServiceClientAuthType string
const ( Bearer ServiceClientAuthType = "Bearer" Basic ServiceClientAuthType = "Basic" )
type ServiceConfig ¶
type ServiceConfig struct { Env []string `yaml:"env,omitempty"` Image string `yaml:"image"` Local bool `yaml:"local"` MountOpts string `yaml:"mountopts,omitempty"` Name string `yaml:"name,omitempty"` Type ServiceType `yaml:"type,omitempty"` URL *url.URL `yaml:"url,omitempty"` Volumes []string `yaml:"volumes,omitempty"` }
ServiceConfig represents a configuration record for a service in the CLI's configuration file. The reason this struct is repeated compared to just using the atkmod.CliParts struct is because the layer of abstraction allows us to tweak the YAML structure.
func LoadServiceConfig ¶
func LoadServiceConfig(cmd *cobra.Command, path string) (*ServiceConfig, error)
LoadServiceConfig loads the service configuration for the given command and path.
type ServiceType ¶
type ServiceType string
const ( Background ServiceType = "background" Interactive ServiceType = "interactive" InOut ServiceType = "inout" )