Skip to content

Commit

Permalink
endpoints: support new endpoint format
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Jun 17, 2024
1 parent ca93718 commit e6cf41e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builder/common/access_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"net/http"
"os"
"strings"

"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
oscgo "github.com/outscale/osc-sdk-go/v2"
Expand Down Expand Up @@ -136,9 +137,13 @@ func (c *AccessConfig) NewOSCClientByRegion(region string) *OscClient {
SecretKey: c.SecretKey,
})
config.HTTPClient = skipClient
url := fmt.Sprintf("https://api.%s.%s", region, c.CustomEndpointOAPI)
if strings.HasPrefix(c.CustomEndpointOAPI, "http://") || strings.HasPrefix(c.CustomEndpointOAPI, "https://") {
url = fmt.Sprintf("%s/api/v1", c.CustomEndpointOAPI)
}
config.Servers = oscgo.ServerConfigurations{
{
URL: fmt.Sprintf("https://api.%s.%s", region, c.CustomEndpointOAPI),
URL: url,
Description: "Loaded from profile",
Variables: map[string]oscgo.ServerVariable{
"region": {
Expand Down

0 comments on commit e6cf41e

Please sign in to comment.