curatedpackages

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CustomName = "generated-"
)
View Source
const (
	ImageRepositoryName = "eks-anywhere-packages-bundles"
)

Variables

This section is empty.

Functions

func CreateBundleManager

func CreateBundleManager(log logr.Logger) bundle.RegistryClient

CreateBundleManager builds a new bundle Manager.

func GenerateAllValidConfigurations added in v0.9.2

func GenerateAllValidConfigurations(configs map[string]string) (string, error)

func GetAWSConfigFromKeySecret added in v0.18.0

func GetAWSConfigFromKeySecret(ctx context.Context, key, secret, region string) (*aws.Config, error)

GetAWSConfigFromKeySecret get AWS config from key, secret and region.

func GetPackageBundleRef

func GetPackageBundleRef(vb releasev1.VersionsBundle) (string, error)

func GetRegionalRegistry added in v0.18.0

func GetRegionalRegistry(defaultRegistry, region string) string

GetRegionalRegistry get the regional registry corresponding to defaultRegistry in a specific region.

func GetRegistry added in v0.9.2

func GetRegistry(uri string) string

func GetVersionBundle

func GetVersionBundle(reader Reader, eksaVersion string, spec *v1alpha1.Cluster) (*releasev1.VersionsBundle, error)

func IsPackageControllerDisabled added in v0.15.0

func IsPackageControllerDisabled(cluster *anywherev1.Cluster) bool

IsPackageControllerDisabled detect if the package controller is disabled.

func ParseAWSConfig added in v0.18.0

func ParseAWSConfig(ctx context.Context, awsConfig string) (*aws.Config, error)

ParseAWSConfig parse AWS config from string.

func ParseConfigurations added in v0.9.2

func ParseConfigurations(configs []string) (map[string]string, error)

func PrintLicense

func PrintLicense()

func PullLatestBundle added in v0.11.2

func PullLatestBundle(ctx context.Context, log logr.Logger, artifact string) ([]byte, error)

PullLatestBundle reads the contents of the artifact using the latest bundle.

func PushBundle added in v0.11.2

func PushBundle(ctx context.Context, ref, fileName string, fileContent []byte) error

func TestRegistryAccessWithAWSConfig added in v0.18.0

func TestRegistryAccessWithAWSConfig(ctx context.Context, awsConfig, registry string, tokenProvider RegistryAuthTokenProvider, do Do) error

TestRegistryAccessWithAWSConfig test if the AWS config has valid permission to access container registry.

func TestRegistryAccessWithAWSKeySecret added in v0.18.0

func TestRegistryAccessWithAWSKeySecret(ctx context.Context, key, secret, region, registry string, tokenProvider RegistryAuthTokenProvider, do Do) error

TestRegistryAccessWithAWSKeySecret test if the AWS key and secret has valid permission to access container registry.

func TestRegistryWithAuthToken added in v0.18.0

func TestRegistryWithAuthToken(authToken, registry string, do Do) error

TestRegistryWithAuthToken test if the registry can be acccessed with auth token.

func ValidateKubeVersion

func ValidateKubeVersion(kubeVersion string, clusterName string) error

func WithActiveBundleTimeout added in v0.12.0

func WithActiveBundleTimeout(timeout time.Duration) func(client *PackageControllerClient)

func WithBundle added in v0.9.2

func WithBundle(bundle *packagesv1.PackageBundle) func(*PackageClient)

func WithClusterSpec added in v0.15.0

func WithClusterSpec(clusterSpec *cluster.Spec) func(client *PackageControllerClient)

WithClusterSpec sets the cluster spec.

func WithCustomConfigs added in v0.9.2

func WithCustomConfigs(customConfigs []string) func(*PackageClient)

func WithCustomPackages added in v0.9.2

func WithCustomPackages(customPackages []string) func(*PackageClient)

func WithEksaAccessKeyId added in v0.11.0

func WithEksaAccessKeyId(eksaAccessKeyId string) func(client *PackageControllerClient)

func WithEksaAwsConfig added in v0.17.0

func WithEksaAwsConfig(eksaAwsConfig string) func(client *PackageControllerClient)

WithEksaAwsConfig set the eksaAwsConfig field.

func WithEksaRegion added in v0.11.0

func WithEksaRegion(eksaRegion string) func(client *PackageControllerClient)

func WithEksaSecretAccessKey added in v0.11.0

func WithEksaSecretAccessKey(eksaSecretAccessKey string) func(client *PackageControllerClient)

func WithHTTPProxy added in v0.12.0

func WithHTTPProxy(httpProxy string) func(client *PackageControllerClient)

func WithHTTPSProxy added in v0.12.0

func WithHTTPSProxy(httpsProxy string) func(client *PackageControllerClient)

func WithManagementClusterName added in v0.12.0

