Skip to content

Commit

Permalink
Merge pull request #278 from HewlettPackard/add-insecure
Browse files Browse the repository at this point in the history
Remove vmaas-api and add insecure flag
  • Loading branch information
reubenur-rahman authored Dec 12, 2024
2 parents ce2af3c + b41612d commit b47ddb3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions acc-dev-testcases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export HPEGL_VMAAS_SPACE_NAME=<vmaas_space_name>
```

By default the Terraform Provider will use the VMaaS production endpoint. To
use a non-production endpoint the `HPEGL_VMAAS_API_URL` must be set. For
use a non-production endpoint the `HPEGL_VMAAS_BROKER_URL` must be set. For
example:
```bash
export HPEGL_VMAAS_API_URL="https://iac-vmaas.intg.hpedevops.net"
export HPEGL_VMAAS_BROKER_URL="https://vmaas-broker.intg.hpedevops.net"
```

By Default acceptance test will run test cases from folder `acc-testcases`.
Expand Down
17 changes: 17 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package client

import (
"crypto/tls"
"fmt"
"net/http"
"os"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -59,6 +61,7 @@ func (i InitialiseClient) NewClient(r *schema.ResourceData) (interface{}, error)
// Create VMaas Client
client := new(Client)
iamVersion := r.Get("iam_version").(string)
insecure := vmaasProviderSettings[constants.INSECURE].(bool)
queryParam := map[string]string{
constants.LocationKey: vmaasProviderSettings[constants.LOCATION].(string),
}
Expand All @@ -80,6 +83,13 @@ func (i InitialiseClient) NewClient(r *schema.ResourceData) (interface{}, error)
DefaultHeader: brokerHeaders,
DefaultQueryParams: queryParam,
}
if insecure {
brokerCfgForAPIClient.HTTPClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
}
brokerApiClient := api_client.NewAPIClient(&brokerCfgForAPIClient)
utils.SetMetaFnAndVersion(brokerApiClient, r, 0)
// Create cmp client
Expand All @@ -88,6 +98,13 @@ func (i InitialiseClient) NewClient(r *schema.ResourceData) (interface{}, error)
DefaultHeader: map[string]string{},
DefaultQueryParams: map[string]string{},
}
if insecure {
cfg.HTTPClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
}
apiClient := api_client.NewAPIClient(&cfg)
err = utils.SetCMPVars(apiClient, brokerApiClient, &cfg)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/resources/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ func (r Registration) ProviderSchemaEntry() *schema.Resource {
DefaultFunc: schema.EnvDefaultFunc("HPEGL_VMAAS_SPACE_NAME", ""),
Description: "It can also be set with the HPEGL_VMAAS_SPACE_NAME env var. When `HPEGL_IAM_VERSION` is `glcs` it refers to IAM Space name of the GL VMaaS Service i.e., Default. When `HPEGL_IAM_VERSION` is `glp` it refers to GLP Workspace ID.",
},
constants.APIURL: {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("HPEGL_VMAAS_API_URL", constants.ServiceURL),
Description: "The URL to use for the VMaaS API, can also be set with the HPEGL_VMAAS_API_URL env var",
},
constants.BROKERRURL: {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("HPEGL_VMAAS_BROKER_URL", constants.BrokerURL),
Description: "The URL to use for the VMaaS Broker API, can also be set with the HPEGL_VMAAS_BROKER_URL env var",
},
constants.INSECURE: {
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("INSECURE", false),
Description: "Not to be used in production. To perform client connection ignoring TLS, it can also be set with the INSECURE env var",
},
},
}
}

0 comments on commit b47ddb3

Please sign in to comment.