Skip to content

Commit

Permalink
stub stamps
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsai-czi committed Sep 11, 2023
1 parent 7c6b7a0 commit 13bf494
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions config/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ReadConfig(fs afero.Fs, b []byte, configFile string) (*Config, error) {
default:
return nil, errs.NewUserf("File type %s is not supported", ext)
}
c.RootPath = fs.Name()
c.GenerateStamp(fs, configFile)
return c, e
}

Expand Down Expand Up @@ -87,7 +87,6 @@ type Config struct {
Plugins Plugins `yaml:"plugins,omitempty"`
Version int `validate:"required,eq=2"`
TFE *TFE `yaml:"tfe,omitempty"`
RootPath string
Stamp Stamp
}

Expand Down
6 changes: 3 additions & 3 deletions config/v2/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,9 +850,9 @@ func ResolveCircleCI(commons ...Common) *CircleCI {
}

// TODO: move Stamp into Common to conform with other resolver functions
func ResolveDate(comm Common) string {
return comm.Stamp.Date
}
// func ResolveDate(comm Common) string {
// return comm.Stamp.Date
// }

func OwnerGetter(comm Common) *string {
return comm.Owner
Expand Down
17 changes: 10 additions & 7 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (p *Plan) buildTFE(c *v2.Config) (*TFEConfig, error) {
ExcludedGithubRequiredChecks: []string{},
AdditionalGithubRequiredChecks: []string{},
}
tfeConfig.ComponentCommon = resolveComponentCommon(c.Defaults.Common, c.Global.Common, c.TFE.Common)
tfeConfig.ComponentCommon = resolveComponentCommon(c.Stamp, c.Defaults.Common, c.Global.Common, c.TFE.Common)
tfeConfig.ModuleSource = c.TFE.ModuleSource
tfeConfig.ModuleName = c.TFE.ModuleName
if c.TFE.ProviderAliases != nil {
Expand Down Expand Up @@ -509,7 +509,7 @@ func (p *Plan) buildAccounts(c *v2.Config) map[string]Account {
for name, acct := range c.Accounts {
accountPlan := Account{}

accountPlan.ComponentCommon = resolveComponentCommon(defaults.Common, acct.Common)
accountPlan.ComponentCommon = resolveComponentCommon(c.Stamp, defaults.Common, acct.Common)
accountPlan.Name = name
accountPlan.Account = name // for backwards compat
accountPlan.Env = "accounts"
Expand Down Expand Up @@ -579,7 +579,7 @@ func (p *Plan) buildGlobal(conf *v2.Config) Component {
defaults := conf.Defaults
global := conf.Global

componentPlan.ComponentCommon = resolveComponentCommon(defaults.Common, global.Common)
componentPlan.ComponentCommon = resolveComponentCommon(conf.Stamp, defaults.Common, global.Common)

if componentPlan.ComponentCommon.Backend.Kind == BackendKindS3 {
componentPlan.ComponentCommon.Backend.S3.KeyPath = fmt.Sprintf("terraform/%s/global.tfstate", componentPlan.ComponentCommon.Project)
Expand Down Expand Up @@ -612,7 +612,7 @@ func (p *Plan) buildEnvs(conf *v2.Config) (map[string]Env, error) {
return nil, errs.WrapUser(fmt.Errorf("Component %s can't have same name as account", componentName), "Invalid component name")
}

componentPlan.ComponentCommon = resolveComponentCommon(defaults.Common, envConf.Common, componentConf.Common)
componentPlan.ComponentCommon = resolveComponentCommon(conf.Stamp, defaults.Common, envConf.Common, componentConf.Common)
accountRemoteStates := v2.ResolveOptionalStringSlice(v2.DependsOnAccountsGetter, defaults.Common, envConf.Common, componentConf.Common)
accountBackends := map[string]Backend{}
for k, v := range p.Accounts {
Expand Down Expand Up @@ -753,7 +753,7 @@ func resolveAWSProvider(commons ...v2.Common) (plan *AWSProvider, providers []AW
return
}

func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
func resolveComponentCommon(stamp v2.Stamp, commons ...v2.Common) ComponentCommon {

Check failure on line 756 in plan/plan.go

View workflow job for this annotation

GitHub Actions / lint

cyclomatic complexity 141 of func `resolveComponentCommon` is high (> 30) (gocyclo)

Check failure on line 756 in plan/plan.go

View workflow job for this annotation

GitHub Actions / lint

cyclomatic complexity 141 of func `resolveComponentCommon` is high (> 30) (gocyclo)
providerVersions := copyMap(utilityProviders)
awsPlan, additionalProviders, awsVersion := resolveAWSProvider(commons...)
if awsVersion != nil {
Expand Down Expand Up @@ -1287,8 +1287,11 @@ func resolveComponentCommon(commons ...v2.Common) ComponentCommon {
TravisCI: travisPlan,
CircleCI: circlePlan,
GitHubActionsCI: githubActionsPlan,
// TODO: resolve all other Stamp tags
Date: v2.ResolveDate(commons),
Date: stamp.Date,
FilePath: stamp.FilePath,
FoggUser: stamp.FoggUser,
GitRepository: stamp.GitRepository,
CommitHash: stamp.CommitHash,
}
}

Expand Down

0 comments on commit 13bf494

Please sign in to comment.