func WithManagementClusterName(managementClusterName string) func(client *PackageControllerClient)

func WithNoProxy added in v0.12.0

func WithNoProxy(noProxy []string) func(client *PackageControllerClient)

func WithRegistryAccessTester added in v0.18.0

func WithRegistryAccessTester(registryTester RegistryAccessTester) func(client *PackageControllerClient)

WithRegistryAccessTester sets the registryTester.

func WithValuesFileWriter added in v0.14.0

func WithValuesFileWriter(writer filewriter.FileWriter) func(client *PackageControllerClient)

WithValuesFileWriter sets up a writer to generate temporary values.yaml to override some values in package controller helm chart.

Types

type BundleReader

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

func NewBundleReader

func NewBundleReader(kubeConfig string, clusterName string, k KubectlRunner, bm Manager, reg BundleRegistry) *BundleReader

func (*BundleReader) GetActiveController

func (b *BundleReader) GetActiveController(ctx context.Context) (*packagesv1.PackageBundleController, error)

func (*BundleReader) GetLatestBundle

func (b *BundleReader) GetLatestBundle(ctx context.Context, kubeVersion string) (*packagesv1.PackageBundle, error)

func (*BundleReader) UpgradeBundle

func (b *BundleReader) UpgradeBundle(ctx context.Context, controller *packagesv1.PackageBundleController, newBundleVersion string) error

type BundleRegistry

type BundleRegistry interface {
	GetRegistryBaseRef(ctx context.Context) (string, error)
}

type ChartInstaller

type ChartInstaller interface {
	InstallChart(ctx context.Context, chart, ociURI, version, kubeconfigFilePath, namespace, valueFilePath string, skipCRDs bool, values []string) error
}

type ChartManager added in v0.15.0

type ChartManager interface {
	ChartInstaller
	ChartUninstaller
}

ChartManager installs and uninstalls helm charts.

type ChartUninstaller added in v0.15.0

type ChartUninstaller interface {
	Delete(ctx context.Context, kubeconfigFilePath, installName, namespace string) error
}

ChartUninstaller handles deleting chart installations.

type ClientBuilder added in v0.15.0

type ClientBuilder interface {
	GetClient(context.Context, types.NamespacedName) (client.Client, error)
}

ClientBuilder returns a k8s client for the specified cluster.

type CustomRegistry

type CustomRegistry struct {
	helm.Client
	// contains filtered or unexported fields
}

func NewCustomRegistry

func NewCustomRegistry(helm helm.Client, registry string) *CustomRegistry

NewCustomRegistry returns a new CustomRegistry.

func (*CustomRegistry) GetRegistryBaseRef

func (cm *CustomRegistry) GetRegistryBaseRef(ctx context.Context) (string, error)

type DefaultRegistry

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

func NewDefaultRegistry

func NewDefaultRegistry(rmr Reader, kv string, cv version.Info) *DefaultRegistry

func (*DefaultRegistry) GetRegistryBaseRef

func (dr *DefaultRegistry) GetRegistryBaseRef(ctx context.Context) (string, error)

type DefaultRegistryAccessTester added in v0.18.0

type DefaultRegistryAccessTester struct{}

DefaultRegistryAccessTester the default implementation of RegistryAccessTester.

func (*DefaultRegistryAccessTester) Test added in v0.18.0

func (r *DefaultRegistryAccessTester) Test(ctx context.Context, accessKey, secret, region, awsConfig, registry string) (err error)

Test if the AWS static credential or sharedConfig has valid permission to access an ECR registry.

type DefaultRegistryAuthTokenProvider added in v0.18.0

type DefaultRegistryAuthTokenProvider struct{}

DefaultRegistryAuthTokenProvider provides auth token for AWS ECR registry access.

func (*DefaultRegistryAuthTokenProvider) GetTokenByAWSConfig added in v0.18.0

func (d *DefaultRegistryAuthTokenProvider) GetTokenByAWSConfig(ctx context.Context, awsConfig string) (string, error)

GetTokenByAWSConfig get auth token by AWS config.

func (*DefaultRegistryAuthTokenProvider) GetTokenByAWSKeySecret added in v0.18.0

func (d *DefaultRegistryAuthTokenProvider) GetTokenByAWSKeySecret(ctx context.Context, key, secret, region string) (string, error)

GetTokenByAWSKeySecret get auth token by AWS key and secret.

type Discovery

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

Discovery * Implements ServerVersionInterface to provide the Kubernetes client version to be used.

func NewDiscovery

func NewDiscovery(kubeVersion *KubeVersion) *Discovery

func (*Discovery) ServerVersion

func (d *Discovery) ServerVersion() (*version.Info, error)

type DisplayablePackage

type DisplayablePackage struct {
	*api.Package
	Status *interface{} `json:"status,omitempty"`
}

