common

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

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",
	"eu-west-3":  "ami-0fc15d50d39e4503c",
	"us-east-1":  "ami-04ad2567c9e3d7893",
	"us-east-2":  "ami-04ad2567c9e3d7893",
	"us-west-1":  "ami-04ad2567c9e3d7893",
	"us-west-2":  "ami-04ad2567c9e3d7893",
	"eu-north-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[commonpb.Location]map[commonpb.CloudProvider][]string{
	commonpb.Location_EU_WEST_1: {
		AWS:   []string{"eu-west-1a", "eu-west-1b", "eu-west-1c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_EU_WEST_2: {
		AWS:   []string{"eu-west-2a", "eu-west-2b", "eu-west-2c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_EU_WEST_3: {
		AWS:   []string{"eu-west-3a", "eu-west-3b", "eu-west-3c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_US_EAST_1: {
		AWS:   []string{"us-east-1a", "us-east-1b", "us-east-1c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_US_EAST_2: {
		AWS:   []string{"us-east-2a", "us-east-2b", "us-east-2c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_US_WEST_1: {
		AWS:   []string{"us-west-1a", "us-west-1b"},
		AZURE: []string{"1", "2"},
	},
	commonpb.Location_US_WEST_2: {
		AWS:   []string{"us-west-1a", "us-west-1b", "us-west-1c"},
		AZURE: []string{"1", "2", "3"},
	},
	commonpb.Location_EU_NORTH_1: {
		AWS:   []string{"eu-north-1a", "eu-north-1b", "eu-north-1c"},
		AZURE: []string{"1", "2", "3"},
	},
}
View Source
var LOCATION = map[commonpb.Location]map[commonpb.CloudProvider]string{
	commonpb.Location_EU_WEST_1: {
		AWS:   "eu-west-1",
		AZURE: "northeurope",
	},
	commonpb.Location_EU_WEST_2: {
		AWS:   "eu-west-2",
		AZURE: "ukwest",
	},
	commonpb.Location_EU_WEST_3: {
		AWS:   "eu-west-3",
		AZURE: "francecentral",
	},

	commonpb.Location_US_EAST_1: {
		AWS:   "us-east-1",
		AZURE: "eastus",
	},
	commonpb.Location_US_EAST_2: {
		AWS:   "us-east-2",
		AZURE: "eastus2",
	},
	commonpb.Location_US_WEST_1: {
		AWS:   "us-west-1",
		AZURE: "westus2",
	},
	commonpb.Location_US_WEST_2: {
		AWS:   "us-west-2",
		AZURE: "westus3",
	},
	commonpb.Location_EU_NORTH_1: {
		AWS:   "eu-north-1",
		AZURE: "swedencentral",
	},
}

Functions

func AlphanumericFormatFunc

func AlphanumericFormatFunc(s string) string

func GetAvailabilityZone

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

func GetCloudLocation

func GetCloudLocation(location commonpb.Location, 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