Skip to content

Commit

Permalink
feat(mtaBuild): Add enableSetTimestamp parameter (#4996)
Browse files Browse the repository at this point in the history
* add enableSetTimestamp param to mtaBuild

* make default: true

* go generate

* update unit tests

---------

Co-authored-by: jliempt <>
  • Loading branch information
jliempt authored Jul 29, 2024
1 parent 8c79fce commit 36f8d35
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
6 changes: 4 additions & 2 deletions cmd/mtaBuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ func runMtaBuild(config mtaBuildOptions,
log.Entry().Infof("\"%s\" file found in project sources", mtaYamlFile)
}

if err = setTimeStamp(mtaYamlFile, utils); err != nil {
return err
if config.EnableSetTimestamp {
if err = setTimeStamp(mtaYamlFile, utils); err != nil {
return err
}
}

mtarName, isMtarNativelySuffixed, err := getMtarName(config, mtaYamlFile, utils)
Expand Down
11 changes: 11 additions & 0 deletions cmd/mtaBuild_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions cmd/mtaBuild_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build unit
// +build unit

package cmd

import (
Expand Down Expand Up @@ -98,7 +95,7 @@ func TestMtaBuild(t *testing.T) {

utilsMock := newMtaBuildTestUtilsBundle()

options := mtaBuildOptions{ApplicationName: "myApp", Platform: "CF", MtarName: "myName", Source: "./", Target: "./"}
options := mtaBuildOptions{ApplicationName: "myApp", Platform: "CF", MtarName: "myName", Source: "./", Target: "./", EnableSetTimestamp: true}

utilsMock.AddFile("package.json", []byte("{\"name\": \"myName\", \"version\": \"1.2.3\"}"))

Expand Down Expand Up @@ -149,7 +146,7 @@ func TestMtaBuild(t *testing.T) {

utilsMock := newMtaBuildTestUtilsBundle()

options := mtaBuildOptions{ApplicationName: "myApp"}
options := mtaBuildOptions{ApplicationName: "myApp", EnableSetTimestamp: true}

utilsMock.AddFile("package.json", []byte("{\"name\": \"myName\", \"version\": \"1.2.3\"}"))
utilsMock.AddFile("mta.yaml", []byte("already there with-${timestamp}"))
Expand Down
8 changes: 8 additions & 0 deletions resources/metadata/mtaBuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ spec:
- STAGES
- PARAMETERS
default: false
- name: enableSetTimestamp
type: bool
description: Enables setting the timestamp in the `mta.yaml` when it contains `${timestamp}`. Disable this when you want the MTA Deploy Service to do this instead.
scope:
- STEPS
- STAGES
- PARAMETERS
default: true
outputs:
resources:
- name: commonPipelineEnvironment
Expand Down

0 comments on commit 36f8d35

Please sign in to comment.