handler

package
v1.2.52 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetYAMLProfilesDir

func GetYAMLProfilesDir() string

func ParseProfiles

func ParseProfiles(profilesDir string) map[string]*Profile

func ParseProfilesByFile

func ParseProfilesByFile(profileLocation string) map[string]*Profile

Types

type AccountRoleConfig

type AccountRoleConfig struct {
	Path               string `yaml:"path,omitempty"`
	PermissionBoundary string `yaml:"permission_boundary,omitempty"`
}

AccountRoleConfig will map the configuration of account roles from profile settings

type ClusterConfig

type ClusterConfig struct {
	BillingAccount                string `yaml:"billing_account,omitempty" json:"billing_account,omitempty"`
	Ec2MetadataHttpTokens         string `yaml:"imdsv2,omitempty" json:"imdsv2,omitempty"`
	InstanceType                  string `yaml:"instance_type,omitempty" json:"instance_type,omitempty"`
	Name                          string `yaml:"name,omitempty" json:"name,omitempty"`
	OIDCConfig                    string `yaml:"oidc_config,omitempty" json:"oidc_config,omitempty"`
	ProvisionShard                string `yaml:"provision_shard,omitempty" json:"provision_shard,omitempty"`
	Zones                         string `yaml:"zones,omitempty" json:"zones,omitempty"`
	AdditionalSGNumber            int    `yaml:"additional_sg_number,omitempty" json:"additional_sg_number,omitempty"`
	ExpirationTime                int    `yaml:"expiration_time,omitempty" json:"expiration_time,omitempty"`
	NameLength                    int    `default:"15" yaml:"name_length,omitempty" json:"name_length,omitempty"`
	VolumeSize                    int    `yaml:"volume_size,omitempty" json:"volume_size,omitempty"`
	WorkerPoolReplicas            int    `yaml:"replicas,omitempty" json:"replicas,omitempty"`
	AdditionalPrincipals          bool   `yaml:"additional_principals,omitempty" json:"additional_principals,omitempty"`
	AdminEnabled                  bool   `yaml:"admin_enabled,omitempty" json:"admin_enabled,omitempty"`
	AuditLogForward               bool   `yaml:"auditlog_forward,omitempty" json:"auditlog_forward,omitempty"`
	Autoscale                     bool   `yaml:"autoscale,omitempty" json:"autoscale,omitempty"`
	AutoscalerEnabled             bool   `yaml:"autoscaler_enabled,omitempty" json:"autoscaler_enabled,omitempty"`
	BYOVPC                        bool   `yaml:"byo_vpc,omitempty" json:"byo_vpc,omitempty"`
	DomainPrefixEnabled           bool   `yaml:"domain_prefix_enabled,omitempty" json:"domain_prefix_enabled,omitempty"`
	DisableUserWorKloadMonitoring bool   `yaml:"disable_uwm,omitempty" json:"disable_uwm,omitempty"`
	DisableSCPChecks              bool   `yaml:"disable_scp_checks,omitempty" json:"disable_scp_checks,omitempty"`
	ExternalAuthConfig            bool   `yaml:"external_auth_config,omitempty" json:"external_auth_config,omitempty"`
	EtcdEncryption                bool   `yaml:"etcd_encryption,omitempty" json:"etcd_encryption,omitempty"`
	EtcdKMS                       bool   `yaml:"etcd_kms,omitempty" json:"etcd_kms,omitempty"`
	FIPS                          bool   `yaml:"fips,omitempty" json:"fips,omitempty"`
	HCP                           bool   `yaml:"hcp,omitempty" json:"hypershift,omitempty"`
	IngressCustomized             bool   `yaml:"ingress_customized,omitempty" json:"ingress_customized,omitempty"`
	KMSKey                        bool   `yaml:"kms_key,omitempty" json:"kms_key,omitempty"`
	LabelEnabled                  bool   `yaml:"label_enabled,omitempty" json:"label_enabled,omitempty"`
	MultiAZ                       bool   `yaml:"multi_az,omitempty" json:"multi_az,omitempty"`
	NetworkingSet                 bool   `yaml:"networking,omitempty" json:"networking,omitempty"`
	PrivateLink                   bool   `yaml:"private_link,omitempty" json:"private_link,omitempty"`
	Private                       bool   `yaml:"private,omitempty" json:"private,omitempty"`
	ProxyEnabled                  bool   `yaml:"proxy_enabled,omitempty" json:"proxy_enabled,omitempty"`
	STS                           bool   `yaml:"sts,omitempty" json:"sts,omitempty"`
	SharedVPC                     bool   `yaml:"shared_vpc,omitempty" json:"shared_vpc,omitempty"`
	TagEnabled                    bool   `yaml:"tag_enabled,omitempty" json:"tag_enabled,omitempty"`
	NetworkType                   string `yaml:"network_type,omitempty" json:"network_type,omitempty"`
	RegistriesConfig              bool   `yaml:"registries_config" json:"registries_config,omitempty"`
	AllowedRegistries             bool   `yaml:"allowed_registries" json:"allowed_registries,omitempty"`
	BlockedRegistries             bool   `yaml:"blocked_registries" json:"blocked_registries,omitempty"`
	ManualCreationMode            bool   `yaml:"manual_creation_mode" json:"manual_creation_mode,omitempty"`
	FedRAMP                       bool   `yaml:"fedramp" json:"fedramp,omitempty"`
	ZeroEgress                    bool   `yaml:"zero_egress" json:"zero_egress,omitempty"`
}

