Add force flag to ignore commit check
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tom Neuber 2024-02-16 22:41:36 +01:00
parent 52703cb28f
commit 0ca7c11a23
Signed by: tom
GPG Key ID: F17EFE4272D89FF6
2 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import (
)
type AppSettings struct {
Force bool
GrafanaURL string
GrafanaToken string
GitBranch string
@ -19,13 +20,14 @@ type AppSettings struct {
}
var cliStruct struct {
Force bool `name:"force" short:"f" help:"Force git commits / ignore existence check."`
GrafanaURL string `name:"grafana-url" env:"GRAFANA_URL" help:"Grafana URL to access the API"`
GrafanaToken string `name:"grafana-auth-token" env:"GRAFANA_AUTH_TOKEN" help:"Grafana auth token to access the API"`
GitBranch string `name:"git-branch" env:"GIT_BRANCH" help:"Git branch name" default:"${default_git_branch}"`
GitRepoURL string `name:"git-repo-url" env:"GIT_REPO_URL" help:"Complete Git repository URL"`
GitUser string `name:"git-user" env:"GIT_USER" help:"Git username"`
GitEmail string `name:"git-email" env:"GIT_EMAIL" help:"Git email address"`
GitPass string `name:"git-pass" env:"GIT_PASS" help:"Git password"`
GitPass string `name:"git-pass" env:"GIT_PASS" help:"Git user password"`
GPGKey string `name:"signing-key" env:"GIT_SIGNING_KEY" help:"GPG signing key"`
}
@ -42,6 +44,7 @@ func Parse() *AppSettings {
validateFlags(ctx)
settings := &AppSettings{
Force: cliStruct.Force,
GrafanaURL: cliStruct.GrafanaURL,
GrafanaToken: cliStruct.GrafanaToken,
GitBranch: cliStruct.GitBranch,

View File

@ -52,7 +52,7 @@ func main() {
for _, version := range versions {
gitdata.UpdateVersion(version)
if gitdata.IsVersionCommitted(appSettings.GitBranch) {
if !appSettings.Force && gitdata.IsVersionCommitted(appSettings.GitBranch) {
fmt.Printf("%s/%s - %s: %s -> already committed\n", dashboardInfo.FolderTitle, dashboard.Title, version.CreatedBy, version.Message)
continue
}