install

package
v0.0.0-...-ac9560e Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDatabaseComputeTier   = armpostgresqlflexibleservers.SKUTierBurstable
	DefaultDatabaseVMSize        = "Standard_B1ms"
	DefaultPostgresMajorVersion  = 16
	DefaultInitialDatabaseSizeGb = 32
	DefaultBackupRetentionDays   = 7
)
View Source
const (
	TygerNamespace          = "tyger"
	DefaultTygerReleaseName = TygerNamespace
)
View Source
const DefaultKubernetesVersion = "1.27" // LTS
View Source
const (
	TagKey = "tyger-environment"
)

Variables

View Source
var (
	ResourceNameRegex       = regexp.MustCompile(`^[a-z][a-z\-0-9]{1,23}$`)
	StorageAccountNameRegex = regexp.MustCompile(`^[a-z0-9]{3,24}$`)
	SubdomainRegex          = regexp.MustCompile(`^[a-zA-Z]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$`)
	DatabaseServerNameRegex = regexp.MustCompile(`^([a-z0-9](?:[a-z0-9\-]{1,61}[a-z0-9])?)?$`)
)
View Source
var (
	ErrAlreadyLoggedError = errors.New("already logged error")
)
View Source
var (
	ErrNotLoggedIn = errors.New("You must run `az login` before running this command")
)

Functions

func ApplyMigrations

func ApplyMigrations(ctx context.Context, targetVersion int, latest, waitForCompletion bool) error

func CreateOrUpdateAppByUri

func CreateOrUpdateAppByUri(ctx context.Context, cred azcore.TokenCredential, app aadApp) (objectId string, err error)

func CreateServicePrincipal

func CreateServicePrincipal(ctx context.Context, cred azcore.TokenCredential, appId string) (string, error)

func CreateStorageAccount

func CreateStorageAccount(ctx context.Context,
	storageAccountConfig *StorageAccountConfig,
	restConfigPromise *Promise[*rest.Config],
	managedIdentityPromise *Promise[*armmsi.Identity],
) (any, error)

func GetAppByUri

func GetAppByUri(ctx context.Context, cred azcore.TokenCredential, uri string) (aadApp, error)

func GetAzureCredentialFromContext

func GetAzureCredentialFromContext(ctx context.Context) azcore.TokenCredential

func GetChartSpec

func GetChartSpec(
	helmChartConfig *HelmChartConfig,
	helmClient helmclient.Client,
	overrideHelmChartConfig *HelmChartConfig,
	customizeSpec ...func(*helmclient.ChartSpec, helmclient.Client) error,
) (helmclient.ChartSpec, error)

func GetDefaultApiVersionForResource

func GetDefaultApiVersionForResource(ctx context.Context, resourceId string, providersClient *armresources.ProvidersClient) (string, error)

func GetDomainNameRegex

func GetDomainNameRegex(location string) *regexp.Regexp

func GetDomainNameSuffix

func GetDomainNameSuffix(location string) string

func GetGraphToken

func GetGraphToken(ctx context.Context, cred azcore.TokenCredential) (azcore.AccessToken, error)

func GetMigrationLogs

func GetMigrationLogs(ctx context.Context, id int, destination io.Writer) error

func GetServicePrincipalByAppId

func GetServicePrincipalByAppId(ctx context.Context, cred azcore.TokenCredential, appId string) (string, error)

func GetServicePrincipalDisplayName

func GetServicePrincipalDisplayName(ctx context.Context, cred azcore.TokenCredential, objectId string) (string, error)

func GetSubscriptionId

func GetSubscriptionId(ctx context.Context, subName string, cred azcore.TokenCredential) (string, error)

func GetUserPrincipalName

func GetUserPrincipalName(ctx context.Context, cred azcore.TokenCredential, objectId string) (string, error)

func GetUserRESTConfig

func GetUserRESTConfig(ctx context.Context) (*rest.Config, error)

func InstallCloud

func InstallCloud(ctx context.Context) (err error)

func InstallIdentities

func InstallIdentities(ctx context.Context, cred azcore.TokenCredential) error

func InstallTyger

func InstallTyger(ctx context.Context) error

func InstallTygerHelmChart

