Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
update azure-sdk-for-go to v19 (#3608)
Browse files Browse the repository at this point in the history
# Conflicts:
#	Gopkg.lock
#	Gopkg.toml
  • Loading branch information
jackfrancis committed Aug 3, 2018
1 parent 293adfd commit a4975a8
Show file tree
Hide file tree
Showing 262 changed files with 91,349 additions and 29,290 deletions.
35 changes: 19 additions & 16 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ required = [

[[constraint]]
name = "github.com/Azure/azure-sdk-for-go"
version = "~12.4.0-beta"
version = "~19.0.0"

[[constraint]]
name = "github.com/Azure/go-autorest"
version = "~9.10.0"
version = "~10.14.0"

[[constraint]]
name = "github.com/Jeffail/gabs"
Expand Down Expand Up @@ -114,15 +114,15 @@ required = [
name = "github.com/onsi/ginkgo"
version = "v1.6.0"

# Apply workaround from https://github.com/golang/dep/issues/1799
[[constraint]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"

[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "gopkg.in/ini.v1"
version = "1.38.1"
version = "1.38.1"

# Apply workaround from https://github.com/golang/dep/issues/1799
[[constraint]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"
4 changes: 3 additions & 1 deletion cmd/dcos-upgrade.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"encoding/json"
"io/ioutil"
"os"
Expand Down Expand Up @@ -121,7 +122,8 @@ func (uc *dcosUpgradeCmd) loadCluster(cmd *cobra.Command) error {
return errors.Wrap(err, "Failed to get client")
}

_, err = uc.client.EnsureResourceGroup(uc.resourceGroupName, uc.location, nil)
ctx := context.Background()
_, err = uc.client.EnsureResourceGroup(ctx, uc.resourceGroupName, uc.location, nil)
if err != nil {
return errors.Wrap(err, "Error ensuring resource group")
}
Expand Down
15 changes: 9 additions & 6 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"fmt"
"io/ioutil"
"math/rand"
Expand All @@ -21,7 +22,7 @@ import (
"github.com/Azure/acs-engine/pkg/armhelpers"
"github.com/Azure/acs-engine/pkg/helpers"
"github.com/Azure/acs-engine/pkg/i18n"
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/Azure/go-autorest/autorest/to"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -285,7 +286,8 @@ func autofillApimodel(dc *deployCmd) error {
dc.containerService.Properties.LinuxProfile.SSH.PublicKeys = []api.PublicKey{{KeyData: publicKey}}
}

_, err = dc.client.EnsureResourceGroup(dc.resourceGroup, dc.location, nil)
ctx := context.Background()
_, err = dc.client.EnsureResourceGroup(ctx, dc.resourceGroup, dc.location, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -319,15 +321,15 @@ func autofillApimodel(dc *deployCmd) error {
},
}
}
applicationID, servicePrincipalObjectID, secret, err := dc.client.CreateApp(appName, appURL, replyURLs, requiredResourceAccess)
applicationID, servicePrincipalObjectID, secret, err := dc.client.CreateApp(ctx, appName, appURL, replyURLs, requiredResourceAccess)
if err != nil {
return errors.Wrap(err, "apimodel invalid: ServicePrincipalProfile was empty, and we failed to create valid credentials")
}
log.Warnf("created application with applicationID (%s) and servicePrincipalObjectID (%s).", applicationID, servicePrincipalObjectID)

log.Warnln("apimodel: ServicePrincipalProfile was empty, assigning role to application...")

err = dc.client.CreateRoleAssignmentSimple(dc.resourceGroup, servicePrincipalObjectID)
err = dc.client.CreateRoleAssignmentSimple(ctx, dc.resourceGroup, servicePrincipalObjectID)
if err != nil {
return errors.Wrap(err, "apimodel: could not create or assign ServicePrincipal")

Expand Down Expand Up @@ -414,12 +416,13 @@ func (dc *deployCmd) run() error {
deploymentSuffix := dc.random.Int31()

if res, err := dc.client.DeployTemplate(
context.Background(),
dc.resourceGroup,
fmt.Sprintf("%s-%d", dc.resourceGroup, deploymentSuffix),
templateJSON,
parametersJSON,
nil); err != nil {
if res != nil && res.Response.Response != nil && res.Body != nil {
); err != nil {
if res.Response.Response != nil && res.Body != nil {
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
log.Errorf(string(body))
Expand Down
100 changes: 52 additions & 48 deletions cmd/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -131,7 +132,8 @@ func (sc *scaleCmd) load(cmd *cobra.Command) error {
return errors.Wrap(err, "failed to get client")
}

_, err = sc.client.EnsureResourceGroup(sc.resourceGroupName, sc.location, nil)
ctx := context.Background()
_, err = sc.client.EnsureResourceGroup(ctx, sc.resourceGroupName, sc.location, nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -207,38 +209,39 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
return errors.Wrap(err, "failed to load existing container service")
}

ctx := context.Background()
orchestratorInfo := sc.containerService.Properties.OrchestratorProfile
var currentNodeCount, highestUsedIndex, index, winPoolIndex int
winPoolIndex = -1
indexes := make([]int, 0)
indexToVM := make(map[int]string)
if sc.agentPool.IsAvailabilitySets() {
//TODO handle when there is a nextLink in the response and get more nodes
vms, err := sc.client.ListVirtualMachines(sc.resourceGroupName)
if err != nil {
return errors.Wrap(err, "failed to get vms in the resource group")
} else if len(*vms.Value) < 1 {
return errors.New("The provided resource group does not contain any vms")
}
for _, vm := range *vms.Value {
vmTags := *vm.Tags
poolName := *vmTags["poolName"]
nameSuffix := *vmTags["resourceNameSuffix"]

//Changed to string contains for the nameSuffix as the Windows Agent Pools use only a substring of the first 5 characters of the entire nameSuffix
if err != nil || !strings.EqualFold(poolName, sc.agentPoolToScale) || !strings.Contains(sc.nameSuffix, nameSuffix) {
continue
for vmsListPage, err := sc.client.ListVirtualMachines(ctx, sc.resourceGroupName); vmsListPage.NotDone(); err = vmsListPage.Next() {
if err != nil {
return errors.Wrap(err, "failed to get vms in the resource group")
} else if len(vmsListPage.Values()) < 1 {
return errors.New("The provided resource group does not contain any vms")
}
for _, vm := range vmsListPage.Values() {
vmTags := vm.Tags
poolName := *vmTags["poolName"]
nameSuffix := *vmTags["resourceNameSuffix"]

//Changed to string contains for the nameSuffix as the Windows Agent Pools use only a substring of the first 5 characters of the entire nameSuffix
if err != nil || !strings.EqualFold(poolName, sc.agentPoolToScale) || !strings.Contains(sc.nameSuffix, nameSuffix) {
continue
}

osPublisher := vm.StorageProfile.ImageReference.Publisher
if osPublisher != nil && strings.EqualFold(*osPublisher, "MicrosoftWindowsServer") {
_, _, winPoolIndex, index, err = utils.WindowsVMNameParts(*vm.Name)
} else {
_, _, index, err = utils.K8sLinuxVMNameParts(*vm.Name)
}
osPublisher := vm.StorageProfile.ImageReference.Publisher
if osPublisher != nil && strings.EqualFold(*osPublisher, "MicrosoftWindowsServer") {
_, _, winPoolIndex, index, err = utils.WindowsVMNameParts(*vm.Name)
} else {
_, _, index, err = utils.K8sLinuxVMNameParts(*vm.Name)
}

indexToVM[index] = *vm.Name
indexes = append(indexes, index)
indexToVM[index] = *vm.Name
indexes = append(indexes, index)
}
}
sortedIndexes := sort.IntSlice(indexes)
sortedIndexes.Sort()
Expand Down Expand Up @@ -309,37 +312,38 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
return nil
}
} else {
vmssList, err := sc.client.ListVirtualMachineScaleSets(sc.resourceGroupName)
if err != nil {
return errors.Wrap(err, "failed to get vmss list in the resource group")
}
for _, vmss := range *vmssList.Value {
vmTags := *vmss.Tags
poolName := *vmTags["poolName"]
nameSuffix := *vmTags["resourceNameSuffix"]

//Changed to string contains for the nameSuffix as the Windows Agent Pools use only a substring of the first 5 characters of the entire nameSuffix
if err != nil || !strings.EqualFold(poolName, sc.agentPoolToScale) || !strings.Contains(sc.nameSuffix, nameSuffix) {
continue
for vmssListPage, err := sc.client.ListVirtualMachineScaleSets(ctx, sc.resourceGroupName); vmssListPage.NotDone(); vmssListPage.Next() {
if err != nil {
return errors.Wrap(err, "failed to get vmss list in the resource group")
}
for _, vmss := range vmssListPage.Values() {
vmTags := vmss.Tags
poolName := *vmTags["poolName"]
nameSuffix := *vmTags["resourceNameSuffix"]

//Changed to string contains for the nameSuffix as the Windows Agent Pools use only a substring of the first 5 characters of the entire nameSuffix
if err != nil || !strings.EqualFold(poolName, sc.agentPoolToScale) || !strings.Contains(sc.nameSuffix, nameSuffix) {
continue
}

osPublisher := *vmss.VirtualMachineProfile.StorageProfile.ImageReference.Publisher
if strings.EqualFold(osPublisher, "MicrosoftWindowsServer") {
_, _, winPoolIndex, err = utils.WindowsVMSSNameParts(*vmss.Name)
log.Errorln(err)
}
osPublisher := *vmss.VirtualMachineProfile.StorageProfile.ImageReference.Publisher
if strings.EqualFold(osPublisher, "MicrosoftWindowsServer") {
_, _, winPoolIndex, err = utils.WindowsVMSSNameParts(*vmss.Name)
log.Errorln(err)
}

currentNodeCount = int(*vmss.Sku.Capacity)
highestUsedIndex = 0
currentNodeCount = int(*vmss.Sku.Capacity)
highestUsedIndex = 0
}
}
}

ctx := acsengine.Context{
translator := acsengine.Context{
Translator: &i18n.Translator{
Locale: sc.locale,
},
}
templateGenerator, err := acsengine.InitializeTemplateGenerator(ctx, sc.classicMode)
templateGenerator, err := acsengine.InitializeTemplateGenerator(translator, sc.classicMode)
if err != nil {
return errors.Wrap(err, "failed to initialize template generator")
}
Expand Down Expand Up @@ -368,7 +372,7 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
return errors.Wrap(err, "errror unmarshalling parameters")
}

transformer := transform.Transformer{Translator: ctx.Translator}
transformer := transform.Transformer{Translator: translator.Translator}
// Our templates generate a range of nodes based on a count and offset, it is possible for there to be holes in the template
// So we need to set the count in the template to get enough nodes for the range, if there are holes that number will be larger than the desired count
countForTemplate := sc.newDesiredAgentCount
Expand Down Expand Up @@ -410,11 +414,11 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
deploymentSuffix := random.Int31()

_, err = sc.client.DeployTemplate(
ctx,
sc.resourceGroupName,
fmt.Sprintf("%s-%d", sc.resourceGroupName, deploymentSuffix),
templateJSON,
parametersJSON,
nil)
parametersJSON)
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -121,7 +122,8 @@ func (uc *upgradeCmd) loadCluster(cmd *cobra.Command) error {
return errors.Wrap(err, "Failed to get client")
}

_, err = uc.client.EnsureResourceGroup(uc.resourceGroupName, uc.location, nil)
ctx := context.Background()
_, err = uc.client.EnsureResourceGroup(ctx, uc.resourceGroupName, uc.location, nil)
if err != nil {
return errors.Wrap(err, "Error ensuring resource group")
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/acsengine/tenantid.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package acsengine

import (
"context"
"net/http"
"regexp"

"github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
Expand All @@ -14,14 +15,14 @@ import (
// the value from WWW-Authenticate header.
func GetTenantID(resourceManagerEndpoint string, subscriptionID string) (string, error) {
const hdrKey = "WWW-Authenticate"
c := subscriptions.NewGroupClientWithBaseURI(resourceManagerEndpoint)
c := subscriptions.NewClientWithBaseURI(resourceManagerEndpoint)

log.Debugf("Resolving tenantID for subscriptionID: %s", subscriptionID)

// we expect this request to fail (err != nil), but we are only interested
// in headers, so surface the error if the Response is not present (i.e.
// network error etc)
subs, err := c.Get(subscriptionID)
subs, err := c.Get(context.Background(), subscriptionID)
if subs.Response.Response == nil {
return "", errors.Wrap(err, "Request failed")
}
Expand Down
Loading

0 comments on commit a4975a8

Please sign in to comment.