Documentation ¶
Overview ¶
Package cloudcmd provides executable commands for the CLI.
This package focuses on the interaction with the cloud provider. It separates the cloud provider specific code from the rest of the CLI, and provides a common interface for all cloud providers.
Exported functions must not be cloud provider specific, but rather take a cloudprovider.Provider as an argument, perform CSP specific logic, and return a universally usable result.
It is used by the "cmd" to handle creation of cloud resources and other CSP specific interactions. User interaction happens in the "cmd" package, and should not happen or pass through this package.
The backend to this package is currently provided by the terraform package.
Index ¶
- func GetMarshaledServiceAccountURI(config *config.Config, fileHandler file.Handler) (string, error)
- func TerraformIAMUpgradeVars(conf *config.Config, fileHandler file.Handler) (terraform.Variables, error)
- func UpgradeRequiresIAMMigration(provider cloudprovider.Provider) bool
- type AWSIAMConfig
- type AWSIAMOutput
- type Applier
- func (a *Applier) Apply(ctx context.Context, csp cloudprovider.Provider, attestation variant.Variant, ...) (infra state.Infrastructure, retErr error)
- func (a *Applier) Plan(ctx context.Context, conf *config.Config) (bool, error)
- func (a *Applier) RestoreWorkspace() error
- func (a *Applier) WorkingDirIsEmpty() (bool, error)
- type AzureIAMConfig
- type AzureIAMOutput
- type GCPIAMConfig
- type GCPIAMOutput
- type IAMConfigOptions
- type IAMCreator
- type IAMDestroyer
- type IAMOutput
- type IAMUpgrader
- type RollbackBehavior
- type Terminator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMarshaledServiceAccountURI ¶ added in v2.10.0
GetMarshaledServiceAccountURI returns the service account URI for the given cloud provider.
func TerraformIAMUpgradeVars ¶ added in v2.11.0
func TerraformIAMUpgradeVars(conf *config.Config, fileHandler file.Handler) (terraform.Variables, error)
TerraformIAMUpgradeVars returns variables required to execute IAM upgrades with Terraform.
func UpgradeRequiresIAMMigration ¶ added in v2.11.0
func UpgradeRequiresIAMMigration(provider cloudprovider.Provider) bool
UpgradeRequiresIAMMigration returns true if the given cloud provider requires an IAM migration.
Types ¶
type AWSIAMConfig ¶ added in v2.3.0
AWSIAMConfig holds the necessary values for AWS IAM configuration.
type AWSIAMOutput ¶ added in v2.10.0
type AWSIAMOutput struct { ControlPlaneInstanceProfile string `json:"controlPlaneInstanceProfile,omitempty"` WorkerNodeInstanceProfile string `json:"workerNodeInstanceProfile,omitempty"` }
AWSIAMOutput contains the output information of an AWS IAM configuration.
type Applier ¶ added in v2.13.0
type Applier struct {
// contains filtered or unexported fields
}
Applier creates or updates cloud resources.
func NewApplier ¶ added in v2.13.0
func NewApplier( ctx context.Context, out io.Writer, workingDir, backupDir string, logLevel terraform.LogLevel, fileHandler file.Handler, ) (*Applier, func(), error)
NewApplier creates a new Applier.
func (*Applier) Apply ¶ added in v2.13.0
func (a *Applier) Apply( ctx context.Context, csp cloudprovider.Provider, attestation variant.Variant, withRollback RollbackBehavior, ) (infra state.Infrastructure, retErr error)
Apply applies the prepared configuration by creating or updating cloud resources.
func (*Applier) Plan ¶ added in v2.13.0
Plan plans the given configuration and prepares the Terraform workspace.
func (*Applier) RestoreWorkspace ¶ added in v2.13.0
RestoreWorkspace rolls back the existing workspace to the backup directory created when planning an action, and the user decides to not apply it. Note that this will not apply the restored state from the backup.
func (*Applier) WorkingDirIsEmpty ¶ added in v2.14.0
WorkingDirIsEmpty returns true if the working directory of the Applier is empty.
type AzureIAMConfig ¶ added in v2.3.0
type AzureIAMConfig struct { SubscriptionID string Location string ServicePrincipal string ResourceGroup string }
AzureIAMConfig holds the necessary values for Azure IAM configuration.
type AzureIAMOutput ¶ added in v2.10.0
type AzureIAMOutput struct { SubscriptionID string `json:"subscriptionID,omitempty"` TenantID string `json:"tenantID,omitempty"` UAMIID string `json:"uamiID,omitempty"` }
AzureIAMOutput contains the output information of a Microsoft Azure IAM configuration.
type GCPIAMConfig ¶ added in v2.3.0
GCPIAMConfig holds the necessary values for GCP IAM configuration.
type GCPIAMOutput ¶ added in v2.10.0
type GCPIAMOutput struct {
ServiceAccountKey string `json:"serviceAccountID,omitempty"`
}
GCPIAMOutput contains the output information of a GCP IAM configuration.
type IAMConfigOptions ¶ added in v2.8.0
type IAMConfigOptions struct { GCP GCPIAMConfig Azure AzureIAMConfig AWS AWSIAMConfig TFLogLevel terraform.LogLevel TFWorkspace string }
IAMConfigOptions holds the necessary values for IAM configuration.
type IAMCreator ¶ added in v2.3.0
type IAMCreator struct {
// contains filtered or unexported fields
}
IAMCreator creates the IAM configuration on the cloud provider.
func NewIAMCreator ¶ added in v2.3.0
func NewIAMCreator(out io.Writer) *IAMCreator
NewIAMCreator creates a new IAM creator.
func (*IAMCreator) Create ¶ added in v2.3.0
func (c *IAMCreator) Create(ctx context.Context, provider cloudprovider.Provider, opts *IAMConfigOptions) (IAMOutput, error)
Create prepares and hands over the corresponding providers IAM creator.
type IAMDestroyer ¶ added in v2.6.0
type IAMDestroyer struct {
// contains filtered or unexported fields
}
IAMDestroyer destroys an IAM configuration.
func NewIAMDestroyer ¶ added in v2.6.0
func NewIAMDestroyer() *IAMDestroyer
NewIAMDestroyer creates a new IAM Destroyer.
func (*IAMDestroyer) DestroyIAMConfiguration ¶ added in v2.6.0
func (d *IAMDestroyer) DestroyIAMConfiguration(ctx context.Context, tfWorkspace string, logLevel terraform.LogLevel) error
DestroyIAMConfiguration destroys the previously created IAM configuration and deletes the local IAM terraform files.
func (*IAMDestroyer) GetTfStateServiceAccountKey ¶ added in v2.10.0
func (d *IAMDestroyer) GetTfStateServiceAccountKey(ctx context.Context, tfWorkspace string) (gcpshared.ServiceAccountKey, error)
GetTfStateServiceAccountKey returns the service_account_key output from the terraform state.
type IAMOutput ¶ added in v2.10.0
type IAMOutput struct { // CloudProvider is the cloud provider of the cluster. CloudProvider cloudprovider.Provider `json:"cloudprovider,omitempty"` GCPOutput GCPIAMOutput `json:"gcpOutput,omitempty"` AzureOutput AzureIAMOutput `json:"azureOutput,omitempty"` AWSOutput AWSIAMOutput `json:"awsOutput,omitempty"` }
IAMOutput is the output of creating a new IAM profile.
type IAMUpgrader ¶ added in v2.11.0
type IAMUpgrader struct {
// contains filtered or unexported fields
}
IAMUpgrader handles upgrades to IAM resources required by Constellation.
func NewIAMUpgrader ¶ added in v2.11.0
func NewIAMUpgrader(ctx context.Context, existingWorkspace, upgradeWorkspace string, logLevel terraform.LogLevel, fileHandler file.Handler, ) (*IAMUpgrader, error)
NewIAMUpgrader creates and initializes a new IAMUpgrader. existingWorkspace is the directory holding the existing Terraform resources. upgradeWorkspace is the directory to use for holding temporary files and resources required to apply the upgrade.
func (*IAMUpgrader) ApplyIAMUpgrade ¶ added in v2.11.0
func (u *IAMUpgrader) ApplyIAMUpgrade(ctx context.Context, csp cloudprovider.Provider) error
ApplyIAMUpgrade applies the Terraform IAM migrations planned by PlanIAMUpgrade. On success, the workspace of the Upgrader replaces the existing Terraform workspace.
func (*IAMUpgrader) PlanIAMUpgrade ¶ added in v2.11.0
func (u *IAMUpgrader) PlanIAMUpgrade(ctx context.Context, outWriter io.Writer, vars terraform.Variables, csp cloudprovider.Provider) (bool, error)
PlanIAMUpgrade prepares the upgrade workspace and plans the possible Terraform migrations for Constellation's IAM resources (service accounts, permissions etc.). In case of possible migrations, the diff is written to outWriter and this function returns true.
func (*IAMUpgrader) RestoreIAMWorkspace ¶ added in v2.12.0
func (u *IAMUpgrader) RestoreIAMWorkspace() error
RestoreIAMWorkspace rolls back the existing workspace to the backup directory created when planning an upgrade, when the user decides to not apply an upgrade after planning it. Note that this will not apply the restored state from the backup.
type RollbackBehavior ¶ added in v2.13.0
type RollbackBehavior bool
RollbackBehavior is a boolean flag that indicates whether a rollback should be performed.
const ( // WithRollbackOnError indicates a rollback should be performed on error. WithRollbackOnError RollbackBehavior = true // WithoutRollbackOnError indicates a rollback should not be performed on error. WithoutRollbackOnError RollbackBehavior = false )
type Terminator ¶
type Terminator struct {
// contains filtered or unexported fields
}
Terminator deletes cloud provider resources.