cmd

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildDate string

BuildDate is the date this binary was built

View Source
var DockerComposeFile string

DockerComposeFile represents the docker-compose.yml file

View Source
var HarborComposeFile string

HarborComposeFile represents the harbor-compose.yml file

View Source
var RootCmd = &cobra.Command{
	Use:    "harbor-compose",
	Short:  "Define and run multi-container Docker apps on Harbor",
	Long:   ``,
	PreRun: preRunHook,
}

RootCmd represents the base command when called without any subcommands

View Source
var Verbose bool

Verbose determines whether or not verbose output is enabled

View Source
var Version string

Version is the version of this app

Functions

func CatalogCustoms added in v0.10.0

func CatalogCustoms(shipment string, env string, buildToken string, catalogRequest CatalogitContainer, provider string)

CatalogCustoms catalogs a container using the customs catalog api

func Catalogit added in v0.10.0

func Catalogit(container CatalogitContainer) (string, []error)

Catalogit sends a POST to the catalogit api

func DeleteShipmentEnvironment added in v0.5.0

func DeleteShipmentEnvironment(username string, token string, shipment string, env string)

DeleteShipmentEnvironment deletes a shipment/environment from harbor

func Deploy added in v0.10.0

func Deploy(shipment string, env string, buildToken string, deployRequest DeployRequest, provider string)

Deploy deploys (and catalogs) a shipment container to an environment

func DeserializeDockerCompose

func DeserializeDockerCompose(file string) project.APIProject

DeserializeDockerCompose deserializes a docker-compose.yml file into an object

func Execute

func Execute(version string, buildDate string)

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetLogStreamer added in v0.8.0

func GetLogStreamer(streamer string) (reader *bufio.Reader, err error)

GetLogStreamer return reader object to parse docker container logs

func GetLogs

func GetLogs(barge string, shipment string, env string) string

GetLogs returns a string of all container logs for a shipment

func GetRandomName added in v0.15.0

func GetRandomName(retry int) string

GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective-surname". For example 'focused-turing'. If retry is non-zero, a random integer between 0 and 10 will be added to the end of the name, e.g `focused_turing3`

func IsContainerVersionCataloged added in v0.10.0

func IsContainerVersionCataloged(name string, version string) bool

IsContainerVersionCataloged determines whether or not a container/version exists in the catalog

func Login added in v0.6.0

func Login() (string, string, error)

Login -

func SaveEnvVar

func SaveEnvVar(username string, token string, shipment string, environment string, envVarPayload EnvVarPayload, container string)

SaveEnvVar updates an environment variable in harbor (supports both environment and container levels)

func SaveNewShipmentEnvironment added in v0.5.0

func SaveNewShipmentEnvironment(username string, token string, shipment ShipmentEnvironment) bool

SaveNewShipmentEnvironment bulk saves a new shipment/environment

func SerializeDockerCompose added in v0.4.0

func SerializeDockerCompose(dockerCompose DockerCompose, file string)

SerializeDockerCompose serializes an object to a docker-compose.yml file

func SerializeHarborCompose added in v0.4.0

func SerializeHarborCompose(harborCompose HarborCompose, file string)

SerializeHarborCompose serializes an object to a harbor-compose.yml file

func Trigger

func Trigger(shipment string, env string) (bool, []string)

Trigger calls the trigger api

func UpdateContainerImage

func UpdateContainerImage(username string, token string, shipment string, env string, container ContainerPayload)

UpdateContainerImage updates a container version on a shipment

func UpdateProvider added in v0.14.0

func UpdateProvider(username string, token string, shipment string, env string, provider ProviderPayload)

UpdateProvider updates provider configuration

func UpdateShipmentEnvironment added in v0.14.0

func UpdateShipmentEnvironment(username string, token string, shipment string, composeShipment ComposeShipment)

UpdateShipmentEnvironment updates shipment/environment-level configuration

Types

type Auth added in v0.6.0

type Auth struct {
	Version  string `json:"version"`
	Username string `json:"username"`
	Token    string `json:"token"`
}

Auth represents a user authentication token

type AuthRequest

type AuthRequest struct {
	User string `json:"username,omitempty"`
	Pass string `json:"password,omitempty"`
}

AuthRequest represents an authentication request

type AuthResponse

type AuthResponse struct {
	Success bool
	Token   string
}

AuthResponse represents an authentication response

type Barge added in v0.18.0

type Barge struct {
	Name           string   `json:"name"`
	AccountID      string   `json:"accountId"`
	AccountName    string   `json:"accountName"`
	Vpc            string   `json:"vpc"`
	PrivateSubnets []string `json:"privateSubnets"`
	PublicSubnets  []string `json:"publicSubnets"`
}

Barge represents a harbor barge

type BargeResults added in v0.18.0

type BargeResults struct {
	Barges []Barge `json:"barges"`
}