ClusterConfig will map the clsuter configuration from profile settings

type ClusterDetail

type ClusterDetail struct {
	APIURL           string   `json:"api_url,omitempty"`
	ClusterID        string   `json:"cluster_id,omitempty"`
	ClusterName      string   `json:"cluster_name,omitempty"`
	ClusterType      string   `json:"cluster_type,omitempty"`
	ConsoleURL       string   `json:"console_url,omitempty"`
	InfraID          string   `json:"infra_id,omitempty"`
	OIDCEndpointURL  string   `json:"oidc_endpoint_url,omitempty"`
	OperatorRoleArns []string `json:"operator_role_arn,omitempty"`
}

ClusterDetail will record basic cluster info to support other team's testing

func ParseClusterDetail

func ParseClusterDetail() (*ClusterDetail, error)

ParseClusterDetail Get the cluster info from cluster-detail.json file

type ClusterHandler

type ClusterHandler interface {
	GenerateClusterCreateFlags() ([]string, error)
	CreateCluster(waitForClusterReady bool) error
	WaitForClusterReady(timeoutMin int) error
	Destroy() []error
	GetClusterDetail() *ClusterDetail
	GetResourcesHandler() ResourcesHandler
}

func NewClusterHandler

func NewClusterHandler(client *rosacli.Client, profile *Profile) (ClusterHandler, error)

NewClusterHandler create a new cluster handler with data persisted to Filesystem Need to call `saveToFile` method to make sure it persists all information

func NewClusterHandlerFromFilesystem

func NewClusterHandlerFromFilesystem(client *rosacli.Client, profile *Profile) (ClusterHandler, error)

NewClusterHandlerFromFilesystem create a new cluster handler from data saved on Filesystem

func NewTempClusterHandler

func NewTempClusterHandler(client *rosacli.Client, profile *Profile) (ClusterHandler, error)

NewTempClusterHandler create a new cluster handler WITHOUT data persisted to Filesystem Useful for test cases needed resources. Do not forget to delete the resources afterwards

type Day2Config added in v1.2.52

type Day2Config struct {
	LocalZoneMP    bool `yaml:"local-zone-mp,omitempty"`
	TuningConfig   bool `yaml:" tuning-config,omitempty"`
	TuningConfigMP bool `yaml:" tuning-config-mp,omitempty"`
}