DisplayablePackage wraps Package to omit undesired members (like Status).

This is necessary in part because of https://github.com/golang/go/issues/11939 but also because we just don't want to generate a Status section when we're emitting templates for a user to modify.

func NewDisplayablePackage

func NewDisplayablePackage(p *api.Package) *DisplayablePackage

type Do added in v0.18.0

type Do func(req *http.Request) (*http.Response, error)

Do is a function type that takes a http request and returns a http response.

type Installer added in v0.9.2

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

func NewInstaller added in v0.9.2

func NewInstaller(runner KubectlRunner, pc PackageHandler, pcc PackageController, spec *cluster.Spec, packagesLocation, mgmtKubeconfig string) *Installer

NewInstaller installs packageController and packages during cluster creation.

func (*Installer) InstallCuratedPackages added in v0.9.2

func (pi *Installer) InstallCuratedPackages(ctx context.Context)

InstallCuratedPackages installs curated packages as part of the cluster creation.

type KubeDeleter added in v0.15.0

type KubeDeleter interface {
	Delete(context.Context, client.Object, ...client.DeleteOption) error
}

KubeDeleter abstracts client.Client so mocks can be substituted in tests.

type KubeVersion

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

func NewKubeVersion

func NewKubeVersion(major string, minor string) *KubeVersion

type KubectlRunner

type KubectlRunner interface {
	ExecuteCommand(ctx context.Context, opts ...string) (bytes.Buffer, error)
	ExecuteFromYaml(ctx context.Context, yaml []byte, opts ...string) (bytes.Buffer, error)
	// GetObject performs a GET call to the kube API server authenticating with a kubeconfig file
	// and unmarshalls the response into the provdied Object
	// If the object is not found, it returns an error implementing apimachinery errors.APIStatus
	GetObject(ctx context.Context, resourceType, name, namespece, kubeconfig string, obj runtime.Object) error
	// HasResource is true if the resource can be retrieved from the API and has length > 0.
	HasResource(ctx context.Context, resourceType string, name string, kubeconfig string, namespace string) (bool, error)
}

type Manager

type Manager interface {
	LatestBundle(ctx context.Context, baseRef string, kubeMajor string, kubeMinor string, clusterName string) (*packagesv1.PackageBundle, error)
}

type PackageClient

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

func NewPackageClient

func NewPackageClient(kubectl KubectlRunner, options ...PackageClientOpt) *PackageClient

func (*PackageClient) ApplyPackages

func (pc *PackageClient) ApplyPackages(ctx context.Context, fileName string, kubeConfig string) error

func (*PackageClient) CreatePackages

func (pc *PackageClient) CreatePackages(ctx context.Context, fileName string, kubeConfig string) error

func (*PackageClient) DeletePackages

func (pc *PackageClient) DeletePackages(ctx context.Context, packages []string, kubeConfig string, clusterName string) error

func (*PackageClient) DescribePackages

func (pc *PackageClient) DescribePackages(ctx context.Context, packages []string, kubeConfig string, clusterName string) error

func (*PackageClient) DisplayPackages

func (pc *PackageClient) DisplayPackages(w io.Writer) error

DisplayPackages pretty-prints a table of available packages.

func (*PackageClient) GeneratePackages

func (pc *PackageClient) GeneratePackages(clusterName string) ([]packagesv1.Package, error)

func (*PackageClient) GetPackageFromBundle

func (pc *PackageClient) GetPackageFromBundle(packageName string) (*packagesv1.BundlePackage, error)

func (*PackageClient) InstallPackage

func (pc *PackageClient) InstallPackage(ctx context.Context, bp *packagesv1.BundlePackage, customName string, clusterName string, kubeConfig string) error

func (*PackageClient) WritePackagesToStdOut

func (pc *PackageClient) WritePackagesToStdOut(packages []packagesv1.Package) error

type PackageClientOpt added in v0.9.2

type PackageClientOpt func(*PackageClient)

type PackageController added in v0.9.2

type PackageController interface {
	// Enable curated packages support.
	Enable(ctx context.Context) error
	IsInstalled(ctx context.Context) bool
}

type PackageControllerClient

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

func NewPackageControllerClient

func NewPackageControllerClient(chartManager ChartManager, kubectl KubectlRunner, clusterName, kubeConfig string, chart *releasev1.Image, registryMirror *registrymirror.RegistryMirror, options ...PackageControllerClientOpt) *PackageControllerClient

NewPackageControllerClient instantiates a new instance of PackageControllerClient.

func NewPackageControllerClientFullLifecycle added in v0.15.0

func NewPackageControllerClientFullLifecycle(logger logr.Logger, chartManager ChartManager, kubectl KubectlRunner, clientBuilder ClientBuilder) *PackageControllerClient

