Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gltform package changes #12

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions pkg/gltform/gltform.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func GetGLConfig() (gljwt *Gljwt, err error) {
return gljwt, err
}

// WriteGLConfigLocally takes a map[string]interface{} which will normally come from a
// WriteGLConfig takes a map[string]interface{} which will normally come from a
// service block in the provider stanza and writes out a .gltform file in the directory
// from which terraform is being run. See the use of this function for bmaas in
// terraform-provider-hpegl.
func WriteGLConfigLocally(d map[string]interface{}) error {
// from which terraform is being run and in the home directory. See the use of this function
// for bmaas in terraform-provider-hpegl.
func WriteGLConfig(d map[string]interface{}) error {
config := &Gljwt{
// If space_name isn't present, we'll just write out ""
SpaceName: d["space_name"].(string),
Expand All @@ -59,9 +59,22 @@ func WriteGLConfigLocally(d map[string]interface{}) error {
return err
}

// Write out marshalled config into local .gltform
// Write out marshalled config into .gltform
homeDir, _ := os.UserHomeDir()
workingDir, _ := os.Getwd()
f, err := os.Create(filepath.Clean(filepath.Join(workingDir, fileExtension)))

for _, p := range []string{homeDir, workingDir} {
err = writeGLConfigToFile(b, p)
if err != nil {
break
}
}

return err
}

func writeGLConfigToFile(b []byte, dir string) error {
f, err := os.Create(filepath.Clean(filepath.Join(dir, fileExtension)))
if err != nil {
return err
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,17 @@ func Schema() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("HPEGL_IAM_SERVICE_URL", "https://client.greenlake.hpe.com/api/iam"),
Description: `The IAM service URL to be used to generate tokens, defaults to production GLC,
can be set by HPEGL_IAM_SERVICE_URL env-var`,
Description: `The IAM service URL to be used to generate tokens. In the case of API-vended service clients
(the default) then this should be set to the "issuer url" for the client. In the case of non-API-vended
service clients use the appropriate GL "client" URL. Can be set by HPEGL_IAM_SERVICE_URL env-var`,
}

providerSchema["api_vended_service_client"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("HPEGL_API_VENDED_SERVICE_CLIENT", true),
Description: ``,
Description: `Declare if the service-client being used is an API-vended one or not. Defaults to "true"
i.e. the client is API-vended. The value can be set using the HPEGL_API_VENDED_SERVICE_CLIENT env-var.`,
}

providerSchema["tenant_id"] = &schema.Schema{
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package utils

import (
"os"

"github.com/spf13/viper"
)

Expand Down