Skip to content

Commit

Permalink
Fix tf acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
mahesh-hpe committed Jun 12, 2024
1 parent c9f4c98 commit 4a0e0c2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/HewlettPackard/hpegl-vmaas-terraform-resources
go 1.21

require (
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611110535-bde9db20c238
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611163337-ef8debaa03a8
github.com/golang/mock v1.6.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611110535-bde9db20c238 h1:DSFTAcz5MaBeUz4hsvzr/we4F1P4ZBtdfiVulnFbaJ8=
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611110535-bde9db20c238/go.mod h1:UzXizYR6sUVsvDRMcLC2E4eabJsPH/3nM8rlKL2BLSc=
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611163337-ef8debaa03a8 h1:WHn8kRFLG6Fzy/DEDt30Vk1uFoUJ0Kzc8pSjIExGMss=
github.com/HewlettPackard/hpegl-vmaas-cmp-go-sdk v0.1.9-0.20240611163337-ef8debaa03a8/go.mod h1:UzXizYR6sUVsvDRMcLC2E4eabJsPH/3nM8rlKL2BLSc=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down
4 changes: 2 additions & 2 deletions internal/acceptance_test/helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2021 Hewlett Packard Enterprise Development LP
// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

package acceptancetest

Expand Down Expand Up @@ -31,7 +31,6 @@ func getAPIClient() (*api_client.APIClient, api_client.Configuration) {
constants.SpaceKey: os.Getenv("HPEGL_VMAAS_SPACE_NAME"),
},
}

apiClient := api_client.NewAPIClient(&cfg)
err := apiClient.SetMeta(nil, func(ctx *context.Context, meta interface{}) {
d := &utils.ResourceData{
Expand All @@ -42,6 +41,7 @@ func getAPIClient() (*api_client.APIClient, api_client.Configuration) {
"user_secret": os.Getenv("HPEGL_USER_SECRET"),
"api_vended_service_client": true,
"iam_token": os.Getenv("HPEGL_IAM_TOKEN"),
"iam_version": utils.GetEnv("HPEGL_IAM_VERSION", "glcs"),
},
}
if utils.GetEnvBool(constants.MockIAMKey) {
Expand Down
24 changes: 18 additions & 6 deletions pkg/atf/constants.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package atf

const providerStanza = `
provider hpegl {
vmaas {
}
}
`
import "fmt"

// const providerStanza = `
// provider hpegl {
// vmaas {
// }
// }
// `

var accTestPath = "../../acc-testcases"

Expand All @@ -16,3 +18,13 @@ const (

randMaxLimit = 999999
)

func GetProviderStanza(alias string) string {
return fmt.Sprintf(`
provider hpegl {
alias = "%s"
vmaas {
}
}
`, alias)
}
3 changes: 2 additions & 1 deletion pkg/atf/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,11 @@ func (r *reader) parseConfig(v *viper.Viper) []accConfig {
configs[i].config = fmt.Sprintf(`
%s
%s "%s" "tf_%s" {
provider = hpegl.%s
%s
}
`,
providerStanza, getType(r.isResource), r.name, tfKey, tfConfig,
GetProviderStanza(tfKey), getType(r.isResource), r.name, tfKey, tfKey, tfConfig,
)
r.parseRegex(v, i)
configs[i].validations = r.parseValidations(v, i)
Expand Down
10 changes: 9 additions & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2021 Hewlett Packard Enterprise Development LP
// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP

package utils

Expand Down Expand Up @@ -76,3 +76,11 @@ func GetEnvBool(key string) bool {

return value
}

func GetEnv(key, defaultVal string) string {
value, exists := os.LookupEnv(key)
if !exists {
value = defaultVal
}
return value
}

0 comments on commit 4a0e0c2

Please sign in to comment.