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

Remove vmaas-api and add insecure flag #278

Merged
merged 1 commit into from
Dec 12, 2024
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
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",
},
},
}
}
Loading