pkg

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ContentTypeMultiPart string = "multipart/form-data; boundary=\"========\""
	Boundary             string = "========"
)

Variables

This section is empty.

Functions

func AppendToFile

func AppendToFile(source string, to string) error

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 FindClusterByName

func FindClusterByName(in *Project, name string) (*string, error)

func FlattenCommandName

func FlattenCommandName(cmd *cobra.Command, suffix string) string

FlattenCommandName returns a string, such as "command.subcommand.step"

func ImageFound

func ImageFound(out *bytes.Buffer, name string) bool

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 Keyify

func Keyify(name string) string

Keyify returns a string value that is suitable for use as a YAML configuration key.

func Lookup

func Lookup(parm JobParam, vars map[string]string) (string, bool)

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 ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the given file into the byte array

func ReadHttpGetB

func ReadHttpGetB(url string, user string, password string, handler ReturnCodeHandlerFunc) ([]byte, error)

func ReadHttpGetBWithFunc

func ReadHttpGetBWithFunc(url string, user string, password string, handler ReturnCodeHandlerFunc) ([]byte, error)

func ReadHttpGetT

func ReadHttpGetT(url string, token string) ([]byte, error)

func ReadHttpGetTWithFunc

func ReadHttpGetTWithFunc(url string, token string, handler ReturnCodeHandlerFunc) ([]byte, error)

func ResolveInterpolation

func ResolveInterpolation(cmd *cobra.Command, s string) (string, error)

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 StringSliceContains(s []string, e string) bool

func Unzip

func Unzip(src, dest string) error

Unzip extracts the zip archive to the specified directory

func WriteFile

func WriteFile(path string, data []byte) error

func WriteMessage

func WriteMessage(msg string, w io.Writer)

WriteMessage writes the given message to the output writer.

Types

type AuthHandlerFunc

type AuthHandlerFunc func(req *http.Request) error

func BasicAuthHandler

func BasicAuthHandler(user string, password string) AuthHandlerFunc

BasicAuthHandler

func BearerAuthTandler

func BearerAuthTandler(token string) AuthHandlerFunc

BearerAuthTandler

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 CredInfo

type CredInfo struct {
	Name   string `yaml:"name"`
	Infra  string `yaml:"infra"`
	State  string `yaml:"state"`
	ApiKey string `yaml:"api_key" tfvar:"ibmcloud_api_key"`
}

type InputHandlerFunc

type InputHandlerFunc func(in *bytes.Buffer) error

InputHandlerFunc is a handler for working with the input of a command.

type JobParam

type JobParam struct {
	Name    string `json:"name"`
	Value   string `json:"value,omitempty"`
	Default string `json:"default,omitempty"`
}

type MetaInfo

type MetaInfo struct {
	Name string `yaml:"project_name"`
}

type OutputHandlerFunc

type OutputHandlerFunc func(out *bytes.Buffer) error

OutputHandlerFunc is a handler for working with the output of a command.

type ParamBuilderFunc

type ParamBuilderFunc func() map[string]string

type Project

type Project struct {
	Clusters    map[string]ClusterInfo `yaml:"clusters"`
	Meta        MetaInfo               `yaml:"general"`
	Credentials map[string]CredInfo    `yaml:"credentials"`
}

func LoadProject

func LoadProject(path string) (*Project, error)

LoadProject loads the given project from the yaml file.

func (*Project) Write

func (p *Project) Write(out io.Writer) error

type ResolveVarConfig

type ResolveVarConfig struct {
	Prefix string
	Tag    string
}

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 ReturnCodeHandlerFunc func(code int) error

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"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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