Day2Config will map the configuration of day2-conf from profile settings

type FromSharedAWSAccount added in v1.2.50

type FromSharedAWSAccount struct {
	VPC                 bool `json:"vpc,omitempty"`
	AdditionalPrincipls bool `json:"additional_principals,omitempty"`
}

type Profile

type Profile struct {
	ChannelGroup      string             `yaml:"channel_group,omitempty"`
	Name              string             `yaml:"as,omitempty"`
	NamePrefix        string             `yaml:"name_prefix,omitempty"`
	Region            string             `yaml:"region,omitempty"`
	Version           string             `yaml:"version,omitempty"`
	AccountRoleConfig *AccountRoleConfig `yaml:"account-role,omitempty"`
	ClusterConfig     *ClusterConfig     `yaml:"cluster,omitempty"`
	Day2Config        *Day2Config        `yaml:"day2-conf,omitempty"`
}

Profile will map the profile settings from the profile yaml file

func GetProfile

func GetProfile(profileName string, profilesDir string) *Profile

func LoadProfileYamlFile

func LoadProfileYamlFile(profileName string) *Profile

func LoadProfileYamlFileByENV

func LoadProfileYamlFileByENV() *Profile

type ProxyDetail

type ProxyDetail struct {
	HTTPsProxy       string
	HTTPProxy        string
	CABundleFilePath string
	NoProxy          string
	InstanceID       string
}

type Resources

type Resources struct {
	AccountRolesPrefix           string                `json:"account_roles_prefix,omitempty"`
	AdditionalPrincipals         string                `json:"additional_principals,omitempty"`
	AuditLogArn                  string                `json:"audit_log,omitempty"`
	DNSDomain                    string                `json:"dns_domain,omitempty"`
	EtcdKMSKey                   string                `json:"etcd_kms_key,omitempty"`
	FromSharedAWSAccount         *FromSharedAWSAccount `json:"from_shared_aws_account,omitempty"`
	IngressHostedZoneID          string                `json:"ingress_hosted_zone_id,omitempty"`
	HostedCPInternalHostedZoneID string                `json:"hostedcp_internal_hosted_zone_id,omitempty"`
	KMSKey                       string                `json:"kms_key,omitempty"`
	OIDCConfigID                 string                `json:"oidc_config_id,omitempty"`
	OIDCProviderID               string                `json:"oidc_provider_id,omitempty"`
	OperatorRolesPrefix          string                `json:"operator_roles_prefix,omitempty"`
	Region                       string                `json:"region,omitempty"`
	ResourceShareArn             string                `json:"resource_share,omitempty"`
	SharedVPCRole                string                `json:"shared_vpc_role,omitempty"`
	VpcID                        string                `json:"vpc_id,omitempty"`
	HCPRoute53ShareRole          string                `json:"hcp_route53_share_role,omitempty"`
	HCPVPCEndpointShareRole      string                `json:"hcp_vpc_endpoint_share_role,omitempty"`
	ProxyInstanceID              string                `json:"proxy_instance_id,omitempty"`
}

Resources will record the resources prepared

type ResourcesHandler

