common

package
v1.6.6-prerelease.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionPrefix = "openshift-v"

	TagsOpenShiftVersion   = tagsPrefix + "openshift_version"
	PropertyRosaTfVersion  = tagsPrefix + "tf_version"
	PropertyRosaTfCommit   = tagsPrefix + "tf_commit"
	PropertyRosaCreatorArn = tagsPrefix + "creator_arn"

	DefaultWaitTimeoutForHCPControlPlaneInMinutes = int64(20)
	DefaultWaitTimeoutInMinutes                   = int64(60)
	DefaultPollingIntervalInMinutes               = 2
	NonPositiveTimeoutSummary                     = "Can't poll cluster state with a non-positive timeout"
	NonPositiveTimeoutFormat                      = "Can't poll state of cluster with identifier '%s', the timeout that was set is not a positive number"

	MaxClusterNameLength         = 54
	MaxClusterDomainPrefixLength = 15
)

Variables

View Source
var AvailabilityZoneValidator = attrvalidators.NewStringValidator("AZ should be valid for cloud_region", func(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
	az := req.ConfigValue.ValueString()
	regionAttr := basetypes.StringValue{}
	err := req.Config.GetAttribute(ctx, path.Root("cloud_region"), &regionAttr)
	if err != nil {
		resp.Diagnostics.AddAttributeError(req.Path, "Invalid AZ", "Failed to fetch cloud_region")
		return
	}
	region := regionAttr.ValueString()
	if !strings.Contains(az, region) {
		msg := fmt.Sprintf("Invalid AZ '%s' for region '%s'.", az, region)
		resp.Diagnostics.AddAttributeError(req.Path, "Invalid AZ", msg)
		return
	}
})
View Source
var PrivateHZValidator = attrvalidators.NewObjectValidator("proxy map should not include an hard coded OCM proxy",
	func(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) {
		if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
			return
		}

		privateHZ := types.PrivateHostedZone{}
		d := req.ConfigValue.As(ctx, &privateHZ, basetypes.ObjectAsOptions{})
		if d.HasError() {

			return
		}
		errSum := "Invalid private_hosted_zone attribute assignment"

		if common.IsStringAttributeKnownAndEmpty(privateHZ.ID) || common.IsStringAttributeKnownAndEmpty(privateHZ.RoleARN) {
			resp.Diagnostics.AddError(errSum, "Invalid configuration. 'private_hosted_zone.id' and 'private_hosted_zone.role_arn' are required")
			return
		}

	})
View Source
var PropertiesValidator = attrvalidators.NewMapValidator("properties map should not include an hard coded OCM properties",
	func(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) {
		if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
			return
		}
		propertiesElements := make(map[string]tfTypes.String, len(req.ConfigValue.Elements()))
		d := req.ConfigValue.ElementsAs(ctx, &propertiesElements, false)
		if d.HasError() {

			return
		}

		for k := range propertiesElements {
			if _, isDefaultKey := OCMProperties[k]; isDefaultKey {
				errHead := "Invalid property key."
				errDesc := fmt.Sprintf("Can not override reserved properties keys. %s is a reserved property key", k)
				resp.Diagnostics.AddError(errHead, errDesc)
				return
			}
		}
	})
View Source
var UserArnRE = regexp.MustCompile("^(arn:(?:aws|aws-us-gov|aws-cn):(?:iam|sts)::\\d{12}(?:|:(?:root|user|assumed-role|role)(?:\\/?.+\\/?)?)(?:\\/[0-9A-Za-z\\+\\.@_,-]{1,64}))$")

Functions

func ValidatePatchProperties added in v1.6.3

func ValidatePatchProperties(ctx context.Context, state, plan types.Map) (map[string]string, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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