common

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IRELAND = "ireland"
	UK      = "uk"
	USEAST  = "us_east"
)
View Source
const (
	// MICRO - 1 core and 0.5 gb ram
	MICRO = "nano"
	// MEDIUM - 2 cores and 4 gb ram
	MEDIUM = "medium"
	// LARGE - 2 cores and 8 gb ram
	LARGE = "large"
)

Variables

View Source
var AMIMAP = map[string]string{
	"eu-west-1": "ami-09d4a659cdd8677be",
	"eu-west-2": "ami-0fc15d50d39e4503c",
	"us-east-1": "ami-04ad2567c9e3d7893",
}

eu-west-2 "ami-0fc15d50d39e4503c" amzn2-ami-hvm-2.0.20211103.0-x86_64-gp2 https://cloud-images.ubuntu.com/locator/ec2/

View Source
var AVAILABILITY_ZONES = map[string]map[commonpb.CloudProvider][]string{
	UK: {
		AWS:   []string{"eu-west-2a", "eu-west-2b", "eu-west-2c"},
		AZURE: []string{"1", "2", "3"},
	},
	IRELAND: {
		AWS:   []string{"eu-west-1a", "eu-west-1b", "eu-west-1c"},
		AZURE: []string{"1", "2", "3"},
	},
	USEAST: {
		AWS:   []string{"us-east-1a", "us-east-1b", "us-east-1c"},
		AZURE: []string{"1", "2", "3"},
	},
}
View Source
var LOCATION = map[string]map[commonpb.CloudProvider]string{
	UK: {
		AWS:   "eu-west-2",
		AZURE: "ukwest",
	},
	IRELAND: {
		AWS:   "eu-west-1",
		AZURE: "northeurope",
	},
	USEAST: {
		AWS:   "us-east-1",
		AZURE: "eastus",
	},
}

Functions

func AlphanumericFormatFunc

func AlphanumericFormatFunc(s string) string

func GetAvailabilityZone

func GetAvailabilityZone(location string, az int, cloud commonpb.CloudProvider) (string, error)

func GetCloudLocation

func GetCloudLocation(location string, provider commonpb.CloudProvider) (string, error)

func GetCloudLocationPb added in v0.1.15

func GetCloudLocationPb(location string, provider commonpb.CloudProvider) (string, error)

func LowercaseAlphanumericFormatFunc

func LowercaseAlphanumericFormatFunc(s string) string

func RandomString

func RandomString(n int) string

func RemoveSpecialChars

func RemoveSpecialChars(a string) string

func StringInSlice

func StringInSlice(a string, list []string) bool

func UniqueId

func UniqueId(prefix string, suffix string, formatFunc FormatFunc) string

UniqueId generates a stable string composed of prefix+suffix and a 4 char hash. Prefix can be any size but will be sliced if bigger than 16 chars. Suffix can have 4 chars at most. Returns a string with at most 24 chars.

Types

type AwsResource

type AwsResource struct {
	output.TerraformResource `hcl:",squash"`
	Tags                     map[string]string `hcl:"tags" hcle:"omitempty"`
}

func NewAwsResource

func NewAwsResource(resourceId string, name string) *AwsResource

func NewAwsResourceWithIdOnly

func NewAwsResourceWithIdOnly(resourceId string) *AwsResource

func (*AwsResource) SetName

func (r *AwsResource) SetName(name string)

type AzResource

type AzResource struct {
	output.TerraformResource `hcl:",squash"`
	ResourceGroupName        string `hcl:"resource_group_name,expr" hcle:"omitempty"`
	Name                     string `hcl:"name" hcle:"omitempty"`
	Location                 string `hcl:"location" hcle:"omitempty"`
}

func NewAzResource

func NewAzResource(resourceId string, name string, rgName string, location string) *AzResource

func (*AzResource) SetName

func (r *AzResource) SetName(name string)

type FormatFunc

type FormatFunc func(s string) string

Jump to

Keyboard shortcuts

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