type ResourcesHandler interface {
	DestroyResources() (errors []error)

	GetAccountRolesPrefix() string
	GetAdditionalPrincipals() string
	GetAuditLogArn() string
	GetDNSDomain() string
	GetEtcdKMSKey() string
	GetIngressHostedZoneID() string
	GetHostedCPInternalHostedZoneID() string
	GetKMSKey() string
	GetOIDCConfigID() string
	GetOperatorRolesPrefix() string
	GetResourceShareArn() string
	GetSharedVPCRole() string
	GetVpcID() string

	GetVPC() *vpc_client.VPC
	GetAWSClient(useSharedVPCIfAvailable bool) (*aws_client.AWSClient, error)

	PrepareVersion(versionRequirement string, channelGroup string, hcp bool) (*rosacli.OpenShiftVersionTableOutput, error)
	PreparePrefix(profilePrefix string, nameLength int) string
	PrepareVPC(vpcName string, cidrValue string, useExisting bool, withSharedAccount bool) (*vpc_client.VPC, error)
	PrepareSubnets(zones []string, multiZone bool) (map[string][]string, error)
	PrepareProxy(zone string, sshPemFileName string, sshPemFileRecordDir string, caFile string) (*ProxyDetail, error)
	PrepareKMSKey(multiRegion bool, testClient string, hcp bool, etcdKMS bool) (string, error)
	PrepareAdditionalSecurityGroups(securityGroupCount int, namePrefix string) ([]string, error)
	PrepareAccountRoles(namePrefix string, hcp bool, openshiftVersion string,
		channelGroup string, path string, permissionsBoundary string, route53RoleARN string,
		vpcEndpointRoleArn string) (accRoles *rosacli.AccountRolesUnit, err error)
	PrepareOperatorRolesByOIDCConfig(
		namePrefix string,
		oidcConfigID string,
		roleArn string,
		sharedRoute53RoleArn string,
		sharedVPCEndPointRoleArn string,
		hcp bool, channelGroup string) error
	PrepareAdminUser() (string, string)
	PrepareAuditlogRoleArnByOIDCConfig(auditLogRoleName string, oidcConfigID string) (string, error)
	PrepareAuditlogRoleArnByIssuer(auditLogRoleName string, oidcIssuerURL string) (string, error)
	PrepareOperatorRolesByCluster(clusterID string) error
	PrepareOIDCConfig(oidcConfigType string, roleArn string, prefix string) (string, error)
	PrepareOIDCProvider(oidcConfigID string) error
	PrepareOIDCProviderByCluster(clusterID string) error
	PrepareSharedVPCRole(sharedVPCRolePrefix string, installerRoleArn string,
		ingressOperatorRoleArn string) (string, string, error)
	PrepareAdditionalPrincipalsRole(roleName string, installerRoleArn string) (string, error)
	PrepareDNSDomain(hostedcp bool) (string, error)
	PrepareHostedZone(hostedZoneName string, vpcID string, private bool) (string, error)
	PrepareSubnetArns(subnetIDs string) ([]string, error)
	PrepareResourceShare(resourceShareName string, resourceArns []string) (string, error)

	DeleteVPCChain(withSharedAccount bool) error
	DeleteKMSKey(etcdKMS bool) error
	DeleteAuditLogRoleArn() error
	DeleteHostedZone(hostedZoneID string) error
	DeleteDNSDomain() error
	DeleteSharedVPCRole(managedPolicy bool) error
	DeleteAdditionalPrincipalsRole(managedPolicy bool) error
	DeleteResourceShare() error
	DeleteOperatorRoles() error
	DeleteOIDCConfig() error
	DeleteAccountRoles() error
}

func NewResourcesHandler

func NewResourcesHandler(client *rosacli.Client, region string,
	awsCredentialsFile string, awsSharedAccountCredentialsFile string) (ResourcesHandler, error)

NewResourcesHandler create a new resources handler with data persisted to Filesystem

func NewResourcesHandlerFromFilesystem

func NewResourcesHandlerFromFilesystem(client *rosacli.Client,
	awsCredentialsFile string, awsSharedAccountCredentialsFile string) (ResourcesHandler, error)

NewResourcesHandlerFromFilesystem create a new resources handler from data saved on Filesystem

func NewTempResourcesHandler

func NewTempResourcesHandler(client *rosacli.Client, region string,
	awsCredentialsFile string, awsSharedAccountCredentialsFile string) (ResourcesHandler, error)

NewTempResourcesHandler create a new resources handler WITHOUT data written to Filesystem Useful for test cases needed resources. Do not forget to delete the resources afterwards awsSharedAccountCredentialsFile is the second AWS account for shared resources

Jump to

Keyboard shortcuts

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