NewPackageControllerClientFullLifecycle creates a PackageControllerClient for the Full Cluster Lifecycle controller.

It differs because the CLI use case has far more information available at instantiation, while the FCL use case has less information at instantiation, and the rest when cluster creation is triggered.

func (*PackageControllerClient) CreateHelmOverrideValuesYaml added in v0.14.0

func (pc *PackageControllerClient) CreateHelmOverrideValuesYaml() (string, []byte, error)

CreateHelmOverrideValuesYaml creates a temp file to override certain values in package controller helm install.

func (*PackageControllerClient) Enable added in v0.15.0

func (pc *PackageControllerClient) Enable(ctx context.Context) error

Enable curated packages in a cluster

In case the cluster is management cluster, it performs the following actions:

  • Installation of Package Controller through helm chart installation
  • Creation of secret credentials
  • Creation of a single run of a cron job refresher
  • Activation of a curated packages bundle

In case the cluster is a workload cluster, it performs the following actions:

  • Creation of package bundle controller (PBC) custom resource in management cluster

func (*PackageControllerClient) EnableFullLifecycle added in v0.15.0

func (pc *PackageControllerClient) EnableFullLifecycle(ctx context.Context, log logr.Logger, clusterName, kubeConfig string, chart *releasev1.Image, registryMirror *registrymirror.RegistryMirror, options ...PackageControllerClientOpt) (err error)

EnableFullLifecycle wraps Enable to handle run-time arguments.

This method fills in the gaps between the original CLI use case, where all information is known at PackageControllerClient initialization, and the Full Cluster Lifecycle use case, where there's limited information at initialization. Basically any parameter here isn't known at instantiation of the PackageControllerClient during full cluster lifecycle usage, hence why this method exists.

func (*PackageControllerClient) GetCuratedPackagesRegistries added in v0.14.1

func (pc *PackageControllerClient) GetCuratedPackagesRegistries(ctx context.Context) (sourceRegistry, defaultRegistry, defaultImageRegistry string)

GetCuratedPackagesRegistries gets value for configurable registries from PBC.

func (*PackageControllerClient) GetPackageControllerConfiguration added in v0.15.0

func (pc *PackageControllerClient) GetPackageControllerConfiguration() (result string, err error)

GetPackageControllerConfiguration returns the default kubernetes version for a Cluster.

func (*PackageControllerClient) IsInstalled added in v0.12.0

func (pc *PackageControllerClient) IsInstalled(ctx context.Context) bool

IsInstalled checks if a package controller custom resource exists.

func (*PackageControllerClient) Reconcile added in v0.15.0

func (pc *PackageControllerClient) Reconcile(ctx context.Context, logger logr.Logger, client client.Client, cluster *anywherev1.Cluster) error

Reconcile installs resources when a full cluster lifecycle cluster is created.

func (*PackageControllerClient) ReconcileDelete added in v0.15.0

func (pc *PackageControllerClient) ReconcileDelete(ctx context.Context, logger logr.Logger, client KubeDeleter, cluster *anywherev1.Cluster) error

ReconcileDelete removes resources after a full cluster lifecycle cluster is deleted.

type PackageControllerClientOpt added in v0.11.0

type PackageControllerClientOpt func(client *PackageControllerClient)

type PackageHandler added in v0.9.2

type PackageHandler interface {
	CreatePackages(ctx context.Context, fileName string, kubeConfig string) error
}

type PackageReader

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

func NewPackageReader

func NewPackageReader(cache *registry.Cache, credentialStore *registry.CredentialStore, awsRegion string) *PackageReader

NewPackageReader create a new package reader with storage client.

func (*PackageReader) ReadChartsFromBundles

func (r *PackageReader) ReadChartsFromBundles(ctx context.Context, b *releasev1.Bundles) []registry.Artifact

ReadChartsFromBundles and return a list of chart artifacts.

func (*PackageReader) ReadImagesFromBundles

func (r *PackageReader) ReadImagesFromBundles(ctx context.Context, b *releasev1.Bundles) ([]registry.Artifact, error)

ReadImagesFromBundles and return a list of image artifacts.

type Reader

type Reader interface {
	ReadBundlesForVersion(eksaVersion string) (*releasev1.Bundles, error)
}

type RegistryAccessTester added in v0.18.0

type RegistryAccessTester interface {
	Test(ctx context.Context, accessKey, secret, region, awsConfig, registry string) error
}

RegistryAccessTester test if AWS credentials has valid permission to access an ECR registry.

type RegistryAuthTokenProvider added in v0.18.0

type RegistryAuthTokenProvider interface {
	GetTokenByAWSConfig(ctx context.Context, awsConfig string) (string, error)
	GetTokenByAWSKeySecret(ctx context.Context, key, secret, region string) (string, error)
}

RegistryAuthTokenProvider provides auth token for registry access.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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