common

package
v0.0.0-...-f835774 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MonacoBaseFolder = "/tmp/monaco/"
View Source
const MonacoConfigFilename = "dynatrace/monaco.conf.yaml"

*

  • Defines the Dynatrace Configuration File structure and supporting Constants
View Source
const MonacoConfigFilenameLOCAL = "dynatrace/_monaco.conf.yaml"
View Source
const MonacoExecutable = "./monaco"

Variables

View Source
var RunLocal = (os.Getenv("ENV") == "local")
View Source
var RunLocalTest = (os.Getenv("ENV") == "localtest")

Functions

func CopyFileContentToDestination

func CopyFileContentToDestination(fileContent string, destination string) error

Copy file contents to a destination

func CopyFileContentsToMonacoProject

func CopyFileContentsToMonacoProject(fileContent string, keptnContext string) error

func CreateBaseFolderIfNotExist

func CreateBaseFolderIfNotExist() error

Create base folder for all monaco executions

func CreateTempFolderForKeptnContext

func CreateTempFolderForKeptnContext(keptnContext string) error

Create temp folder for keptn context to store project files

func DeleteTempFolderForKeptnContext

func DeleteTempFolderForKeptnContext(keptnContext string) error

Delete temp folder for cleanup

func ExecuteMonaco

func ExecuteMonaco(dtCredentials *DTCredentials, keptnContext string, data *keptnlib.ConfigurationChangeEventData, projects string, verbose bool, dryrun bool) error

func ExtractMonacoArchive

func ExtractMonacoArchive(keptnContext string) error

func ExtractZIPArchive

func ExtractZIPArchive(archiveFileName string, outputFolder string) error

func GenerateMonacoProjectStringFromMonacoConfig

func GenerateMonacoProjectStringFromMonacoConfig(monacoConfigFile *MonacoConfigFile, keptnEvent *BaseKeptnEvent) string

func GetConfigurationServiceURL

func GetConfigurationServiceURL() string

Request URL of configuration service

func GetKeptnResource

func GetKeptnResource(keptnEvent *BaseKeptnEvent, resourceURI string, logger *keptn.Logger) (string, error)

Downloads a resource from the Keptn Configuration Repo In RunLocal mode it gets it from the local disk In normal mode it first tries to find it on service level, then stage and then project level

func GetKubernetesClient

func GetKubernetesClient() (*kubernetes.Clientset, error)

func ParseUnixTimestamp

func ParseUnixTimestamp(timestamp string) (time.Time, error)

ParseUnixTimestamp parses a time stamp into Unix foramt

func PrepareFiles

func PrepareFiles(keptnEvent *BaseKeptnEvent, shkeptncontext string, logger *keptn.Logger) error

func ReplaceKeptnPlaceholders

func ReplaceKeptnPlaceholders(input string, keptnEvent *BaseKeptnEvent) string

replaces $ placeholders with actual values $CONTEXT, $EVENT, $SOURCE $PROJECT, $STAGE, $SERVICE, $DEPLOYMENT $TESTSTRATEGY $LABEL.XXXX -> will replace that with a label called XXXX $ENV.XXXX -> will replace that with an env variable called XXXX $SECRET.YYYY -> will replace that with the k8s secret called YYYY

func TimestampToString

func TimestampToString(time time.Time) string

TimestampToString converts time stamp into string

func Unzip

func Unzip(src string, dest string) ([]string, error)

func UploadKeptnResource

func UploadKeptnResource(contentToUpload []byte, remoteResourceURI string, keptnEvent *BaseKeptnEvent, logger *keptn.Logger) error

UploadKeptnResource uploads a file to the Keptn Configuration Service

Types

type BaseKeptnEvent

type BaseKeptnEvent struct {
	Context string
	Source  string
	Event   string

	Project            string
	Stage              string
	Service            string
	Deployment         string
	TestStrategy       string
	DeploymentStrategy string

	Image string
	Tag   string

	Labels map[string]string
}

type DTCredentials

type DTCredentials struct {
	Tenant   string `json:"DT_TENANT" yaml:"DT_TENANT"`
	ApiToken string `json:"DT_API_TOKEN" yaml:"DT_API_TOKEN"`
}

func GetDTCredentials

func GetDTCredentials(dynatraceSecretName string) (*DTCredentials, error)

*

  • Pulls the Dynatrace Credentials from the passed secret

type MonacoConfigFile

type MonacoConfigFile struct {
	SpecVersion string   `json:"spec_version" yaml:"spec_version"`
	DtCreds     string   `json:"dtCreds,omitempty" yaml:"dtCreds,omitempty"`
	Projects    []string `json:"projects,omitempty" yaml:"projects,omitempty"`
}

func GetMonacoConfig

func GetMonacoConfig(keptnEvent *BaseKeptnEvent, logger *keptn.Logger) (*MonacoConfigFile, error)

GetMonacoConfig loads monaco.conf for the current service

Jump to

Keyboard shortcuts

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