app

package
v1.25.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnsibleExtraVarsKey = "ansible_extra_vars"

	BuildNameKey      = "build_name"
	BuildNameExtraKey = "build_name_extra"

	BuildTypeAmazon = "amazon"
	BuildTypeAzure  = "azure"
	BuildTypeGCP    = "gcp"

	CommonConfigDefaultPath = "./images/common.yaml"
	ContainerdVersionKey    = "containerd_version"

	DefaultBuildName = "provision_build"

	GPUTypesKey      = "/gpu/types"
	GPUNvidiaVersion = "/nvidia_driver_version"

	KubernetesVersionKey       = "kubernetes_version"
	KubernetesFullVersionKey   = "kubernetes_full_version"
	KubernetesBuildMetadataKey = "kubernetes_build_metadata"

	PackerAMIGroupsPath     = "/packer/ami_groups"
	PackerAMIRegionsPath    = "/packer/ami_regions"
	PackerAMIUsersPath      = "/packer/ami_users"
	PackerBuilderRegionPath = "/packer/aws_region"
	PackerBuilderTypePath   = "/packer_builder_type"
	PackerFilterNamePath    = "/packer/ami_filter_name"
	PackerFilterOwnerPath   = "/packer/ami_filter_owners"
	PackerInstanceTypePath  = "/packer/aws_instance_type"
	PackerSourceAMIPath     = "/packer/source_ami"

	PackerAzureClientIDPath              = "/packer/client_id"
	PackerAzureDistributionVersionPath   = "/packer/distribution_version"
	PackerAzureInstanceType              = "/packer/vm_size"
	PackerAzureGalleryLocations          = "/packer/gallery_image_locations"
	PackerAzureGalleryImageNamePath      = "/packer/gallery_image_name"
	PackerAzureGalleryImageOfferPath     = "/packer/gallery_image_offer"
	PackerAzureGalleryImagePublisherPath = "/packer/gallery_image_publisher"
	PackerAzureGalleryImageSKU           = "/packer/gallery_image_sku"
	PackerAzureLocation                  = "/packer/location"
	PackerAzureGalleryNamePath           = "/packer/gallery_name"
	PackerAzureResourceGroupNamePath     = "/packer/resource_group_name"
	PackerAzureSubscriptionIDPath        = "/packer/subscription_id"
	PackerAzureTenantIDPath              = "/packer/tenant_id"
	PackerAzureCloudEndpointPath         = "/packer/cloud_environment_name"

	PackerGCPProjectIDPath = "/packer/project_id"
	PackerGCPNetworkPath   = "/packer/network"
	PackerGCPRegionPath    = "/packer/region"

	PackerGPUPath          = "/packer/gpu"
	PackerGPUTypes         = "/packer/gpu_types"
	PackerGPUNvidiaVersion = "/packer/gpu_nvidia_version"

	AzureClientIDEnvVariable = "AZURE_CLIENT_ID"
	//nolint:gosec // environment var set by user
	AzureClientSecretEnvVariable   = "AZURE_CLIENT_SECRET"
	AzureSubscriptionIDEnvVariable = "AZURE_SUBSCRIPTION_ID"
	AzureTenantIDEnvVariable       = "AZURE_TENANT_ID"

	//nolint:gosec // environment var set by user
	GCPCredentialEnvVariable = "GOOGLE_APPLICATION_CREDENTIALS"

	OutputDir = "./work"
)

Variables

View Source
var (
	ErrInitConfig               = errors.New("init configuration failure")
	ErrBuild                    = errors.New("build failure")
	ErrKubernetesVersionMissing = errors.New("necessary kubernetes_version key missing")
	ErrPathNotString            = errors.New("path value is not a string")
	ErrPathNotSlice             = errors.New("path value is not a slice")
	ErrConfigRequired           = errors.New("config value is required")
)

errors.

View Source
var AnsibleRunsDirectory = "ansible-runs"

Functions

func BuildError

func BuildError(op string) error

func BuildName

func BuildName(config Config) string

func EnrichKubernetesFullVersion

func EnrichKubernetesFullVersion(config Config, userDefinedKubernetesVersion string) error

enrichKubernetesFullVersion will enrich the kubernetes semver with build metadata added in via overrides. A common example is the fips override, which adds +fips.buildnumber to the version.

func GenPackerVars

func GenPackerVars(config Config, extraVarsPath string) ([]byte, error)

func InitConfigError

func InitConfigError(op string, err error) error

func MergeAmazonUserArgs

func MergeAmazonUserArgs(config Config, amazonArgs *AmazonArgs) error

func MergeAzureUserArgs

func MergeAzureUserArgs(config Config, azureArgs *AzureArgs) error

func MergeGCPUserArgs

func MergeGCPUserArgs(config Config, gcpArgs *GCPArgs) error

func MergeMapsOverwrite

func MergeMapsOverwrite(orig map[string]interface{}, maps ...map[string]interface{}) error

recursively merges maps into orig, orig is modified.

func MergeUserArgs

func MergeUserArgs(config Config, userArgs UserArgs) error

func NewRunOptions

func NewRunOptions(flags RootFlags) appansible.RunOptions

func Provision

func Provision(inventory string, flags ProvisionFlags) error

func Validate

func Validate(flags ValidateFlags) error

Types

type AmazonArgs

