Skip to content

Commit

Permalink
🐛 fix gitlab hcl discovery for groups (#1792)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Sep 19, 2023
1 parent b6729fc commit cc3ce67
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions motor/discovery/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,29 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, pCfg *provide
terraformCfg.Backend = providers.ProviderType_TERRAFORM
// git+https://gitlab.com/mondoolabs/example-gitlab.git
terraformCfg.Options["path"] = "git+" + project.HTTPURLToRepo

terraformCfg.Options = map[string]string{
"asset-type": "hcl",
"path": "git+" + project.HTTPURLToRepo,
}

if len(pCfg.Credentials) == 0 {
token := os.Getenv("GITLAB_TOKEN")
terraformCfg.Credentials = []*vault.Credential{{
Type: vault.CredentialType_password,
User: "oauth2",
Secret: []byte(token),
}}
} else {
// add oauth2 user to the credentials
for i := range pCfg.Credentials {
cred := pCfg.Credentials[i]
if cred.Type == vault.CredentialType_password {
cred.User = "oauth2"
}
}
}

assets, err := (&terraform_resolver.Resolver{}).Resolve(ctx, projectAsset, terraformCfg, credsResolver, sfn)
if err == nil && len(assets) > 0 {
for i := range assets {
Expand All @@ -183,6 +206,8 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, pCfg *provide
continue
}
}
} else {
log.Error().Err(err).Msg("error discovering terraform")
}
}
}
Expand Down

0 comments on commit cc3ce67

Please sign in to comment.