Documentation ¶
Index ¶
- Constants
- func AppendToFile(source string, to string) error
- func CreateCliRunner(cmd *cobra.Command, cfg *ServiceConfig) (*atkmod.CliModuleRunner, error)
- func DoContainerizedStep(cmd *cobra.Command, step string, inHandler InputHandlerFunc, ...) error
- func Exec(svc *ServiceClient) error
- func FindClusterByName(in *Project, name string) (*string, error)
- func FlattenCommandName(cmd *cobra.Command, suffix string) string
- func ImageFound(out *bytes.Buffer, name string) bool
- func Keyify(name string) string
- func Lookup(parm JobParam, vars map[string]string) (string, bool)
- 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 StringSliceContains(s []string, e string) bool
- func Unzip(src, dest string) error
- func WriteFile(path string, data []byte) error
- func WriteMessage(msg string, w io.Writer)
- type AuthHandlerFunc
- type BuildParamResolver
- type ClusterInfo
- type CredInfo
- type InputHandlerFunc
- type JobParam
- type MetaInfo
- type OutputHandlerFunc
- type ParamBuilderFunc
- type Project
- type ResolveVarConfig
- type ResponseHandlerFunc
- type ReturnCodeHandlerFunc
- type ServiceClient
- type ServiceClientAuthType
- type ServiceConfig
- type ServiceType
Constants ¶
const ( ContentTypeMultiPart string = "multipart/form-data; boundary=\"========\"" Boundary string = "========" )
Variables ¶
This section is empty.
Functions ¶
func AppendToFile ¶
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 Exec ¶
func Exec(svc *ServiceClient) error
func FlattenCommandName ¶
FlattenCommandName returns a string, such as "command.subcommand.step"
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 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 WriteMessage ¶
WriteMessage writes the given message to the output writer.
Types ¶
type AuthHandlerFunc ¶
func BasicAuthHandler ¶
func BasicAuthHandler(user string, password string) AuthHandlerFunc
BasicAuthHandler
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 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 InputHandlerFunc ¶
InputHandlerFunc is a handler for working with the input of a command.
type OutputHandlerFunc ¶
OutputHandlerFunc is a handler for working with the output of a command.
type ParamBuilderFunc ¶
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 ResolveVarConfig ¶
ResolveVarConfig are the configuration options for the ResolveVars func.
func NewDefaultResolveVarConfig ¶
func NewDefaultResolveVarConfig() *ResolveVarConfig
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" )