Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
cmd/plume: update Azure to build API options
Browse files Browse the repository at this point in the history
The updated New call for the API takes the API options which contains the
auth based options inside of them.
  • Loading branch information
arithx committed Nov 29, 2017
1 parent c5a5a18 commit 4b02752
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
17 changes: 4 additions & 13 deletions cmd/plume/prerelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"golang.org/x/net/context"
gs "google.golang.org/api/storage/v1"

"github.com/coreos/mantle/auth"
"github.com/coreos/mantle/platform/api/aws"
"github.com/coreos/mantle/platform/api/azure"
"github.com/coreos/mantle/sdk"
Expand Down Expand Up @@ -282,11 +281,6 @@ func azurePreRelease(ctx context.Context, client *http.Client, src *storage.Buck
return nil
}

prof, err := auth.ReadAzureProfile(azureProfile)
if err != nil {
return fmt.Errorf("failed reading Azure profile: %v", err)
}

// download azure vhd image and unzip it
vhdfile, err := getImageFile(client, src, spec.Azure.Image)
if err != nil {
Expand All @@ -307,14 +301,11 @@ func azurePreRelease(ctx context.Context, client *http.Client, src *storage.Buck
imageName := fmt.Sprintf("%s-%s-%s", spec.Azure.Offer, strings.Title(specChannel), specVersion)

for _, environment := range spec.Azure.Environments {
opt := prof.SubscriptionOptions(environment.SubscriptionName)
if opt == nil {
return fmt.Errorf("couldn't find subscription %q", environment.SubscriptionName)
}

// construct azure api client
plog.Printf("Creating Azure API from subscription %q endpoint %q", opt.SubscriptionID, opt.ManagementURL)
api, err := azure.New(opt)
api, err := azure.New(&azure.Options{
AzureProfile: azureProfile,
AzureSubscription: environment.SubscriptionName,
})
if err != nil {
return fmt.Errorf("failed to create Azure API: %v", err)
}
Expand Down
16 changes: 4 additions & 12 deletions cmd/plume/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"google.golang.org/api/compute/v1"
gs "google.golang.org/api/storage/v1"

"github.com/coreos/mantle/auth"
"github.com/coreos/mantle/platform/api/aws"
"github.com/coreos/mantle/platform/api/azure"
"github.com/coreos/mantle/platform/api/gcloud"
Expand Down Expand Up @@ -330,21 +329,14 @@ func doAzure(ctx context.Context, client *http.Client, src *storage.Bucket, spec
return
}

prof, err := auth.ReadAzureProfile(azureProfile)
if err != nil {
plog.Fatalf("failed reading Azure profile: %v", err)
}

// channel name should be caps for azure image
imageName := fmt.Sprintf("%s-%s-%s", spec.Azure.Offer, strings.Title(specChannel), specVersion)

for _, environment := range spec.Azure.Environments {
opt := prof.SubscriptionOptions(environment.SubscriptionName)
if opt == nil {
plog.Fatalf("couldn't find subscription %q", environment.SubscriptionName)
}

api, err := azure.New(opt)
api, err := azure.New(&azure.Options{
AzureProfile: azureProfile,
AzureSubscription: environment.SubscriptionName,
})
if err != nil {
plog.Fatalf("failed to create Azure API: %v", err)
}
Expand Down

0 comments on commit 4b02752

Please sign in to comment.