Functions
Functions¶
Both templates and triggers have access to the set of functions.
Trigger example:
name: app-operation-stuck
condition: time.Now().Sub(time.Parse(app.status.operationState.startedAt)).Minutes() >= 5
template: my-template
Template example:
name: my-template
title: Application {{.app.metadata.name}} sync status is {{.app.status.sync.status}}
body: "Author: {{(call .repo.GetCommitMetadata .app.status.sync.revision).Author}}"
time¶
Time related functions.
time.Now() Time
Executes function built-in Golang time.Now function. Returns an instance of Golang Time.
time.Parse(val string) Time
Parses specified string using RFC3339 layout. Returns an instance of Golang Time.
repo¶
Functions that provide additional information about Application source repository.
repo.RepoURLToHTTPS(url string) string
Transforms given GIT URL into HTTPs format.
repo.FullNameByRepoURL(url string) string
Returns repository URL full name (<owner>/<repoName>)
. Currently supports only Github, Gitlab and Bitbucket.
repo.GetCommitMetadata(sha string) CommitMetadata
Returns commit metadata. The commit must belong to the application source repository. CommitMetadata
fields:
Message string
commit messageAuthor string
- commit authorDate time.Time
- commit creation dateTags []string
- Associated tags