jetconfig

package
v0.0.0-...-2dfab7d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CronType      = "cron"
	HelmChartType = "helm"
	JobType       = "job"
	WebType       = "web"
)

Types

View Source
const DefaultAppPodPort = 8080

TODO DEV-983 consolidate default helm value constants

View Source
const JetpackEnvsecProvider = "jetpack"
View Source
const ProjectIDPrefix = "proj"

Variables

View Source
var (
	InstanceType_name = map[int32]string{
		0: "UNKNOWN",
		1: "NANO",
		2: "MICRO",
		3: "SMALL",
		4: "MEDIUM",
		5: "MEDIUM_PLUS",
	}
	InstanceType_value = map[string]int32{
		"UNKNOWN":     0,
		"NANO":        1,
		"MICRO":       2,
		"SMALL":       3,
		"MEDIUM":      4,
		"MEDIUM_PLUS": 5,
	}
)

Enum value maps for InstanceType.

View Source
var ErrConfigNotFound = errors.New("jetconfig (launchpad.yaml) was not found")
View Source
var ErrInvalidProjectID = errors.New("project ID is invalid")
View Source
var File_padcli_jetconfig_jetconfig_proto protoreflect.FileDescriptor
View Source
var Versions = version{
	// contains filtered or unexported fields
}

singleton (unenforced) for this package

Functions

func ConfigDir

func ConfigDir(path string) string

func ConfigName

func ConfigName(path string) string

func GetProjectSlug

func GetProjectSlug(projectID string) (string, error)

func GetServiceTypes

func GetServiceTypes() []string

func InterpolateStamps

func InterpolateStamps(s string) string

func NewProjectId

func NewProjectId() string

Types

type Builder

type Builder interface {
	GetBuildCommand() string
	GetImage() string
	GetInstanceType() *InstanceType
	GetPath() string
	ShouldPublish() bool
}

Builder is an interface for services that may have BuildCommand fields. NOTE: not all builders will eventually have image. For example, helm-services may be builders but may not have images. We may refactor when introducing such builders.

type Config

type Config struct {
	ConfigVersion string `yaml:"configVersion,omitempty"`

	// typeid generated for each project for storing env vars without having to rely on
	// project name which may change over time
	ProjectID string `yaml:"projectId,omitempty"`

	Name string `yaml:"name,omitempty"`

	// The cluster to deploy to. Should be the unique name of a Jetpack-managed cluster,
	// or the name of a context in the user's kubeconfig.
	Cluster string `yaml:"cluster,omitempty"` // --cluster

	Envsec EnvsecFields `yaml:"envsec,omitempty"`

	ImageRepository string `yaml:"imageRepository,omitempty"`

	Environment map[string]EnvironmentFields `yaml:"environment,omitempty"`

	Services services `yaml:"services,omitempty"`

	// The file path to this jetconfig
	Path string `yaml:"-"`
	// contains filtered or unexported fields
}

TODO, make this struct unexported

func RequireFromFileSystem

func RequireFromFileSystem(
	ctx context.Context,
	path string,
	env api.Environment,
) (*Config, error)

RequireFromFileSystem will: - read launchpad.yaml at `path` in the file system - populates the Config struct from the file's contents, via yaml unmarshalling - upgrade the jetconfig with newer fields - if config doesn't exist, it returns an error.

func (*Config) AddNewCronService

func (c *Config) AddNewCronService(
	name string,
	command []string,
	schedule string,
) Cron

instantiates a new Cron service for initcmd

func (*Config) AddNewJobHelmChart

func (c *Config) AddNewJobHelmChart(
	name string,
	command []string,
	schedule string,
) HelmChart

instantiates a new Job service for initcmd

func (*Config) AddNewJobService

func (c *Config) AddNewJobService(
	name string,
	command []string,
	schedule string,
) Job

instantiates a new Job service for initcmd

func (*Config) AddNewWebService

func (c *Config) AddNewWebService(name string) Web

