Documentation ¶
Index ¶
- Constants
- Variables
- func CopyFileContentToDestination(fileContent string, destination string) error
- func CopyFileContentsToMonacoProject(fileContent string, keptnEvent *BaseKeptnEvent) error
- func CreateBaseFolderIfNotExist() error
- func CreateTempFolderForKeptnContext(keptnEvent *BaseKeptnEvent) (error, string)
- func DeleteTempFolderForKeptnContext(keptnEvent *BaseKeptnEvent) error
- func DownloadAllFilesFromSubfolder(keptnEvent *BaseKeptnEvent, projectsPath string) error
- func DownloadAndExtractMonacoZip(keptnEvent *BaseKeptnEvent, zipFilePath string) error
- func ExecuteMonaco(dtCredentials *DTCredentials, keptnEvent *BaseKeptnEvent, projects string, ...) error
- func ExtractMonacoArchive(keptnEvent *BaseKeptnEvent) error
- func ExtractZIPArchive(archiveFileName string, outputFolder string) error
- func FileExists(filename string) bool
- func GenerateMonacoProjectStringFromMonacoConfig(monacoConfigFile *MonacoConfigFile, keptnEvent *BaseKeptnEvent) string
- func GetAllKeptnResources(project string, stage string, service string, inheritResources bool, ...) (int, error)
- func GetConfigurationServiceURL() string
- func GetKeptnResource(keptnEvent *BaseKeptnEvent, resourceURI string) (string, error)
- func GetKubernetesClient() (*kubernetes.Clientset, error)
- func GetTempMonacoFolder(keptnEvent *BaseKeptnEvent) string
- func ParseUnixTimestamp(timestamp string) (time.Time, error)
- func PrepareFiles(keptnEvent *BaseKeptnEvent) error
- func ReplaceKeptnPlaceholders(input string, keptnEvent *BaseKeptnEvent) string
- func TimestampToString(time time.Time) string
- func Unzip(src string, dest string) ([]string, error)
- func UploadKeptnResource(contentToUpload []byte, remoteResourceURI string, keptnEvent *BaseKeptnEvent) error
- type BaseKeptnEvent
- type DTCredentials
- type MonacoConfigFile
Constants ¶
const MonacoBaseFolder = "tmp/monaco/"
const MonacoConfigFilename = "dynatrace/monaco.conf.yaml"
*
- Defines the Dynatrace Configuration File structure and supporting Constants
const MonacoConfigFilenameLOCAL = "dynatrace/_monaco.conf.yaml"
const MonacoExecutable = "./monaco"
const MonacoProjectsSubfolder = "projects"
Variables ¶
var RunLocal = (os.Getenv("ENV") == "local")
var RunLocalTest = (os.Getenv("ENV") == "localtest")
Functions ¶
func CopyFileContentToDestination ¶
Copy file contents to a destination
func CopyFileContentsToMonacoProject ¶
func CopyFileContentsToMonacoProject(fileContent string, keptnEvent *BaseKeptnEvent) error
func CreateBaseFolderIfNotExist ¶
func CreateBaseFolderIfNotExist() error
Create base folder for all monaco executions
func CreateTempFolderForKeptnContext ¶
func CreateTempFolderForKeptnContext(keptnEvent *BaseKeptnEvent) (error, string)
Create temp folder for keptn context to store project files
func DeleteTempFolderForKeptnContext ¶
func DeleteTempFolderForKeptnContext(keptnEvent *BaseKeptnEvent) error
Delete temp folder for cleanup
func DownloadAllFilesFromSubfolder ¶
func DownloadAllFilesFromSubfolder(keptnEvent *BaseKeptnEvent, projectsPath string) error
*
- Tries to download all files under the projectsPaths it into a unique folder based on the keptn context id
func DownloadAndExtractMonacoZip ¶
func DownloadAndExtractMonacoZip(keptnEvent *BaseKeptnEvent, zipFilePath string) error
*
- Tries to download the zip file and if it exists extracts it into a unique folder based on the keptn context id
func ExecuteMonaco ¶
func ExecuteMonaco(dtCredentials *DTCredentials, keptnEvent *BaseKeptnEvent, projects string, verbose bool, dryrun bool) error
func ExtractMonacoArchive ¶
func ExtractMonacoArchive(keptnEvent *BaseKeptnEvent) error
func ExtractZIPArchive ¶
func GenerateMonacoProjectStringFromMonacoConfig ¶
func GenerateMonacoProjectStringFromMonacoConfig(monacoConfigFile *MonacoConfigFile, keptnEvent *BaseKeptnEvent) string
func GetAllKeptnResources ¶
func GetAllKeptnResources(project string, stage string, service string, inheritResources bool, resourceUriFolderOfInterest string, localDirectory string) (int, error)
* This function will download ALL Resources from Keptn's Configuration Repository where the name starts with 'resourceUriFolderOfInterest'. This for instance allows us to download all files in the /dynatrace/projects folders * * Parameters: * project, stage, string: reference the keptn repo * inheritResources: if true it will download all resources from service, stage and project level - otherwise just from service level * resourceUriFolderOfInterest: will only download resources where the resourceUri contains that value, e.g: "/jmeter" and then also stores the downloaded files under that prefix * localDirectory: the local directory to store these downloaded files * * Return: * no of resources: total number of downloaded resources * error: any error that occured
func GetConfigurationServiceURL ¶
func GetConfigurationServiceURL() string
Request URL of configuration service
func GetKeptnResource ¶
func GetKeptnResource(keptnEvent *BaseKeptnEvent, resourceURI string) (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 GetTempMonacoFolder ¶
func GetTempMonacoFolder(keptnEvent *BaseKeptnEvent) string
returns the tmp folder for this run, e.g: tmp/KEPTNCONTEXT-STAGE
func ParseUnixTimestamp ¶
ParseUnixTimestamp parses a time stamp into Unix foramt
func PrepareFiles ¶
func PrepareFiles(keptnEvent *BaseKeptnEvent) 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 ¶
TimestampToString converts time stamp into string
func UploadKeptnResource ¶
func UploadKeptnResource(contentToUpload []byte, remoteResourceURI string, keptnEvent *BaseKeptnEvent) error
UploadKeptnResource uploads a file to the Keptn Configuration Service
Types ¶
type BaseKeptnEvent ¶
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) (*MonacoConfigFile, error)
GetMonacoConfig loads monaco.conf for the current service