deployclient

package
v0.0.0-...-7c152a1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRef                   = "master"
	DefaultOwner                 = "navikt"
	DefaultDeployServer          = "deploy.nav.cloud.nais.io:443"
	DefaultOtelCollectorEndpoint = "https://collector-internet.external.prod-gcp.nav.cloud.nais.io"
	DefaultTracingDashboardURL   = "https://grafana.nav.cloud.nais.io/d/cdxgyzr3rikn4a/deploy-tracing-drilldown?var-trace_id="
	DefaultDeployTimeout         = time.Minute * 10
)
View Source
const (
	DeployClientVersion  = "deploy.nais.io/client-version"
	GithubWorkflowRunURL = "deploy.nais.io/github-workflow-run-url"
)

Variables

View Source
var (
	ErrResourceRequired       = errors.New("at least one Kubernetes resource is required to make sense of the deployment")
	ErrAuthRequired           = errors.New("Github token or API key required")
	ErrClusterRequired        = errors.New("cluster required; see reference section in the documentation for available environments")
	ErrMalformedAPIKey        = errors.New("API key must be a hex encoded string")
	ErrInvalidTelemetryFormat = errors.New("telemetry input format malformed")
)

Functions

func ErrorStatus

func ErrorStatus(status *pb.DeploymentStatus) error

func InitConfig

func InitConfig(cfg *Config)

func InjectAnnotations

func InjectAnnotations(resource json.RawMessage, annotations map[string]string) (json.RawMessage, error)

func MakeDeploymentRequest

func MakeDeploymentRequest(cfg Config, deadline time.Time, kubernetes *pb.Kubernetes) *pb.DeploymentRequest

func MultiDocumentFileAsJSON

func MultiDocumentFileAsJSON(path string, ctx TemplateVariables) ([]json.RawMessage, error)

func NewGrpcConnection

func NewGrpcConnection(cfg Config) (*grpc.ClientConn, error)

func Prepare

func Prepare(ctx context.Context, cfg *Config) (*pb.DeploymentRequest, error)

func SetupLogging

func SetupLogging(cfg Config)

Types

type ActionsFormatter

type ActionsFormatter struct{}

func (*ActionsFormatter) Format

func (a *ActionsFormatter) Format(e *log.Entry) ([]byte, error)

type Config

type Config struct {
	APIKey                    string
	Actions                   bool
	Cluster                   string
	DeployServerURL           string
	DryRun                    bool
	Environment               string
	GithubToken               string
	GrpcAuthentication        bool
	GrpcUseTLS                bool
	Owner                     string
	PollInterval              time.Duration
	PrintPayload              bool
	Quiet                     bool
	Ref                       string
	Repository                string
	Resource                  []string
	Retry                     bool
	RetryInterval             time.Duration
	Team                      string
	Traceparent               string
	TelemetryInput            string
	Telemetry                 *telemetry.PipelineTimings
	Timeout                   time.Duration
	TracingDashboardURL       string
	OpenTelemetryCollectorURL string
	Variables                 []string
	VariablesFile             string
	Wait                      bool
}

func NewConfig

func NewConfig() *Config

config return user input and default values as Config. Values will be resolved with the following precedence: flags > environment variables > default values.

func (*Config) Validate

func (cfg *Config) Validate() error

type Deployer

type Deployer struct {
	Client pb.DeployClient
}

func (*Deployer) Deploy

func (d *Deployer) Deploy(ctx context.Context, cfg *Config, deployRequest *pb.DeploymentRequest) error

type Error

type Error struct {
	Code ExitCode
	Err  error
}

func ErrorWrap

func ErrorWrap(exitCode ExitCode, err error) *Error

func Errorf

func Errorf(exitCode ExitCode, format string, args ...interface{}) *Error

func (*Error) Error

func (err *Error) Error() string

type ExitCode

type ExitCode int
const (
	ExitSuccess ExitCode = iota
	ExitDeploymentFailure
	ExitDeploymentError
	ExitDeploymentInactive
	ExitNoDeployment
	ExitUnavailable
	ExitInvocationFailure
	ExitInternalError
	ExitTemplateError
	ExitTimeout
)

Keep separate to avoid skewing exit codes

func ErrorExitCode

func ErrorExitCode(err error) ExitCode

type TemplateVariables

type TemplateVariables map[string]interface{}

Jump to

Keyboard shortcuts

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