type AmazonArgs struct {
	// AMI options
	SourceAMI        string   `json:"source_ami"`
	AMIFilterName    string   `json:"ami_filter_name"`
	AMIFilterOwner   string   `json:"ami_filter_owner"`
	AWSBuilderRegion string   `json:"aws_region"`
	AMIRegions       []string `json:"ami_regions"`
	AWSInstanceType  string   `json:"aws_instance_type"`

	AMIUsers  []string `json:"ami_users"`
	AMIGroups []string `json:"ami_groups"`
}

type ArtifactUploader

type ArtifactUploader struct {
	// contains filtered or unexported fields
}

func NewArtifactUploader

func NewArtifactUploader(buildName string) (*ArtifactUploader, error)

func (*ArtifactUploader) UploadArtifacts

func (a *ArtifactUploader) UploadArtifacts(artifactFlags ArtifactsCmdFlags) error

type ArtifactsCmdFlags

type ArtifactsCmdFlags struct {
	OSPackagesBundleFile     string
	ContainerdBundleFile     string
	PIPPackagesBundleFile    string
	ContainerImagesBundleDir string
	NvidiaRunfile            string
	Inventory                string
	RootFlags
	Overrides []string
	ExtraVars []string
	WorkDir   string
}

type AzureArgs

type AzureArgs struct {
	ClientID string

	InstanceType string

	GalleryImageLocations []string
	GalleryImageName      string
	GalleryImageOffer     string
	GalleryImagePublisher string
	GalleryImageSKU       string
	GalleryName           string

	Location          string
	ResourceGroupName string

	SubscriptionID string
	TenantID       string
	CloudEndpoint  *AzureCloudFlag
}

type AzureCloudEndpoint

type AzureCloudEndpoint string
var (
	AzureCloudEndpointChina      AzureCloudEndpoint = "China"
	AzureCloudEndpointPublic     AzureCloudEndpoint = "Public"
	AzureCloudEndpointGovernment AzureCloudEndpoint = "USGovernment"
)

func ListAzureEndpoints

func ListAzureEndpoints() []AzureCloudEndpoint

type AzureCloudFlag

type AzureCloudFlag struct {
	Endpoint AzureCloudEndpoint
}

func (*AzureCloudFlag) Set

func (a *AzureCloudFlag) Set(s string) error

func (*AzureCloudFlag) String

func (a *AzureCloudFlag) String() string

func (*AzureCloudFlag) Type

func (a *AzureCloudFlag) Type() string

type BuildOptions

type BuildOptions struct {
	PackerPath         string
	PackerBuildFlags   packer.BuildFlags
	CustomManifestPath string
	DryRun             bool
}

type Builder

type Builder struct{}

func (*Builder) InitConfig

func (b *Builder) InitConfig(initOptions InitOptions) (string, error)

func (*Builder) Provision

func (b *Builder) Provision(workDir string, flags ProvisionFlags) error

Provision will run ansible playbook directly on an existing set of hosts.

func (*Builder) Run

func (b *Builder) Run(workDir string, buildOptions BuildOptions) error

type ClusterArgs

type ClusterArgs struct {
	KubernetesVersion string `json:"kubernetes_version" yaml:"kubernetes_version"`
	ContainerdVersion string `json:"containerd_version" yaml:"containerd_version"`
}

type Config

type Config map[string]interface{}

func (Config) AddBuildNameExtra

func (config Config) AddBuildNameExtra(base string) string

func (Config) Delete

func (config Config) Delete(path string) error

func (Config) Get

func (config Config) Get(path string) string

func (Config) GetSliceWithError

func (config Config) GetSliceWithError(path string) ([]string, error)

func (Config) GetWithEnvironment

func (config Config) GetWithEnvironment(path string, environmentVariable string) (string, error)

func (Config) GetWithError

func (config Config) GetWithError(path string) (string, error)

func (Config) Set

func (config Config) Set(path string, value interface{}) error

func (Config) SetAllowEmpty

func (config Config) SetAllowEmpty(path string, value interface{}) error

type GCPArgs

type GCPArgs struct {
	ProjectID string // the project ID to which the source VM belongs.
	Region    string // the region where the source VM is located.
	Network   string // the network in which to load image creation, should have .
}

type InitOptions

type InitOptions struct {
	CommonConfigPath string
	Image            string
	Overrides        []string
	UserArgs         UserArgs

	// ExtraVarsOnly is true when only ansible variables should only ansible variables
	// should be generated. Omitting packer variables. This is useful for working with
	// preprovisioned infrastructure
	ExtraVarsOnly bool
}

type ProvisionFlags

type ProvisionFlags struct {
	RootFlags
	ClusterArgs

	ExtraVars []string
	Overrides []string
	Provider  string
	WorkDir   string
	Inventory string
}

type RootFlags

type RootFlags struct {
	Verbosity logging.Verbosity
	RootFlagsCommon
}

func (*RootFlags) LogDebug

func (r *RootFlags) LogDebug() bool

type RootFlagsCommon

type RootFlagsCommon struct {
	Color bool
}

type UserArgs

type UserArgs struct {
	ClusterArgs

	Amazon *AmazonArgs
	Azure  *AzureArgs
	GCP    *GCPArgs

	// ExtraVars provided to ansible
	ExtraVars []string
}

type ValidateFlags

type ValidateFlags struct {
	RootFlags

	Inventory     string
	ServiceSubnet string
	PodSubnet     string
	APIServerPort int
}

Jump to

Keyboard shortcuts

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