BargeResults represents a barge payload

func GetBarges added in v0.18.0

func GetBarges() *BargeResults

GetBarges returns a list of harbor barges

type BuildArtifact added in v0.11.0

type BuildArtifact struct {
	FilePath     string
	FileContents string
	FileMode     os.FileMode
}

BuildArtifact represents a build artifact

type BuildProvider added in v0.11.0

type BuildProvider interface {

	//build providers can manipulate the docker compose configuration and output build artifacts
	//supports multiple target platforms
	ProvideArtifacts(dockerCompose *DockerCompose, harborCompose *HarborCompose, token string, platform string) ([]*BuildArtifact, error)
}

BuildProvider represents a build provider

type BuildTokenOutput added in v0.12.0

type BuildTokenOutput struct {
	Shipment    string
	Environment string
	CiCdEnvVar  string
	Token       string
}

BuildTokenOutput represents an object that can be written to stdout and formatted

type CatalogitContainer added in v0.10.0

type CatalogitContainer struct {
	Name    string `json:"name"`
	Image   string `json:"image"`
	Version string `json:"version"`
}

CatalogitContainer is what gets sent to catalog to post a new image

type CircleCIv1 added in v0.11.0

type CircleCIv1 struct{}

CircleCIv1 represents a Circle CI build provider

func (CircleCIv1) ProvideArtifacts added in v0.11.0

func (provider CircleCIv1) ProvideArtifacts(dockerCompose *DockerCompose, harborCompose *HarborCompose, token string, platform string) ([]*BuildArtifact, error)

ProvideArtifacts -

type CircleCIv2 added in v0.12.0

type CircleCIv2 struct{}

CircleCIv2 represents a Circle CI build provider (v2)

func (CircleCIv2) ProvideArtifacts added in v0.12.0

func (provider CircleCIv2) ProvideArtifacts(dockerCompose *DockerCompose, harborCompose *HarborCompose, token string, platform string) ([]*BuildArtifact, error)

ProvideArtifacts -

type Codeship added in v0.13.0

type Codeship struct{}

Codeship represents a Codeship build provider

func (Codeship) ProvideArtifacts added in v0.13.0

func (provider Codeship) ProvideArtifacts(dockerCompose *DockerCompose, harborCompose *HarborCompose, token string, platform string) ([]*BuildArtifact, error)

ProvideArtifacts -

type ComposeShipment

type ComposeShipment struct {
	Env                        string            `yaml:"env"`
	Barge                      string            `yaml:"barge,omitempty"`
	Containers                 []string          `yaml:"containers"`
	Replicas                   int               `yaml:"replicas,omitempty"`
	Group                      string            `yaml:"group,omitempty"`
	Property                   string            `yaml:"property,omitempty"`
	Project                    string            `yaml:"project,omitempty"`
	Product                    string            `yaml:"product,omitempty"`
	Environment                map[string]string `yaml:"environment,omitempty"`
	IgnoreImageVersion         bool              `yaml:"ignoreImageVersion,omitempty"`
	EnableMonitoring           *bool             `yaml:"enableMonitoring,omitempty"`
	HealthcheckTimeoutSeconds  *int              `yaml:"healthcheckTimeoutSeconds,omitempty"`
	HealthcheckIntervalSeconds *int              `yaml:"healthcheckIntervalSeconds,omitempty"`
}

ComposeShipment represents a harbor shipment in a harbor-compose.yml file

type Config added in v0.12.0

type Config struct {
	ShipitURI    string `json:"shipit"`
	CatalogitURI string `json:"catalogit"`
	TriggerURI   string `json:"trigger"`
	AuthURI      string `json:"authn"`
	HelmitURI    string `json:"helmit"`
	CustomsURI   string `json:"customs"`
	TelemetryURI string `json:"telemetry"`
	BargesURI    string `json:"barges"`
}

Config is the config for all communications in harbor

func GetConfig added in v0.12.0

func GetConfig() *Config

GetConfig will set the default values

type ContainerLastState added in v0.7.0

type ContainerLastState struct {
	ExitCode    int       `json:"exitCode"`
	Reason      string    `json:"reason"`
	StartedAt   time.Time `json:"startedAt"`
	FinishedAt  time.Time `json:"finishedAt"`
	ContainerID string    `json:"containerID"`
}

ContainerLastState represents the last state of a container

type ContainerPayload

type ContainerPayload struct {
	Name    string          `json:"name,omitempty"`
	Image   string          `json:"image,omitempty"`
	EnvVars []EnvVarPayload `json:"envVars,omitempty"`
	Ports   []PortPayload   `json:"ports,omitempty"`
}

ContainerPayload represents a container payload

type ContainerState added in v0.7.0

type ContainerState struct {
	StartedAt time.Time `json:"startedAt"`
	Reason    string    `json:"reason"`
	Message   string    `json:"message"`
}

