helpers

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package helpers provides general purpose utility methods that are used throughout aks-engine codebase.

Index

Constants

View Source
const (
	// ValidityDuration specifies the duration an TLS certificate is valid
	ValidityDuration = time.Hour * 24 * 365 * 30
	// PkiKeySize is the size in bytes of the PKI key
	PkiKeySize = 4096
)
View Source
const (
	// SSHKeySize is the size (in bytes) of SSH key to create
	SSHKeySize = 4096
)

Variables

This section is empty.

Functions

func AcceleratedNetworkingSupported

func AcceleratedNetworkingSupported(sku string) bool

AcceleratedNetworkingSupported check if the VmSKU support the Accelerated Networking

func CreatePki

func CreatePki(extraFQDNs []string, extraIPs []net.IP, clusterDomain string, caPair *PkiKeyCertPair, masterCount int) (*PkiKeyCertPair, *PkiKeyCertPair, *PkiKeyCertPair, *PkiKeyCertPair, *PkiKeyCertPair, []*PkiKeyCertPair, error)

CreatePki creates PKI certificates

func CreateSSH

func CreateSSH(rg io.Reader, s *i18n.Translator) (privateKey *rsa.PrivateKey, publicKeyString string, err error)

CreateSSH creates an SSH key pair.

func CreateSaveSSH

func CreateSaveSSH(username, outputDirectory string, s *i18n.Translator) (privateKey *rsa.PrivateKey, publicKeyString string, err error)

CreateSaveSSH generates and stashes an SSH key pair.

func EnsureString added in v0.31.0

func EnsureString(val, defaultVal string) string

EnsureString returns an string for the default value. If val is not empty, return val If val is empty, return defaultVal

func EqualError

func EqualError(a, b error) bool

EqualError is a nil-safe method which reports whether errors a and b are considered equal. They're equal if both are nil, or both are not nil and a.Error() == b.Error().

func GetAzureLocations

func GetAzureLocations() []string

GetAzureLocations provides all azure regions in prod. Related powershell to refresh this list:

Get-AzureRmLocation | Select-Object -Property Location

func GetCloudTargetEnv

func GetCloudTargetEnv(location string) string

GetCloudTargetEnv determines and returns whether the region is a sovereign cloud which have their own data compliance regulations (China/Germany/USGov) or standard Azure public cloud

func GetDCOSMasterAllowedSizes

func GetDCOSMasterAllowedSizes() string

GetDCOSMasterAllowedSizes returns the master allowed sizes

func GetHomeDir

func GetHomeDir() string

GetHomeDir attempts to get the home dir from env

func GetKubernetesAllowedSizes

func GetKubernetesAllowedSizes() string

GetKubernetesAllowedSizes returns the allowed sizes for Kubernetes agent

func GetSizeMap

func GetSizeMap() string

GetSizeMap returns the size / storage map

func GetTargetEnv added in v0.31.0

func GetTargetEnv(location, customCloudName string) string

GetTargetEnv determines and returns whether the region is a sovereign cloud which have their own data compliance regulations (China/Germany/USGov) or standard Azure public cloud CustomCloudName is name of environment if customCloudProfile is provided, it will be empty string if customCloudProfile is empty. Because customCloudProfile is empty for deployment for AzurePublicCloud, AzureChinaCloud,AzureGermanCloud,AzureUSGovernmentCloud, The customCloudName value will be empty string for those clouds

func IsFalseBoolPointer

func IsFalseBoolPointer(b *bool) bool

IsFalseBoolPointer is a simple boolean helper function for boolean pointers

func IsTrueBoolPointer

func IsTrueBoolPointer(b *bool) bool

IsTrueBoolPointer is a simple boolean helper function for boolean pointers

func JSONMarshal

func JSONMarshal(content interface{}, escape bool) ([]byte, error)

JSONMarshal marshals JSON w/ optional SetEscapeHTML

func JSONMarshalIndent

func JSONMarshalIndent(content interface{}, prefix, indent string, escape bool) ([]byte, error)

JSONMarshalIndent marshals formatted JSON w/ optional SetEscapeHTML

func NormalizeAzureRegion

func NormalizeAzureRegion(name string) string

NormalizeAzureRegion returns a normalized Azure region with white spaces removed and converted to lower case

func PointerToBool

func PointerToBool(b bool) *bool

PointerToBool returns a pointer to a bool

func PointerToInt

func PointerToInt(i int) *int

PointerToInt returns a pointer to a int

func PointerToString

func PointerToString(s string) *string

PointerToString returns a pointer to a string

func ShellQuote

func ShellQuote(s string) string

ShellQuote returns a string that is enclosed within single quotes. If the string already has single quotes, they will be escaped.

Types

type FileSaver

type FileSaver struct {
	Translator *i18n.Translator
}

FileSaver represents the object that save string or byte data to file

func (*FileSaver) SaveFile

func (f *FileSaver) SaveFile(dir string, file string, data []byte) error

SaveFile saves binary data to file

func (*FileSaver) SaveFileString

func (f *FileSaver) SaveFileString(dir string, file string, data string) error

SaveFileString saves string to file

type PkiKeyCertPair

type PkiKeyCertPair struct {
	CertificatePem string
	PrivateKeyPem  string
}

PkiKeyCertPair represents an PKI public and private cert pair

func CreatePkiKeyCertPair

func CreatePkiKeyCertPair(commonName string) (*PkiKeyCertPair, error)

CreatePkiKeyCertPair generates a pair of PKI certificate and private key

Jump to

Keyboard shortcuts

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