func InstallTygerHelmChart(ctx context.Context, restConfig *rest.Config, dryRun bool) (manifest string, valuesYaml string, err error)

func NewMiAwareAzureCLICredential

func NewMiAwareAzureCLICredential(options *azidentity.AzureCLICredentialOptions) (azcore.TokenCredential, error)

az account get-access-token fails if --tenant is provided and the user is logged in with a managed identity This creates a TokenProvider that works around this case

func PodExec

func PodExec(ctx context.Context, podName string, command ...string) (stdout *bytes.Buffer, stderr *bytes.Buffer, err error)

func Ptr

func Ptr[T any](t T) *T

func QuickValidateEnvironmentConfig

func QuickValidateEnvironmentConfig(config *EnvironmentConfig) bool

func RandomAlphanumString

func RandomAlphanumString(n int) string

func RenderConfig

func RenderConfig(templateValues ConfigTemplateValues, writer io.Writer) error

func SetAzureCredentialOnContext

func SetAzureCredentialOnContext(ctx context.Context, cred azcore.TokenCredential) context.Context

func SetConfigOnContext

func SetConfigOnContext(ctx context.Context, config *EnvironmentConfig) context.Context

func UninstallCloud

func UninstallCloud(ctx context.Context) (err error)

func UninstallTyger

func UninstallTyger(ctx context.Context) error

func WaitForPoller

func WaitForPoller[T any](ctx context.Context, promise *Promise[*runtime.Poller[T]]) (T, error)

Types

type AksPrincipal

type AksPrincipal struct {
	Kind PrincipalKind `json:"kind"`
	Id   string        `json:"id"`
}

type ApiConfig

type ApiConfig struct {
	DomainName string      `json:"domainName"`
	Auth       *AuthConfig `json:"auth"`
	Helm       *HelmConfig `json:"helm"`
}

type AuthConfig

type AuthConfig struct {
	TenantID  string `json:"tenantId"`
	ApiAppUri string `json:"apiAppUri"`
	CliAppUri string `json:"cliAppUri"`
}

type CloudConfig

type CloudConfig struct {
	TenantID              string              `json:"tenantId"`
	SubscriptionID        string              `json:"subscriptionId"`
	DefaultLocation       string              `json:"defaultLocation"`
	ResourceGroup         string              `json:"resourceGroup"`
	Compute               *ComputeConfig      `json:"compute"`
	Storage               *StorageConfig      `json:"storage"`
	DatabaseConfig        *DatabaseConfig     `json:"database"`
	LogAnalyticsWorkspace *NamedAzureResource `json:"logAnalyticsWorkspace"`
}

type ClusterConfig

type ClusterConfig struct {
	Name                       string            `json:"name"`
	ApiHost                    bool              `json:"apiHost"`
	Location                   string            `json:"location"`
	KubernetesVersion          string            `json:"kubernetesVersion,omitempty"`
	UserNodePools              []*NodePoolConfig `json:"userNodePools"`
	LocalDevelopmentIdentityId string            `json:"localDevelopmentIdentityId"` // undocumented - for local development only
}

type ComputeConfig

type ComputeConfig struct {
	Clusters                   []*ClusterConfig `json:"clusters"`
	ManagementPrincipals       []AksPrincipal   `apjson:"managementPrincipals"`
	PrivateContainerRegistries []string         `json:"privateContainerRegistries"`
}

func (*ComputeConfig) GetApiHostCluster

func (c *ComputeConfig) GetApiHostCluster() *ClusterConfig

type ConfigTemplateValues

type ConfigTemplateValues struct {
	EnvironmentName          string
	ResourceGroup            string
	TenantId                 string
	SubscriptionId           string
	DefaultLocation          string
	KubernetesVersion        string
	PrincipalId              string
	PrincipalDisplay         string
	PrincipalKind            PrincipalKind
	DatabaseServerName       string
	PostgresMajorVersion     int
	BufferStorageAccountName string
	LogsStorageAccountName   string
	DomainName               string
	ApiTenantId              string
	CurrentIpAddress         string
	CpuNodePoolMinCount      int
	GpuNodePoolMinCount      int
}

type DatabaseConfig