instantiates a new Web service for initcmd

func (*Config) Builders

func (c *Config) Builders() map[string]Builder

func (*Config) Cronjobs

func (c *Config) Cronjobs() []Cron

func (*Config) GetCluster

func (c *Config) GetCluster() string

func (*Config) GetInstanceName

func (cfg *Config) GetInstanceName() string

func (*Config) GetProjectID

func (c *Config) GetProjectID() string

func (*Config) GetProjectName

func (cfg *Config) GetProjectName() string

func (*Config) GetProjectNameWithSlug

func (c *Config) GetProjectNameWithSlug() string

func (*Config) GetProjectSlug

func (c *Config) GetProjectSlug() string

func (*Config) HasDefaultFileName

func (c *Config) HasDefaultFileName() bool

func (*Config) HasDeployment

func (cfg *Config) HasDeployment() (bool, error)

func (*Config) HelmCharts

func (c *Config) HelmCharts() []HelmChart

func (*Config) Jobs

func (c *Config) Jobs() []Job

func (*Config) SaveConfig

func (cfg *Config) SaveConfig(path string) (string, error)

func (*Config) UnmarshalYAML

func (cfg *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*Config) WebService

func (c *Config) WebService() (Web, error)

For now, at most one web service is expected If no web service is specified, then returns empty-string for name, and nil for *Web

NOTE: if we add a service.Name field, then this API improves TODO DEV-966 enable multiple web-services. Change function's name and type.

type Cron

type Cron interface {
	Builder
	Service
	GetSchedule() string
	GetConcurrencyPolicy() string
	GetCommand() []string
}

Public Cron interface

type EnvironmentFields

type EnvironmentFields struct {
	// Default flags
	Flags FlagSet `yaml:"flags,omitempty"`
}

type EnvsecFields

type EnvsecFields struct {
	Provider string `yaml:"provider,omitempty"`
}

type FlagSet

type FlagSet map[string]any

func (FlagSet) GetValueAsString

func (f FlagSet) GetValueAsString(name string) (string, error)

func (FlagSet) GetValueAsStringSlice

func (f FlagSet) GetValueAsStringSlice(name string) ([]string, error)

type HelmChart

type HelmChart interface {
	Service
	GetRepo() string
	GetChart() string
}

Public HelmChart interface

type InstanceType

type InstanceType int32
const (
	InstanceType_UNKNOWN     InstanceType = 0
	InstanceType_NANO        InstanceType = 1
	InstanceType_MICRO       InstanceType = 2
	InstanceType_SMALL       InstanceType = 3
	InstanceType_MEDIUM      InstanceType = 4
	InstanceType_MEDIUM_PLUS InstanceType = 5
)

func (*InstanceType) Compute

func (i *InstanceType) Compute() string

func (InstanceType) Descriptor

func (InstanceType) Enum

func (x InstanceType) Enum() *InstanceType

func (InstanceType) EnumDescriptor deprecated

func (InstanceType) EnumDescriptor() ([]byte, []int)

Deprecated: Use InstanceType.Descriptor instead.

func (*InstanceType) MarshalYAML

func (i *InstanceType) MarshalYAML() (any, error)

func (*InstanceType) Memory

func (i *InstanceType) Memory() string

func (InstanceType) Number

func (InstanceType) String

func (x InstanceType) String() string

func (InstanceType) Type

func (*InstanceType) UnmarshalYAML

func (i *InstanceType) UnmarshalYAML(value *yaml.Node) error

type Job

type Job interface {
	Builder
	Service
	GetCommand() []string
}

Public Job interface

type Service

type Service interface {
	GetName() string
	GetUniqueName() string
	GetPath() string
	// contains filtered or unexported methods
}

Service represents the core of a jetconfig service

type Web

type Web interface {
	Builder
	Service
	GetPort() int
	GetURL() (*url.URL, error)
}

Jump to

Keyboard shortcuts

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