ContainerState represents a particular state of a container

type ContainerStatusOutput added in v0.7.0

type ContainerStatusOutput struct {
	ID        string
	Image     string
	Started   string
	Status    string
	Restarts  string
	LastState string
}

ContainerStatusOutput represents an object that can be written to stdout and formatted

type DeployRequest added in v0.10.0

type DeployRequest struct {
	Name    string `json:"name"`
	Image   string `json:"image"`
	Version string `json:"version"`
	Catalog bool   `json:"catalog"`
}

DeployRequest represents a request to deploy a shipment/container to an environment

type DockerCompose

type DockerCompose struct {
	Version  string                           `yaml:"version"`
	Services map[string]*DockerComposeService `yaml:"services"`
}

DockerCompose represents a docker-compose.yml file (only used for writing via generate/init/pull)

type DockerComposeService

type DockerComposeService struct {
	Build       string            `yaml:"build,omitempty"`
	Image       string            `yaml:"image,omitempty"`
	Ports       []string          `yaml:"ports,omitempty"`
	Environment map[string]string `yaml:"environment,omitempty"`
	EnvFile     []string          `yaml:"env_file,omitempty"`
}

DockerComposeService represents a container (only used for writing via generate/init)

type EnvVarPayload

type EnvVarPayload struct {
	Name  string `json:"name"`
	Value string `json:"value"`
	Type  string `json:"type,omitempty"`
}

EnvVarPayload represents EnvVar

type Group added in v0.18.0

type Group struct {
	ID     string   `json:"id"`
	Users  []string `json:"users"`
	Admins []string `json:"admins"`
}

Group represents a harbor group

func GetGroup added in v0.18.0

func GetGroup(id string) *Group

GetGroup returns the members of a harbor group

type HarborCompose

type HarborCompose struct {
	Shipments map[string]ComposeShipment `yaml:"shipments"`
}

HarborCompose represents a harbor-compose.yml file

func DeserializeHarborCompose

func DeserializeHarborCompose(file string) HarborCompose

DeserializeHarborCompose deserializes a harbor-compose.yml file into an object

type HelmitContainer

type HelmitContainer struct {
	Name      string   `json:"name"`
	ID        string   `json:"id"`
	Image     string   `json:"image"`
	Logstream string   `json:"log_stream"`
	Logs      []string `json:"logs"`
}

HelmitContainer represents a single container instance in harbor

type HelmitReplica

type HelmitReplica struct {
	Host       string            `json:"host"`
	Provider   string            `json:"provider"`
	Containers []HelmitContainer `json:"containers"`
}

HelmitReplica represents a single running replica in harbor

type HelmitResponse

type HelmitResponse struct {
	Error    bool            `json:"error"`
	Replicas []HelmitReplica `json:"replicas"`
}

HelmitResponse represents a response from helmit

type LoadBalancer added in v0.18.0

type LoadBalancer struct {
	Name                  string `json:"name"`
	Type                  string `json:"type"`
	Public                bool   `json:"public"`
	ARN                   string `json:"arn"`
	DNSName               string `json:"dnsName"`
	CanonicalHostedZoneID string `json:"canonicalHostedZoneId"`
	VpcID                 string `json:"vpcId"`
	State                 string `json:"state"`
}

LoadBalancer represents a harbor load balancer

type LocalBuild added in v0.11.0

type LocalBuild struct{}

LocalBuild represents a local build provider

func (LocalBuild) ProvideArtifacts added in v0.11.0

func (provider LocalBuild) ProvideArtifacts(dockerCompose *DockerCompose, harborCompose *HarborCompose, token string, platform string) ([]*BuildArtifact, error)

ProvideArtifacts -

type Logs added in v0.5.0

type Logs []logObject

Logs is a list

func (Logs) Len added in v0.5.0

func (slice Logs) Len() int

func (Logs) Less added in v0.5.0

func (slice Logs) Less(i, j int) bool

func (Logs) Swap added in v0.5.0

func (slice Logs) Swap(i, j int)

type ParentShipment added in v0.14.0

type ParentShipment struct {
	Name    string          `json:"name"`
	EnvVars []EnvVarPayload `json:"envVars"`
	Group   string          `json:"group"`
}

The ParentShipment of the shipmentModel

type PortPayload

type PortPayload struct {
	Name                string `json:"name,omitempty"`
	Value               int    `json:"value,omitempty"`
	Protocol            string `json:"protocol,omitempty"`
	Healthcheck         string `json:"healthcheck,omitempty"`
	Primary             bool   `json:"primary,omitempty"`
	External            bool   `json:"external,omitempty"`
	PublicVip           bool   `json:"public_vip,omitempty"`
	PublicPort          int    `json:"public_port,omitempty"`
	EnableProxyProtocol bool   `json:"enable_proxy_protocol,omitempty"`
	SslArn              string `json:"ssl_arn,omitempty"`
	SslManagementType   string `json:"ssl_management_type,omitempty"`
	HealthcheckTimeout  *int   `json:"healthcheck_timeout,omitempty"`
	HealthcheckInterval *int   `json:"healthcheck_interval,omitempty"`
	LBType              string `json:"lbtype,omitempty"`
}