type DatabaseConfig struct {
	ServerName           string          `json:"serverName"`
	Location             string          `json:"location"`
	ComputeTier          string          `json:"computeTier"`
	VMSize               string          `json:"vmSize"`
	FirewallRules        []*FirewallRule `json:"firewallRules,omitempty"`
	PostgresMajorVersion int             `json:"postgresMajorVersion"`
	StorageSizeGB        int             `json:"storageSizeGB"`
	BackupRetentionDays  int             `json:"backupRetentionDays"`
	BackupGeoRedundancy  bool            `json:"backupGeoRedundancy"`
}

type DatabaseVersion

type DatabaseVersion struct {
	Id          int    `json:"id"`
	Description string `json:"description"`
	State       string `json:"state"`
}

func ListDatabaseVersions

func ListDatabaseVersions(ctx context.Context, allVersions bool) ([]DatabaseVersion, error)

type EnvironmentConfig

type EnvironmentConfig struct {
	EnvironmentName string       `json:"environmentName"`
	Cloud           *CloudConfig `json:"cloud"`
	Api             *ApiConfig   `json:"api"`
}

func GetConfigFromContext

func GetConfigFromContext(ctx context.Context) *EnvironmentConfig

type FirewallRule

type FirewallRule struct {
	Name           string `json:"name"`
	StartIpAddress string `json:"startIpAddress"`
	EndIpAddress   string `json:"endIpAddress"`
}

type HelmChartConfig

type HelmChartConfig struct {
	Namespace   string         `json:"namespace"`
	ReleaseName string         `json:"releaseName"`
	RepoName    string         `json:"repoName"`
	RepoUrl     string         `json:"repoUrl"`
	Version     string         `json:"version"`
	ChartRef    string         `json:"chartRef"`
	Values      map[string]any `json:"values"`
}

type HelmConfig

type HelmConfig struct {
	Tyger              *HelmChartConfig `json:"tyger"`
	Traefik            *HelmChartConfig `json:"traefik"`
	CertManager        *HelmChartConfig `json:"certManager"`
	NvidiaDevicePlugin *HelmChartConfig `json:"nvidiaDevicePlugin"`
}

type NamedAzureResource

type NamedAzureResource struct {
	ResourceGroup string `json:"resourceGroup"`
	Name          string `json:"name"`
}

type NodePoolConfig

type NodePoolConfig struct {
	Name     string `json:"name"`
	VMSize   string `json:"vmSize"`
	MinCount int32  `json:"minCount"`
	MaxCount int32  `json:"maxCount"`
}

type Principal

type Principal struct {
	ObjectId string        `json:"objectId"`
	Kind     PrincipalKind `json:"kind"`
}

func ObjectsIdToPrincipals

func ObjectsIdToPrincipals(ctx context.Context, cred azcore.TokenCredential, objectIds []string) ([]Principal, error)

type PrincipalKind

type PrincipalKind string
const (
	PrincipalKindUser             PrincipalKind = "User"
	PrincipalKindGroup            PrincipalKind = "Group"
	PrincipalKindServicePrincipal PrincipalKind = "ServicePrincipal"
)

type Promise

type Promise[T any] struct {
	// contains filtered or unexported fields
}

func NewPromise

func NewPromise[T any](ctx context.Context, group *PromiseGroup, function func(context.Context) (T, error)) *Promise[T]

func NewPromiseAfter

func NewPromiseAfter[T any](ctx context.Context, group *PromiseGroup, function func(context.Context) (T, error), dependencies ...UntypedPromise) *Promise[T]

func (*Promise[T]) Await

func (p *Promise[T]) Await() (T, error)

func (*Promise[T]) AwaitErr

func (p *Promise[T]) AwaitErr() error

type PromiseGroup

type PromiseGroup []UntypedPromise

type StorageAccountConfig

type StorageAccountConfig struct {
	Name     string `json:"name"`
	Location string `json:"location"`
	Sku      string `json:"sku"`
}

type StorageConfig

type StorageConfig struct {
	Buffers []*StorageAccountConfig `json:"buffers"`
	Logs    *StorageAccountConfig   `json:"logs"`
}

type UntypedPromise

type UntypedPromise interface {
	AwaitErr() error
}

Jump to

Keyboard shortcuts

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