diff --git a/apply/apply.go b/apply/apply.go index f45bcae24..976c87ab1 100644 --- a/apply/apply.go +++ b/apply/apply.go @@ -8,10 +8,12 @@ import ( "io/fs" "net/url" "os" + "os/exec" "path/filepath" "regexp" "sort" "strings" + "text/template" "github.com/pkg/errors" "golang.org/x/exp/slices" @@ -521,10 +523,24 @@ func removeExtension(path string) string { return strings.TrimSuffix(path, filepath.Ext(path)) } +func getGitRemoteOriginURL(cwd ...string) string { + dir := "." + if len(cwd) > 0 { + dir = cwd[0] + } + cmd := exec.Command("git", "remote", "get-url", "--push", "origin") + cmd.Dir = dir + out, err := cmd.Output() + if err != nil { + logrus.Warnf("unable to get git output: %s", err) + return "" + } + return strings.TrimSpace(string(out)) +} + func applyTemplate(sourceFile io.Reader, commonTemplates fs.FS, dest afero.Fs, path string, overrides interface{}) error { - dir, _ := filepath.Split(path) - ospath := filepath.FromSlash(dir) - err := dest.MkdirAll(ospath, 0775) + dir := filepath.Dir(path) + err := dest.MkdirAll(dir, 0775) if err != nil { return errs.WrapUserf(err, "couldn't create %s directory", dir) } @@ -534,7 +550,14 @@ func applyTemplate(sourceFile io.Reader, commonTemplates fs.FS, dest afero.Fs, p if err != nil { return errs.WrapUser(err, "unable to open file") } - t, e := util.OpenTemplate(path, sourceFile, commonTemplates) + t, e := util.OpenTemplate(path, sourceFile, commonTemplates, []template.FuncMap{ + { + "cwd": func() string { + return filepath.Dir(writer.Name()) + }, + "git_origin": getGitRemoteOriginURL, + }, + }...) if e != nil { return e } diff --git a/apply/apply_test.go b/apply/apply_test.go index a57db174c..9b96cef60 100644 --- a/apply/apply_test.go +++ b/apply/apply_test.go @@ -29,6 +29,22 @@ func init() { logrus.SetFormatter(formatter) } +type testGitRemote struct { + path string + expectedRemote string +} + +func TestGetGitRemoveOriginURL(t *testing.T) { + r := require.New(t) + tests := []testGitRemote{ + {path: ".", expectedRemote: "git@github.com:chanzuckerberg/fogg"}, + } + for _, test := range tests { + remote := getGitRemoteOriginURL(test.path) + r.Equal(test.expectedRemote, remote) + } +} + func randomString(n int) string { var letter = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") diff --git a/config/v2/config.go b/config/v2/config.go index 3a49e9ea4..391ba236b 100644 --- a/config/v2/config.go +++ b/config/v2/config.go @@ -4,14 +4,12 @@ import ( "bytes" "encoding/json" "fmt" - "os/exec" "path/filepath" "strings" "time" "github.com/chanzuckerberg/fogg/errs" "github.com/chanzuckerberg/fogg/plugins" - "github.com/sirupsen/logrus" "github.com/spf13/afero" yaml "gopkg.in/yaml.v3" ) @@ -54,29 +52,10 @@ func (c *Config) Write(fs afero.Fs, path string) error { return encoder.Encode(c) } -func getGitRemoteOriginURL(cwd ...string) string { - dir := "." - if len(cwd) > 0 { - dir = cwd[0] - } - cmd := exec.Command("git", "remote", "get-url", "--push", "origin") - cmd.Dir = dir - out, err := cmd.Output() - if err != nil { - logrus.Warnf("unable to get git output: %s", err) - return "" - } - return strings.TrimSpace(string(out)) -} - // TODO: write out functions to generate tag data func (c *Config) GenerateStamp(fs afero.Fs, configFile string) { stamp := Stamp{} - stamp.Date = DateAsTag() - stamp.FilePath = fs.Name() stamp.FoggUser = "" - stamp.GitRepository = getGitRemoteOriginURL() - stamp.CommitHash = "" c.Stamp = stamp } @@ -87,11 +66,7 @@ func DateAsTag() string { } type Stamp struct { - Date string - FilePath string - FoggUser string - GitRepository string - CommitHash string + FoggUser string } type Config struct { diff --git a/config/v2/config_test.go b/config/v2/config_test.go index 8918d7686..9b5aea6b6 100644 --- a/config/v2/config_test.go +++ b/config/v2/config_test.go @@ -8,22 +8,6 @@ import ( "github.com/stretchr/testify/require" ) -type testGitRemote struct { - path string - expectedRemote string -} - -func TestGetGitRemoveOriginURL(t *testing.T) { - r := require.New(t) - tests := []testGitRemote{ - {path: ".", expectedRemote: "git@github.com:chanzuckerberg/fogg"}, - } - for _, test := range tests { - remote := getGitRemoteOriginURL(test.path) - r.Equal(test.expectedRemote, remote) - } -} - func TestReadConfig(t *testing.T) { r := require.New(t) diff --git a/plan/plan.go b/plan/plan.go index dfb828df0..4fb123488 100644 --- a/plan/plan.go +++ b/plan/plan.go @@ -1287,11 +1287,7 @@ func resolveComponentCommon(stamp v2.Stamp, commons ...v2.Common) ComponentCommo TravisCI: travisPlan, CircleCI: circlePlan, GitHubActionsCI: githubActionsPlan, - Date: stamp.Date, - FilePath: stamp.FilePath, FoggUser: stamp.FoggUser, - GitRepository: stamp.GitRepository, - CommitHash: stamp.CommitHash, } } diff --git a/templates/templates/component/terraform/fogg.tf.tmpl b/templates/templates/component/terraform/fogg.tf.tmpl index cf815456b..fb461878e 100644 --- a/templates/templates/component/terraform/fogg.tf.tmpl +++ b/templates/templates/component/terraform/fogg.tf.tmpl @@ -123,17 +123,15 @@ variable "owner" { variable "tags" { type = object({project: string, env: string, service: string, owner: string, managedBy: string}) default = { - project = "{{ .Project }}" - env = "{{ .Env }}" - service = "{{ .Name }}" - owner = "{{ .Owner }}" - date = "{{ .Date }}" - filePath = "{{ .FilePath }}" - foggUser = "{{ .FoggUser }}" - gitRepository = "{{ .GitRepository }}" - commitHash = "{{ .CommitHash }}" - managedBy = "terraform" - + project = "{{ .Project }}" + env = "{{ .Env }}" + service = "{{ .Name }}" + owner = "{{ .Owner }}" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "{{ cwd }}" + foggUser = "{{ .FoggUser }}" + gitRepository = "{{ git_origin }}" + managedBy = "terraform" } } diff --git a/testdata/auth0_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/auth0_provider_yaml/terraform/accounts/foo/fogg.tf index c31c422a0..e7ab00abf 100644 --- a/testdata/auth0_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/auth0_provider_yaml/terraform/accounts/foo/fogg.tf @@ -109,16 +109,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/auth0_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/auth0_provider_yaml/terraform/envs/bar/bam/fogg.tf index 66198acb4..2f205ceb9 100644 --- a/testdata/auth0_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/auth0_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -104,16 +104,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/auth0_provider_yaml/terraform/global/fogg.tf b/testdata/auth0_provider_yaml/terraform/global/fogg.tf index 1f0b831fa..a169f767d 100644 --- a/testdata/auth0_provider_yaml/terraform/global/fogg.tf +++ b/testdata/auth0_provider_yaml/terraform/global/fogg.tf @@ -104,16 +104,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf index d67f5144e..b5bfbbd7f 100644 --- a/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/bless_provider_yaml/terraform/accounts/foo/fogg.tf @@ -122,16 +122,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf index e8e2e475e..1eac83cd2 100644 --- a/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/bless_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -117,16 +117,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/bless_provider_yaml/terraform/global/fogg.tf b/testdata/bless_provider_yaml/terraform/global/fogg.tf index e8a288454..7d771fec3 100644 --- a/testdata/bless_provider_yaml/terraform/global/fogg.tf +++ b/testdata/bless_provider_yaml/terraform/global/fogg.tf @@ -117,16 +117,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/circleci/terraform/global/fogg.tf b/testdata/circleci/terraform/global/fogg.tf index e0eea7f61..4ef54fd87 100644 --- a/testdata/circleci/terraform/global/fogg.tf +++ b/testdata/circleci/terraform/global/fogg.tf @@ -93,16 +93,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/github_actions/terraform/global/fogg.tf b/testdata/github_actions/terraform/global/fogg.tf index e0eea7f61..4ef54fd87 100644 --- a/testdata/github_actions/terraform/global/fogg.tf +++ b/testdata/github_actions/terraform/global/fogg.tf @@ -93,16 +93,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf index d8f9b670c..9e646b8a6 100644 --- a/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/github_provider_yaml/terraform/accounts/foo/fogg.tf @@ -110,16 +110,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf index 5ebfecfe5..b35c95cd5 100644 --- a/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/github_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -105,16 +105,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/github_provider_yaml/terraform/global/fogg.tf b/testdata/github_provider_yaml/terraform/global/fogg.tf index 938944edc..8b2b4cc6f 100644 --- a/testdata/github_provider_yaml/terraform/global/fogg.tf +++ b/testdata/github_provider_yaml/terraform/global/fogg.tf @@ -105,16 +105,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf index b6dd894f3..2cbc5bd75 100644 --- a/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/okta_provider_yaml/terraform/accounts/foo/fogg.tf @@ -110,16 +110,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf index 0309be550..18f752776 100644 --- a/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/okta_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -105,16 +105,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/okta_provider_yaml/terraform/global/fogg.tf b/testdata/okta_provider_yaml/terraform/global/fogg.tf index 7815cb6d9..06cbbe5d0 100644 --- a/testdata/okta_provider_yaml/terraform/global/fogg.tf +++ b/testdata/okta_provider_yaml/terraform/global/fogg.tf @@ -105,16 +105,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foofoo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foofoo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/remote_backend_yaml/terraform/accounts/acct1/fogg.tf b/testdata/remote_backend_yaml/terraform/accounts/acct1/fogg.tf index e9e707a2b..dc61d97ae 100644 --- a/testdata/remote_backend_yaml/terraform/accounts/acct1/fogg.tf +++ b/testdata/remote_backend_yaml/terraform/accounts/acct1/fogg.tf @@ -96,16 +96,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "accounts" - service = "acct1" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "accounts" + service = "acct1" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/acct1" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/remote_backend_yaml/terraform/global/fogg.tf b/testdata/remote_backend_yaml/terraform/global/fogg.tf index 06bb31ce6..4597ff52f 100644 --- a/testdata/remote_backend_yaml/terraform/global/fogg.tf +++ b/testdata/remote_backend_yaml/terraform/global/fogg.tf @@ -91,16 +91,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf index e382ef457..43b6d9289 100644 --- a/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/snowflake_provider_yaml/terraform/accounts/foo/fogg.tf @@ -111,16 +111,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf index f5dd7eef2..7429ed3f2 100644 --- a/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/snowflake_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -106,16 +106,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf index ef49e4c54..440f948e6 100644 --- a/testdata/snowflake_provider_yaml/terraform/global/fogg.tf +++ b/testdata/snowflake_provider_yaml/terraform/global/fogg.tf @@ -106,16 +106,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_config/terraform/accounts/account/fogg.tf b/testdata/tfe_config/terraform/accounts/account/fogg.tf index a7c50a032..f9537e7ab 100644 --- a/testdata/tfe_config/terraform/accounts/account/fogg.tf +++ b/testdata/tfe_config/terraform/accounts/account/fogg.tf @@ -121,16 +121,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "accounts" - service = "account" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "accounts" + service = "account" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/account" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_config/terraform/envs/staging/comp1/fogg.tf b/testdata/tfe_config/terraform/envs/staging/comp1/fogg.tf index 4f0fb8cf2..b12004b97 100644 --- a/testdata/tfe_config/terraform/envs/staging/comp1/fogg.tf +++ b/testdata/tfe_config/terraform/envs/staging/comp1/fogg.tf @@ -118,16 +118,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "staging" - service = "comp1" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "staging" + service = "comp1" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/comp1" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_config/terraform/global/fogg.tf b/testdata/tfe_config/terraform/global/fogg.tf index d787bfa15..34cbec526 100644 --- a/testdata/tfe_config/terraform/global/fogg.tf +++ b/testdata/tfe_config/terraform/global/fogg.tf @@ -116,16 +116,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_config/terraform/tfe/fogg.tf b/testdata/tfe_config/terraform/tfe/fogg.tf index f15abaae6..13a5656c9 100644 --- a/testdata/tfe_config/terraform/tfe/fogg.tf +++ b/testdata/tfe_config/terraform/tfe/fogg.tf @@ -123,16 +123,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/tfe" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf index eae42c9c1..44ff5b607 100644 --- a/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/tfe_provider_yaml/terraform/accounts/foo/fogg.tf @@ -108,16 +108,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf index 4f973a802..0da99264e 100644 --- a/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf +++ b/testdata/tfe_provider_yaml/terraform/envs/bar/bam/fogg.tf @@ -93,16 +93,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "bar" - service = "bam" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "bar" + service = "bam" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/bar/bam" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/tfe_provider_yaml/terraform/global/fogg.tf b/testdata/tfe_provider_yaml/terraform/global/fogg.tf index b958cd272..e55a8b910 100644 --- a/testdata/tfe_provider_yaml/terraform/global/fogg.tf +++ b/testdata/tfe_provider_yaml/terraform/global/fogg.tf @@ -103,16 +103,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf index 44a29bea8..162a9c590 100644 --- a/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf +++ b/testdata/v2_full_yaml/terraform/accounts/bar/fogg.tf @@ -265,16 +265,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "accounts" - service = "bar" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "accounts" + service = "bar" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/bar" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf index 508f74ac2..814443c1d 100644 --- a/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/v2_full_yaml/terraform/accounts/foo/fogg.tf @@ -135,16 +135,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf index b1c83ce6f..0aab18b69 100644 --- a/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/prod/datadog/fogg.tf @@ -128,16 +128,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "prod" - service = "datadog" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "prod" + service = "datadog" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/prod/datadog" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf index da80a149f..3ba7253ce 100644 --- a/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/prod/hero/fogg.tf @@ -136,16 +136,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "prod" - service = "hero" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "prod" + service = "hero" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/prod/hero" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/prod/okta/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/okta/fogg.tf index 72fc1af89..558176e28 100644 --- a/testdata/v2_full_yaml/terraform/envs/prod/okta/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/prod/okta/fogg.tf @@ -131,16 +131,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "prod" - service = "okta" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "prod" + service = "okta" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/prod/okta" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/prod/sentry/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/sentry/fogg.tf index 0a81b3d18..ebcb323e5 100644 --- a/testdata/v2_full_yaml/terraform/envs/prod/sentry/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/prod/sentry/fogg.tf @@ -129,16 +129,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "prod" - service = "sentry" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "prod" + service = "sentry" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/prod/sentry" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf b/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf index 7a006b4d9..9f6dda62d 100644 --- a/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/prod/vpc/fogg.tf @@ -119,16 +119,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "prod" - service = "vpc" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "prod" + service = "vpc" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/prod/vpc" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf index 60f4400e2..9a0bf761f 100644 --- a/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/staging/comp1/fogg.tf @@ -117,16 +117,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "comp1" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "comp1" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/comp1" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf index bc7195323..0a5439c35 100644 --- a/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/staging/comp2/fogg.tf @@ -117,16 +117,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "comp2" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "comp2" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/comp2" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/staging/k8s-comp/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/k8s-comp/fogg.tf index dfbd3a9f4..2f42ae313 100644 --- a/testdata/v2_full_yaml/terraform/envs/staging/k8s-comp/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/staging/k8s-comp/fogg.tf @@ -135,16 +135,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "k8s-comp" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "k8s-comp" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/k8s-comp" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf index 0d708f722..b013e8b52 100644 --- a/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf +++ b/testdata/v2_full_yaml/terraform/envs/staging/vpc/fogg.tf @@ -117,16 +117,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "vpc" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "vpc" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/vpc" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_full_yaml/terraform/global/fogg.tf b/testdata/v2_full_yaml/terraform/global/fogg.tf index 5da869b8f..94472008f 100644 --- a/testdata/v2_full_yaml/terraform/global/fogg.tf +++ b/testdata/v2_full_yaml/terraform/global/fogg.tf @@ -119,16 +119,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf b/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf index e0eea7f61..4ef54fd87 100644 --- a/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf +++ b/testdata/v2_minimal_valid_yaml/terraform/global/fogg.tf @@ -93,16 +93,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "foo" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "foo" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/accounts/bar/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/accounts/bar/fogg.tf index ab3093f6e..f7889e2e3 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/accounts/bar/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/accounts/bar/fogg.tf @@ -96,16 +96,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "accounts" - service = "bar" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "accounts" + service = "bar" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/bar" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/accounts/foo/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/accounts/foo/fogg.tf index 5900537e0..3c80c09c4 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/accounts/foo/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/accounts/foo/fogg.tf @@ -96,16 +96,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "accounts" - service = "foo" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "accounts" + service = "foo" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/accounts/foo" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp1/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp1/fogg.tf index 9ab13c2e3..105d14baa 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp1/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp1/fogg.tf @@ -91,16 +91,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "comp1" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "comp1" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/comp1" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp2/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp2/fogg.tf index fe9025236..b17ab9a41 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp2/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/comp2/fogg.tf @@ -91,16 +91,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "comp2" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "comp2" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/comp2" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf index e37ee13d0..dec1994c7 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/envs/staging/vpc/fogg.tf @@ -91,16 +91,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "staging" - service = "vpc" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "staging" + service = "vpc" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/envs/staging/vpc" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf b/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf index 42adfc1db..2976541e1 100644 --- a/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf +++ b/testdata/v2_no_aws_provider_yaml/terraform/global/fogg.tf @@ -91,16 +91,15 @@ variable "owner" { variable "tags" { type = object({ project : string, env : string, service : string, owner : string, managedBy : string }) default = { - project = "proj" - env = "" - service = "global" - owner = "foo@example.com" - date = "2023-09-13" - filePath = "BasePathFs" - foggUser = "" - gitRepository = "git@github.com:chanzuckerberg/fogg" - commitHash = "" - managedBy = "terraform" + project = "proj" + env = "" + service = "global" + owner = "foo@example.com" + terraformLastApplyTime = timestamp() + terraformWorkspaceDir = "/terraform/global" + foggUser = "" + gitRepository = "git@github.com:chanzuckerberg/fogg" + managedBy = "terraform" } } # tflint-ignore: terraform_unused_declarations diff --git a/util/template.go b/util/template.go index ae1c8ba40..d9fd6452e 100644 --- a/util/template.go +++ b/util/template.go @@ -39,12 +39,18 @@ func avail(name string, data interface{}) bool { } // OpenTemplate will read `source` for a template, parse, configure and return a template.Template -func OpenTemplate(label string, source io.Reader, templates fs.FS) (*template.Template, error) { +func OpenTemplate(label string, source io.Reader, templates fs.FS, optionalFuncMaps ...template.FuncMap) (*template.Template, error) { // TODO we should probably cache these rather than open and parse them for every apply funcs := sprig.TxtFuncMap() funcs["dict"] = dict funcs["avail"] = avail + for _, fm := range optionalFuncMaps { + for k, v := range fm { + funcs[k] = v + } + } + s, err := io.ReadAll(source) if err != nil { return nil, errs.WrapInternal(err, "could not read template")