PortPayload represents a port

type ProviderPayload

type ProviderPayload struct {
	Name     string          `json:"name"`
	Replicas int             `json:"replicas"`
	EnvVars  []EnvVarPayload `json:"envVars,omitempty"`
	Barge    string          `json:"barge,omitempty"`
}

ProviderPayload represents a provider payload

type ShipmentEnvironment

type ShipmentEnvironment struct {
	Username         string             `json:"username"`
	Token            string             `json:"token"`
	Name             string             `json:"name"`
	EnvVars          []EnvVarPayload    `json:"envVars"`
	Containers       []ContainerPayload `json:"containers"`
	Providers        []ProviderPayload  `json:"providers"`
	ParentShipment   ParentShipment     `json:"parentShipment"`
	BuildToken       string             `json:"buildToken,omitempty"`
	EnableMonitoring bool               `json:"enableMonitoring"`
	IamRole          string             `json:"iamRole"`
}

ShipmentEnvironment represents a shipment/environment combination

func GetShipmentEnvironment

func GetShipmentEnvironment(username string, token string, shipment string, env string) *ShipmentEnvironment

GetShipmentEnvironment returns a harbor shipment from the API

type ShipmentEvent added in v0.17.0

type ShipmentEvent struct {
	Type    string `json:"type"`
	Count   int    `json:"count"`
	Reason  string `json:"reason"`
	Message string `json:"message"`
	Source  struct {
		Component string `json:"component"`
	} `json:"source"`
	FirstTimestamp time.Time `json:"firstTimestamp"`
	LastTimestamp  time.Time `json:"lastTimestamp"`
	StartTime      string
}

ShipmentEvent represents a shipment event

type ShipmentEventResult added in v0.17.0

type ShipmentEventResult struct {
	Namespace string          `json:"namespace"`
	Version   string          `json:"version"`
	Events    []ShipmentEvent `json:"events"`
}

ShipmentEventResult represents system events for a shipment/environment

func GetShipmentEvents added in v0.17.0

func GetShipmentEvents(barge string, shipment string, env string) *ShipmentEventResult

GetShipmentEvents returns a ShipmentEventResult for a given shipment/environment

type ShipmentStatus added in v0.7.0

type ShipmentStatus struct {
	Namespace string `json:"namespace"`
	Version   string `json:"version"`
	Status    struct {
		Phase      string `json:"phase"`
		Containers []struct {
			ID        string                        `json:"id"`
			Image     string                        `json:"image"`
			Ready     bool                          `json:"ready"`
			Restarts  int                           `json:"restarts"`
			State     map[string]ContainerState     `json:"state"`
			Status    string                        `json:"status"`
			LastState map[string]ContainerLastState `json:"lastState"`
		} `json:"containers"`
	} `json:"status"`
	AverageRestarts float32 `json:"averageRestarts"`
}

ShipmentStatus represents the deployed status of a shipment

func GetShipmentStatus added in v0.7.0

func GetShipmentStatus(barge string, shipment string, env string) *ShipmentStatus

GetShipmentStatus returns the running status of a shipment

type ShipmentStatusOutput added in v0.7.0

type ShipmentStatusOutput struct {
	Shipment    string
	Environment string
	Barge       string
	Status      string
	Containers  string
	Replicas    string
	Endpoint    string
}

ShipmentStatusOutput represents an object that can be written to stdout and formatted

type TriggerResponseMultiple added in v0.5.0

type TriggerResponseMultiple struct {
	Messages []string `json:"message,omitempty"`
}

TriggerResponseMultiple is the payload returned from the trigger api

type TriggerResponseSingle added in v0.5.0

type TriggerResponseSingle struct {
	Message string `json:"message,omitempty"`
}

TriggerResponseSingle is the payload returned from the trigger api

type UpdatePortRequest added in v0.14.0

type UpdatePortRequest struct {
	Name                string `json:"name"`
	HealthcheckTimeout  *int   `json:"healthcheck_timeout,omitempty"`
	HealthcheckInterval *int   `json:"healthcheck_interval,omitempty"`
}

UpdatePortRequest represents a request to update a port

type UpdateShipmentEnvironmentRequest added in v0.14.0

type UpdateShipmentEnvironmentRequest struct {
	EnableMonitoring bool `json:"enableMonitoring"`
}

UpdateShipmentEnvironmentRequest represents a request to update a shipment/environment

Jump to

Keyboard shortcuts

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