From db593a517dc275787393ada9fc7df380efd5fa2b Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Thu, 9 Jun 2016 22:26:22 -0700 Subject: [PATCH 01/31] Added manifest post-processor, which creates a manifest of build artifacts --- command/plugin.go | 2 + post-processor/manifest/artifact.go | 37 ++++++++ post-processor/manifest/post-processor.go | 100 ++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 post-processor/manifest/artifact.go create mode 100644 post-processor/manifest/post-processor.go diff --git a/command/plugin.go b/command/plugin.go index 95c08dc63..729edeba9 100644 --- a/command/plugin.go +++ b/command/plugin.go @@ -39,6 +39,7 @@ import ( dockerpushpostprocessor "github.com/mitchellh/packer/post-processor/docker-push" dockersavepostprocessor "github.com/mitchellh/packer/post-processor/docker-save" dockertagpostprocessor "github.com/mitchellh/packer/post-processor/docker-tag" + manifestpostprocessor "github.com/mitchellh/packer/post-processor/manifest" shelllocalpostprocessor "github.com/mitchellh/packer/post-processor/shell-local" vagrantpostprocessor "github.com/mitchellh/packer/post-processor/vagrant" vagrantcloudpostprocessor "github.com/mitchellh/packer/post-processor/vagrant-cloud" @@ -108,6 +109,7 @@ var PostProcessors = map[string]packer.PostProcessor{ "docker-push": new(dockerpushpostprocessor.PostProcessor), "docker-save": new(dockersavepostprocessor.PostProcessor), "docker-tag": new(dockertagpostprocessor.PostProcessor), + "manifest": new(manifestpostprocessor.PostProcessor), "shell-local": new(shelllocalpostprocessor.PostProcessor), "vagrant": new(vagrantpostprocessor.PostProcessor), "vagrant-cloud": new(vagrantcloudpostprocessor.PostProcessor), diff --git a/post-processor/manifest/artifact.go b/post-processor/manifest/artifact.go new file mode 100644 index 000000000..984330e0e --- /dev/null +++ b/post-processor/manifest/artifact.go @@ -0,0 +1,37 @@ +package manifest + +import "fmt" + +const BuilderId = "packer.post-processor.manifest" + +type Artifact struct { + BuildName string `json:"build_name"` + BuildTime int64 `json:"build_time"` + Description string `json:"description"` + BuildFiles []string `json:"files"` + BuildId string `json:"artifact_id"` +} + +func (a *Artifact) BuilderId() string { + return BuilderId +} + +func (a *Artifact) Files() []string { + return a.BuildFiles +} + +func (a *Artifact) Id() string { + return a.BuildId +} + +func (a *Artifact) String() string { + return fmt.Sprintf("%s-%s", a.BuildName, a.BuildId) +} + +func (a *Artifact) State(name string) interface{} { + return nil +} + +func (a *Artifact) Destroy() error { + return nil +} diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go new file mode 100644 index 000000000..2f8eadaee --- /dev/null +++ b/post-processor/manifest/post-processor.go @@ -0,0 +1,100 @@ +package manifest + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "os" + "time" + + "github.com/mitchellh/packer/common" + "github.com/mitchellh/packer/helper/config" + "github.com/mitchellh/packer/packer" + "github.com/mitchellh/packer/template/interpolate" +) + +// The artifact-override post-processor allows you to specify arbitrary files as +// artifacts. These will override any other artifacts created by the builder. +// This allows you to use a builder and provisioner to create some file, such as +// a compiled binary or tarball, extract it from the builder (VM or container) +// and then save that binary or tarball and throw away the builder. + +type Config struct { + common.PackerConfig `mapstructure:",squash"` + + Filename string `mapstructure:"filename"` + + ctx interpolate.Context +} + +type PostProcessor struct { + config Config +} + +type ManifestFile struct { + Builds []Artifact `json:"builds"` +} + +func (p *PostProcessor) Configure(raws ...interface{}) error { + err := config.Decode(&p.config, &config.DecodeOpts{ + Interpolate: true, + InterpolateContext: &p.config.ctx, + InterpolateFilter: &interpolate.RenderFilter{ + Exclude: []string{}, + }, + }, raws...) + if err != nil { + return err + } + + if p.config.Filename == "" { + p.config.Filename = "packer-manifest.json" + } + + return nil +} + +func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packer.Artifact, bool, error) { + artifact := &Artifact{} + + // Create the current artifact. + artifact.BuildFiles = source.Files() + artifact.BuildId = source.Id() + artifact.BuildName = source.BuilderId() + artifact.BuildTime = time.Now().Unix() + artifact.Description = source.String() + + // Create a lock file with exclusive access. If this fails we will retry + // after a delay + lockFilename := p.config.Filename + ".lock" + _, err := os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) + defer os.Remove(lockFilename) + + // Read the current manifest file from disk + contents := []byte{} + if contents, err = ioutil.ReadFile(p.config.Filename); err != nil && !os.IsNotExist(err) { + return nil, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.Filename, err) + } + + // Parse the manifest file JSON, if we have some + manifestFile := &ManifestFile{} + if len(contents) > 0 { + if err = json.Unmarshal(contents, manifestFile); err != nil { + return nil, true, fmt.Errorf("Unable to parse content from %s: %s", p.config.Filename, err) + } + } + + // Add the current artifact to the manifest file + manifestFile.Builds = append(manifestFile.Builds, *artifact) + + // Write JSON to disk + if out, err := json.Marshal(manifestFile); err == nil { + if err := ioutil.WriteFile(p.config.Filename, out, 0664); err != nil { + return nil, true, fmt.Errorf("Unable to write %s: %s", p.config.Filename, err) + } + } else { + return nil, true, fmt.Errorf("Unable to marshal JSON %s", err) + } + + return artifact, true, err +} From 8c875ebda4d1a76fe067c80dbb4b62cae9f2da34 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 10 Jun 2016 00:52:21 -0700 Subject: [PATCH 02/31] Changed overloaded artifact variable name to source --- post-processor/manifest/post-processor.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 2f8eadaee..fe23455f1 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -73,14 +73,14 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe // Read the current manifest file from disk contents := []byte{} if contents, err = ioutil.ReadFile(p.config.Filename); err != nil && !os.IsNotExist(err) { - return nil, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.Filename, err) + return source, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.Filename, err) } // Parse the manifest file JSON, if we have some manifestFile := &ManifestFile{} if len(contents) > 0 { if err = json.Unmarshal(contents, manifestFile); err != nil { - return nil, true, fmt.Errorf("Unable to parse content from %s: %s", p.config.Filename, err) + return source, true, fmt.Errorf("Unable to parse content from %s: %s", p.config.Filename, err) } } @@ -88,13 +88,13 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe manifestFile.Builds = append(manifestFile.Builds, *artifact) // Write JSON to disk - if out, err := json.Marshal(manifestFile); err == nil { + if out, err := json.MarshalIndent(manifestFile, "", " "); err == nil { if err := ioutil.WriteFile(p.config.Filename, out, 0664); err != nil { - return nil, true, fmt.Errorf("Unable to write %s: %s", p.config.Filename, err) + return source, true, fmt.Errorf("Unable to write %s: %s", p.config.Filename, err) } } else { - return nil, true, fmt.Errorf("Unable to marshal JSON %s", err) + return source, true, fmt.Errorf("Unable to marshal JSON %s", err) } - return artifact, true, err + return source, true, err } From 3c6ca7cbde0abfd0da76550ed747102b5a1a313b Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 10 Jun 2016 01:31:41 -0700 Subject: [PATCH 03/31] Added builder_type and build_name, renamed some other fields --- post-processor/manifest/artifact.go | 18 ++++++++++-------- post-processor/manifest/post-processor.go | 18 +++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/post-processor/manifest/artifact.go b/post-processor/manifest/artifact.go index 984330e0e..9a68d0e7e 100644 --- a/post-processor/manifest/artifact.go +++ b/post-processor/manifest/artifact.go @@ -5,11 +5,13 @@ import "fmt" const BuilderId = "packer.post-processor.manifest" type Artifact struct { - BuildName string `json:"build_name"` - BuildTime int64 `json:"build_time"` - Description string `json:"description"` - BuildFiles []string `json:"files"` - BuildId string `json:"artifact_id"` + BuildName string `json:"name"` + BuilderType string `json:"builder_type"` + InputType string `json:"input_type"` + BuildTime int64 `json:"build_time"` + Description string `json:"description"` + ArtifactFiles []string `json:"files"` + ArtifactId string `json:"artifact_id"` } func (a *Artifact) BuilderId() string { @@ -17,15 +19,15 @@ func (a *Artifact) BuilderId() string { } func (a *Artifact) Files() []string { - return a.BuildFiles + return a.ArtifactFiles } func (a *Artifact) Id() string { - return a.BuildId + return a.ArtifactId } func (a *Artifact) String() string { - return fmt.Sprintf("%s-%s", a.BuildName, a.BuildId) + return fmt.Sprintf("%s-%s", a.BuildName, a.ArtifactId) } func (a *Artifact) State(name string) interface{} { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index fe23455f1..1ed894718 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -13,12 +13,6 @@ import ( "github.com/mitchellh/packer/template/interpolate" ) -// The artifact-override post-processor allows you to specify arbitrary files as -// artifacts. These will override any other artifacts created by the builder. -// This allows you to use a builder and provisioner to create some file, such as -// a compiled binary or tarball, extract it from the builder (VM or container) -// and then save that binary or tarball and throw away the builder. - type Config struct { common.PackerConfig `mapstructure:",squash"` @@ -58,18 +52,24 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe artifact := &Artifact{} // Create the current artifact. - artifact.BuildFiles = source.Files() - artifact.BuildId = source.Id() - artifact.BuildName = source.BuilderId() + artifact.ArtifactFiles = source.Files() + artifact.ArtifactId = source.Id() + artifact.InputType = source.BuilderId() + artifact.BuilderType = p.config.PackerBuilderType + artifact.BuildName = p.config.PackerBuildName artifact.BuildTime = time.Now().Unix() artifact.Description = source.String() // Create a lock file with exclusive access. If this fails we will retry // after a delay + // TODO add retry lockFilename := p.config.Filename + ".lock" _, err := os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) defer os.Remove(lockFilename) + // TODO fix error on first run: + // * Post-processor failed: open packer-manifest.json: no such file or directory + // // Read the current manifest file from disk contents := []byte{} if contents, err = ioutil.ReadFile(p.config.Filename); err != nil && !os.IsNotExist(err) { From 78070f8ca9eaeb26c233d9c267ca61e3f39ea5ff Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 10 Jun 2016 01:44:33 -0700 Subject: [PATCH 04/31] Removed input_type and description since these are not particularly useful --- post-processor/manifest/artifact.go | 2 -- post-processor/manifest/post-processor.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/post-processor/manifest/artifact.go b/post-processor/manifest/artifact.go index 9a68d0e7e..7e24ed0df 100644 --- a/post-processor/manifest/artifact.go +++ b/post-processor/manifest/artifact.go @@ -7,9 +7,7 @@ const BuilderId = "packer.post-processor.manifest" type Artifact struct { BuildName string `json:"name"` BuilderType string `json:"builder_type"` - InputType string `json:"input_type"` BuildTime int64 `json:"build_time"` - Description string `json:"description"` ArtifactFiles []string `json:"files"` ArtifactId string `json:"artifact_id"` } diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 1ed894718..033899ab0 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -54,11 +54,9 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe // Create the current artifact. artifact.ArtifactFiles = source.Files() artifact.ArtifactId = source.Id() - artifact.InputType = source.BuilderId() artifact.BuilderType = p.config.PackerBuilderType artifact.BuildName = p.config.PackerBuildName artifact.BuildTime = time.Now().Unix() - artifact.Description = source.String() // Create a lock file with exclusive access. If this fails we will retry // after a delay From 7a9c3bc2a0831954cdce96729e23fe1760730f77 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 10 Jun 2016 14:39:41 -0700 Subject: [PATCH 05/31] Added -force truncation behavior for manifest, and added docs --- main.go | 7 ++++ post-processor/manifest/artifact.go | 1 + post-processor/manifest/post-processor.go | 31 ++++++++++++--- .../docs/post-processors/manifest.html.md | 39 +++++++++++++++++++ 4 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 website/source/docs/post-processors/manifest.html.md diff --git a/main.go b/main.go index bfd81c649..5f760e824 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "sync" "time" + "github.com/hashicorp/go-uuid" "github.com/mitchellh/cli" "github.com/mitchellh/packer/command" "github.com/mitchellh/packer/packer" @@ -36,6 +37,12 @@ func realMain() int { var wrapConfig panicwrap.WrapConfig if !panicwrap.Wrapped(&wrapConfig) { + // Generate a UUID for this packer run and pass it to the environment. + // GenerateUUID always returns a nil error (based on rand.Read) so we'll + // just ignore it. + UUID, _ := uuid.GenerateUUID() + os.Setenv("PACKER_RUN_UUID", UUID) + // Determine where logs should go in general (requested by the user) logWriter, err := logOutput() if err != nil { diff --git a/post-processor/manifest/artifact.go b/post-processor/manifest/artifact.go index 7e24ed0df..781a54266 100644 --- a/post-processor/manifest/artifact.go +++ b/post-processor/manifest/artifact.go @@ -10,6 +10,7 @@ type Artifact struct { BuildTime int64 `json:"build_time"` ArtifactFiles []string `json:"files"` ArtifactId string `json:"artifact_id"` + PackerRunUUID string `json:"packer_run_uuid"` } func (a *Artifact) BuilderId() string { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 033899ab0..8f2ce211c 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "log" "os" "time" @@ -26,7 +27,8 @@ type PostProcessor struct { } type ManifestFile struct { - Builds []Artifact `json:"builds"` + Builds []Artifact `json:"builds"` + LastRunUUID string `json:"last_run_uuid"` } func (p *PostProcessor) Configure(raws ...interface{}) error { @@ -51,18 +53,28 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packer.Artifact, bool, error) { artifact := &Artifact{} + var err error + // Create the current artifact. artifact.ArtifactFiles = source.Files() artifact.ArtifactId = source.Id() artifact.BuilderType = p.config.PackerBuilderType artifact.BuildName = p.config.PackerBuildName artifact.BuildTime = time.Now().Unix() + artifact.PackerRunUUID = os.Getenv("PACKER_RUN_UUID") // Create a lock file with exclusive access. If this fails we will retry - // after a delay - // TODO add retry + // after a delay. lockFilename := p.config.Filename + ".lock" - _, err := os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) + for i := 0; i < 3; i++ { + _, err = os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) + if err == nil { + break + } + log.Printf("Error locking manifest file for reading and writing. Will sleep and retry. %s", err) + // The file should not be locked for very long so we'll keep this short. + time.Sleep((time.Duration(i+1) * 200 * time.Millisecond)) + } defer os.Remove(lockFilename) // TODO fix error on first run: @@ -74,7 +86,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe return source, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.Filename, err) } - // Parse the manifest file JSON, if we have some + // Parse the manifest file JSON, if we have one manifestFile := &ManifestFile{} if len(contents) > 0 { if err = json.Unmarshal(contents, manifestFile); err != nil { @@ -82,12 +94,19 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe } } + // If -force is set and we are not on same run, truncate the file. Otherwise + // we will continue to add new builds to the existing manifest file. + if p.config.PackerForce && os.Getenv("PACKER_RUN_UUID") != manifestFile.LastRunUUID { + manifestFile = &ManifestFile{} + } + // Add the current artifact to the manifest file manifestFile.Builds = append(manifestFile.Builds, *artifact) + manifestFile.LastRunUUID = os.Getenv("PACKER_RUN_UUID") // Write JSON to disk if out, err := json.MarshalIndent(manifestFile, "", " "); err == nil { - if err := ioutil.WriteFile(p.config.Filename, out, 0664); err != nil { + if err = ioutil.WriteFile(p.config.Filename, out, 0664); err != nil { return source, true, fmt.Errorf("Unable to write %s: %s", p.config.Filename, err) } } else { diff --git a/website/source/docs/post-processors/manifest.html.md b/website/source/docs/post-processors/manifest.html.md new file mode 100644 index 000000000..88e658288 --- /dev/null +++ b/website/source/docs/post-processors/manifest.html.md @@ -0,0 +1,39 @@ +--- +description: | + The manifest post-processor writes a JSON file with the build artifacts and IDs from a packer run. +layout: docs +page_title: 'Manifest Post-Processor' +... + +# Manifest Post-Processor + +Type: `manifest` + +The manifest post-processor writes a JSON file with a list of all of the artifacts packer produces during a run. If your packer template includes multiple builds, this helps you keep track of which output artifacts (files, AMI IDs, docker containers, etc.) correspond to each build. + +The manifest post-processor is invoked each time a build completes and *updates* data in the manifest file. Builds are identified by name and type, and include their build time, artifact ID, and file list. + +If packer is run with the `-force` flag the manifest file will be truncated automatically during each packer run. Otherwise, subsequent builds will be added to the file. You can use the timestamps to see which is the latest artifact. + +You can specify manifest more than once and write each build to its own file, or write all builds to the same file. For simple builds manifest only needs to be specified once (see below) but you can also chain it together with other post-processors such as Docker and Artifice. + +## Configuration + +### Optional: + +- `filename` (string) The manifest will be written to this file. This defaults to `packer-manifest.json`. + +### Example Configuration + +You can simply add `{"type":"manifest"}` to your post-processor section. Below is a more verbose example: + +``` {.javascript} +{ + "post-processors": [ + { + "type": "manifest", + "filename": "manifest.json" + } + ] +} +``` From 104cdcf2665dae09c11a5acd7462a9ff431b064c Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 10 Jun 2016 15:58:17 -0700 Subject: [PATCH 06/31] Added go-uuid --- Godeps/Godeps.json | 4 + .../github.com/hashicorp/go-uuid/.travis.yml | 12 + vendor/github.com/hashicorp/go-uuid/LICENSE | 363 ++++++++++++++++++ vendor/github.com/hashicorp/go-uuid/README.md | 8 + vendor/github.com/hashicorp/go-uuid/uuid.go | 65 ++++ 5 files changed, 452 insertions(+) create mode 100644 vendor/github.com/hashicorp/go-uuid/.travis.yml create mode 100644 vendor/github.com/hashicorp/go-uuid/LICENSE create mode 100644 vendor/github.com/hashicorp/go-uuid/README.md create mode 100644 vendor/github.com/hashicorp/go-uuid/uuid.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 548b82018..f965163b1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -270,6 +270,10 @@ "ImportPath": "github.com/hashicorp/go-rootcerts", "Rev": "6bb64b370b90e7ef1fa532be9e591a81c3493e00" }, + { + "ImportPath": "github.com/hashicorp/go-uuid", + "Rev": "73d19cdc2bf00788cc25f7d5fd74347d48ada9ac" + }, { "ImportPath": "github.com/hashicorp/go-version", "Rev": "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38" diff --git a/vendor/github.com/hashicorp/go-uuid/.travis.yml b/vendor/github.com/hashicorp/go-uuid/.travis.yml new file mode 100644 index 000000000..769849071 --- /dev/null +++ b/vendor/github.com/hashicorp/go-uuid/.travis.yml @@ -0,0 +1,12 @@ +language: go + +sudo: false + +go: + - 1.4 + - 1.5 + - 1.6 + - tip + +script: + - go test -bench . -benchmem -v ./... diff --git a/vendor/github.com/hashicorp/go-uuid/LICENSE b/vendor/github.com/hashicorp/go-uuid/LICENSE new file mode 100644 index 000000000..e87a115e4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-uuid/LICENSE @@ -0,0 +1,363 @@ +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + diff --git a/vendor/github.com/hashicorp/go-uuid/README.md b/vendor/github.com/hashicorp/go-uuid/README.md new file mode 100644 index 000000000..02565c8c4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-uuid/README.md @@ -0,0 +1,8 @@ +# uuid [![Build Status](https://travis-ci.org/hashicorp/go-uuid.svg?branch=master)](https://travis-ci.org/hashicorp/go-uuid) + +Generates UUID-format strings using high quality, purely random bytes. It can also parse UUID-format strings into their component bytes. + +Documentation +============= + +The full documentation is available on [Godoc](http://godoc.org/github.com/hashicorp/go-uuid). diff --git a/vendor/github.com/hashicorp/go-uuid/uuid.go b/vendor/github.com/hashicorp/go-uuid/uuid.go new file mode 100644 index 000000000..ff9364c40 --- /dev/null +++ b/vendor/github.com/hashicorp/go-uuid/uuid.go @@ -0,0 +1,65 @@ +package uuid + +import ( + "crypto/rand" + "encoding/hex" + "fmt" +) + +// GenerateRandomBytes is used to generate random bytes of given size. +func GenerateRandomBytes(size int) ([]byte, error) { + buf := make([]byte, size) + if _, err := rand.Read(buf); err != nil { + return nil, fmt.Errorf("failed to read random bytes: %v", err) + } + return buf, nil +} + +// GenerateUUID is used to generate a random UUID +func GenerateUUID() (string, error) { + buf, err := GenerateRandomBytes(16) + if err != nil { + return "", err + } + return FormatUUID(buf) +} + +func FormatUUID(buf []byte) (string, error) { + if len(buf) != 16 { + return "", fmt.Errorf("wrong length byte slice (%d)", len(buf)) + } + + return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", + buf[0:4], + buf[4:6], + buf[6:8], + buf[8:10], + buf[10:16]), nil +} + +func ParseUUID(uuid string) ([]byte, error) { + if len(uuid) != 36 { + return nil, fmt.Errorf("uuid string is wrong length") + } + + hyph := []byte("-") + + if uuid[8] != hyph[0] || + uuid[13] != hyph[0] || + uuid[18] != hyph[0] || + uuid[23] != hyph[0] { + return nil, fmt.Errorf("uuid is improperly formatted") + } + + hexStr := uuid[0:8] + uuid[9:13] + uuid[14:18] + uuid[19:23] + uuid[24:36] + + ret, err := hex.DecodeString(hexStr) + if err != nil { + return nil, err + } + if len(ret) != 16 { + return nil, fmt.Errorf("decoded hex is the wrong length") + } + + return ret, nil +} From 510e4c991e8ea9e6bd1e4ce725e3799d0617e5b6 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 24 Jun 2016 10:35:22 +0200 Subject: [PATCH 07/31] Add comment on required subnet_id when using vpc_id --- website/source/docs/builders/amazon-ebs.html.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/source/docs/builders/amazon-ebs.html.md b/website/source/docs/builders/amazon-ebs.html.md index 8ad3039b0..a11f8cbba 100644 --- a/website/source/docs/builders/amazon-ebs.html.md +++ b/website/source/docs/builders/amazon-ebs.html.md @@ -214,7 +214,8 @@ builder. data when launching the instance. - `vpc_id` (string) - If launching into a VPC subnet, Packer needs the VPC ID - in order to create a temporary security group within the VPC. + in order to create a temporary security group within the VPC. Requires `subnet_id` + to be set. - `windows_password_timeout` (string) - The timeout for waiting for a Windows password for Windows instances. Defaults to 20 minutes. Example value: "10m" From 9aab66b9715b22f3e22abe0bb2779f5adb24c55c Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 24 Jun 2016 12:46:35 -0700 Subject: [PATCH 08/31] Change sleep so it doesn't wait after the final attempt --- post-processor/manifest/post-processor.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 8f2ce211c..69fb10856 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -61,19 +61,26 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe artifact.BuilderType = p.config.PackerBuilderType artifact.BuildName = p.config.PackerBuildName artifact.BuildTime = time.Now().Unix() + // Since each post-processor runs in a different process we need a way to + // coordinate between various post-processors in a single packer run. We do + // this by setting a UUID per run and tracking this in the manifest file. + // When we detect that the UUID in the file is the same, we know that we are + // part of the same run and we simply add our data to the list. If the UUID + // is different we will check the -force flag and decide whether to truncate + // the file before we proceed. artifact.PackerRunUUID = os.Getenv("PACKER_RUN_UUID") // Create a lock file with exclusive access. If this fails we will retry // after a delay. lockFilename := p.config.Filename + ".lock" for i := 0; i < 3; i++ { + // The file should not be locked for very long so we'll keep this short. + time.Sleep((time.Duration(i) * 200 * time.Millisecond)) _, err = os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) if err == nil { break } log.Printf("Error locking manifest file for reading and writing. Will sleep and retry. %s", err) - // The file should not be locked for very long so we'll keep this short. - time.Sleep((time.Duration(i+1) * 200 * time.Millisecond)) } defer os.Remove(lockFilename) From 40bd45764c90d26924a4a70103860f1d5e626084 Mon Sep 17 00:00:00 2001 From: Patrick Robinson Date: Mon, 27 Jun 2016 10:28:54 +1000 Subject: [PATCH 09/31] Only set InstanceInititatedShutdownBehavior on ebs instances --- .../amazon/common/step_run_source_instance.go | 5 +++- builder/amazon/instance/builder.go | 29 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index aac13fb88..c859a0df2 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -148,7 +148,6 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(), Placement: &ec2.Placement{AvailabilityZone: &s.AvailabilityZone}, EbsOptimized: &s.EbsOptimized, - InstanceInitiatedShutdownBehavior: &s.InstanceInitiatedShutdownBehavior, } if s.SubnetId != "" && s.AssociatePublicIpAddress { @@ -166,6 +165,10 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi runOpts.SecurityGroupIds = securityGroupIds } + if s.ExpectedRootDevice == "ebs" { + runOpts.InstanceInitiatedShutdownBehavior = &s.InstanceInitiatedShutdownBehavior + } + runResp, err := ec2conn.RunInstances(runOpts) if err != nil { err := fmt.Errorf("Error launching source instance: %s", err) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 514ff6da7..96b8fa9cc 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -204,21 +204,20 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe VpcId: b.config.VpcId, }, &awscommon.StepRunSourceInstance{ - Debug: b.config.PackerDebug, - SpotPrice: b.config.SpotPrice, - SpotPriceProduct: b.config.SpotPriceAutoProduct, - InstanceType: b.config.InstanceType, - IamInstanceProfile: b.config.IamInstanceProfile, - UserData: b.config.UserData, - UserDataFile: b.config.UserDataFile, - SourceAMI: b.config.SourceAmi, - SubnetId: b.config.SubnetId, - AssociatePublicIpAddress: b.config.AssociatePublicIpAddress, - EbsOptimized: b.config.EbsOptimized, - AvailabilityZone: b.config.AvailabilityZone, - BlockDevices: b.config.BlockDevices, - Tags: b.config.RunTags, - InstanceInitiatedShutdownBehavior: b.config.InstanceInitiatedShutdownBehavior, + Debug: b.config.PackerDebug, + SpotPrice: b.config.SpotPrice, + SpotPriceProduct: b.config.SpotPriceAutoProduct, + InstanceType: b.config.InstanceType, + IamInstanceProfile: b.config.IamInstanceProfile, + UserData: b.config.UserData, + UserDataFile: b.config.UserDataFile, + SourceAMI: b.config.SourceAmi, + SubnetId: b.config.SubnetId, + AssociatePublicIpAddress: b.config.AssociatePublicIpAddress, + EbsOptimized: b.config.EbsOptimized, + AvailabilityZone: b.config.AvailabilityZone, + BlockDevices: b.config.BlockDevices, + Tags: b.config.RunTags, }, &awscommon.StepGetPassword{ Debug: b.config.PackerDebug, From 9af244afc44f9285064d317dd944f2f11d9096f1 Mon Sep 17 00:00:00 2001 From: Patrick Robinson Date: Mon, 27 Jun 2016 10:29:59 +1000 Subject: [PATCH 10/31] Remove documentation about instance shutdown from instance builder --- website/source/docs/builders/amazon-instance.html.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/website/source/docs/builders/amazon-instance.html.md b/website/source/docs/builders/amazon-instance.html.md index 8818f1cb9..887f03b2b 100644 --- a/website/source/docs/builders/amazon-instance.html.md +++ b/website/source/docs/builders/amazon-instance.html.md @@ -244,10 +244,6 @@ builder. - `windows_password_timeout` (string) - The timeout for waiting for a Windows password for Windows instances. Defaults to 20 minutes. Example value: "10m" -- `shutdown_behaviour` (string) - Automatically terminate instances on shutdown - incase packer exits ungracefully. Possible values are "stop" and "terminate", - default is stop. - ## Basic Example Here is a basic example. It is completely valid except for the access keys: From 19057028cfc2392a886b068d7bd779b5713a3873 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Mon, 27 Jun 2016 19:19:29 -0700 Subject: [PATCH 11/31] Fix build failure when there is no packer-manifest.json file --- post-processor/manifest/post-processor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index 69fb10856..bd6648523 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -120,5 +120,5 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe return source, true, fmt.Errorf("Unable to marshal JSON %s", err) } - return source, true, err + return source, true, nil } From 999b8b2ed0b478cc203c5400fc27a4334b87c807 Mon Sep 17 00:00:00 2001 From: Joel Scoble Date: Wed, 6 Jul 2016 15:42:26 -0500 Subject: [PATCH 12/31] file provisioner: download should create all dirs in the destination path --- provisioner/file/provisioner.go | 15 +++++-- provisioner/file/provisioner_test.go | 59 +++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 63c1c0a8d..2b9a6b5fe 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "path/filepath" "strings" "github.com/mitchellh/packer/common" @@ -95,12 +96,20 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error { func (p *Provisioner) ProvisionDownload(ui packer.Ui, comm packer.Communicator) error { for _, src := range p.config.Sources { ui.Say(fmt.Sprintf("Downloading %s => %s", src, p.config.Destination)) - - if strings.HasSuffix(p.config.Destination, "/") { - err := os.MkdirAll(p.config.Destination, os.FileMode(0755)) + // ensure destination dir exists. p.config.Destination may either be a file or a dir. + dir := p.config.Destination + // if it doesn't end with a /, set dir as the parent dir + if !strings.HasSuffix(p.config.Destination, "/") { + dir = filepath.Dir(dir) + } + if dir != "" { + err := os.MkdirAll(dir, os.FileMode(0755)) if err != nil { return err } + } + // if the config.Destination was a dir, download the dir + if !strings.HasSuffix(p.config.Destination, "/") { return comm.DownloadDir(src, p.config.Destination, nil) } diff --git a/provisioner/file/provisioner_test.go b/provisioner/file/provisioner_test.go index 6f7cd5ea3..0086ed5ab 100644 --- a/provisioner/file/provisioner_test.go +++ b/provisioner/file/provisioner_test.go @@ -1,11 +1,14 @@ package file import ( - "github.com/mitchellh/packer/packer" + "fmt" "io/ioutil" "os" + "path/filepath" "strings" "testing" + + "github.com/mitchellh/packer/packer" ) func testConfig() map[string]interface{} { @@ -139,3 +142,57 @@ func TestProvisionerProvision_SendsFile(t *testing.T) { t.Fatalf("should upload with source file's data") } } + +func TestProvisionDownloadMkdirAll(t *testing.T) { + tests := []struct { + path string + }{ + {"dir"}, + {"dir/"}, + {"dir/subdir"}, + {"dir/subdir/"}, + {"path/to/dir"}, + {"path/to/dir/"}, + } + tmpDir, err := ioutil.TempDir("", "packer-file") + if err != nil { + t.Fatalf("error tempdir: %s", err) + } + defer os.RemoveAll(tmpDir) + tf, err := ioutil.TempFile(tmpDir, "packer") + if err != nil { + t.Fatalf("error tempfile: %s", err) + } + fmt.Println(tf.Name()) + defer os.Remove(tf.Name()) + + config := map[string]interface{}{ + "source": tf.Name(), + } + var p Provisioner + for _, test := range tests { + path := filepath.Join(tmpDir, test.path) + config["destination"] = filepath.Join(path, "something") + if err := p.Prepare(config); err != nil { + t.Fatalf("err: %s", err) + } + ui := &stubUi{} + comm := &packer.MockCommunicator{} + err = p.ProvisionDownload(ui, comm) + if err != nil { + t.Fatalf("should successfully provision: %s", err) + } + + if !strings.Contains(ui.sayMessages, tf.Name()) { + t.Fatalf("should print source filename") + } + + if !strings.Contains(ui.sayMessages, "something") { + t.Fatalf("should print destination filename") + } + + if _, err := os.Stat(path); err != nil { + t.Fatalf("stat of download dir should not error: %s", err) + } + } +} From 049fb2d9c1468d78700b5fb4e93320ffa1e70b90 Mon Sep 17 00:00:00 2001 From: Ricard Clau Date: Thu, 7 Jul 2016 20:01:23 +0100 Subject: [PATCH 13/31] actually check for errors in functional tests --- provisioner/ansible/provisioner_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/provisioner/ansible/provisioner_test.go b/provisioner/ansible/provisioner_test.go index 582c28907..12a0f4e9b 100644 --- a/provisioner/ansible/provisioner_test.go +++ b/provisioner/ansible/provisioner_test.go @@ -252,7 +252,10 @@ func TestAnsibleGetVersion(t *testing.T) { var p Provisioner p.config.Command = "ansible-playbook" - p.getVersion() + err := p.getVersion() + if err != nil { + t.Fatalf("err: %s", err) + } } func TestAnsibleLongMessages(t *testing.T) { @@ -263,7 +266,10 @@ func TestAnsibleLongMessages(t *testing.T) { var p Provisioner p.config.Command = "ansible-playbook" p.config.PlaybookFile = "./test-fixtures/long-debug-message.yml" - p.Prepare() + err := p.Prepare() + if err != nil { + t.Fatalf("err: %s", err) + } comm := &packer.MockCommunicator{} ui := &packer.BasicUi{ @@ -271,5 +277,8 @@ func TestAnsibleLongMessages(t *testing.T) { Writer: new(bytes.Buffer), } - p.Provision(ui, comm) + err = p.Provision(ui, comm) + if err != nil { + t.Fatalf("err: %s", err) + } } From 94d158b0b7ca4e299e9fb14fe932930d234da114 Mon Sep 17 00:00:00 2001 From: Joel Scoble Date: Thu, 7 Jul 2016 18:12:54 -0500 Subject: [PATCH 14/31] remove debug fmt.Print from test --- provisioner/file/provisioner_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/provisioner/file/provisioner_test.go b/provisioner/file/provisioner_test.go index 0086ed5ab..53dc315d4 100644 --- a/provisioner/file/provisioner_test.go +++ b/provisioner/file/provisioner_test.go @@ -1,7 +1,6 @@ package file import ( - "fmt" "io/ioutil" "os" "path/filepath" @@ -163,7 +162,6 @@ func TestProvisionDownloadMkdirAll(t *testing.T) { if err != nil { t.Fatalf("error tempfile: %s", err) } - fmt.Println(tf.Name()) defer os.Remove(tf.Name()) config := map[string]interface{}{ From 9f35d86f99a892e6f36b2478d2da9dc0cb668c6b Mon Sep 17 00:00:00 2001 From: arafato Date: Fri, 8 Jul 2016 14:24:07 +0200 Subject: [PATCH 15/31] fixed typo that breaks validation --- examples/azure/ubuntu.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/azure/ubuntu.json b/examples/azure/ubuntu.json index 0d5b176b4..eae2f24c7 100644 --- a/examples/azure/ubuntu.json +++ b/examples/azure/ubuntu.json @@ -4,7 +4,7 @@ "client_secret": "{{env `ARM_CLIENT_SECRET`}}", "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", - "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", + "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}" }, "builders": [{ "type": "azure-arm", From 130cea91d4a3a0dbdc45d1c1f8c468a131277c5b Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Mon, 11 Jul 2016 14:36:49 -0700 Subject: [PATCH 16/31] Update to an official version of Approvals The in-project version of Approvals has been moved to its own GitHub project under the offcial umbrella. This PR snaps to that version of the code.an official version of Approvals The in-project version of Approvals has been moved to its own GitHub project under the offcial umbrella. This PR snaps to that version of the code. --- ...est.TestKeyVaultDeployment03.approved.json | 67 ++++ ...stVirtualMachineDeployment03.approved.json | 160 ++++++++ ...stVirtualMachineDeployment04.approved.json | 158 ++++++++ builder/azure/arm/template_factory_test.go | 12 +- builder/azure/common/approvals/approvals.go | 122 ------ ...ilder_test.TestBuildLinux00.approved.json} | 318 ++++++++-------- ...ilder_test.TestBuildLinux01.approved.json} | 314 ++++++++-------- ...der_test.TestBuildWindows00.approved.json} | 346 +++++++++--------- .../common/template/template_builder_test.go | 15 +- 9 files changed, 882 insertions(+), 630 deletions(-) create mode 100644 builder/azure/arm/template_factory_test.TestKeyVaultDeployment03.approved.json create mode 100644 builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json create mode 100644 builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json delete mode 100644 builder/azure/common/approvals/approvals.go rename builder/azure/common/template/{TestBuildLinux00.approved.txt => template_builder_test.TestBuildLinux00.approved.json} (86%) rename builder/azure/common/template/{TestBuildLinux01.approved.txt => template_builder_test.TestBuildLinux01.approved.json} (86%) rename builder/azure/common/template/{TestBuildWindows00.approved.txt => template_builder_test.TestBuildWindows00.approved.json} (87%) diff --git a/builder/azure/arm/template_factory_test.TestKeyVaultDeployment03.approved.json b/builder/azure/arm/template_factory_test.TestKeyVaultDeployment03.approved.json new file mode 100644 index 000000000..6d4049800 --- /dev/null +++ b/builder/azure/arm/template_factory_test.TestKeyVaultDeployment03.approved.json @@ -0,0 +1,67 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "keyVaultName": { + "type": "string" + }, + "keyVaultSecretValue": { + "type": "securestring" + }, + "objectId": { + "type": "string" + }, + "tenantId": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[parameters('keyVaultName')]", + "properties": { + "accessPolicies": [ + { + "objectId": "[parameters('objectId')]", + "permissions": { + "keys": [ + "all" + ], + "secrets": [ + "all" + ] + }, + "tenantId": "[parameters('tenantId')]" + } + ], + "enabledForDeployment": "true", + "enabledForTemplateDeployment": "true", + "sku": { + "family": "A", + "name": "standard" + }, + "tenantId": "[parameters('tenantId')]" + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.KeyVault/vaults/', parameters('keyVaultName'))]" + ], + "name": "[variables('keyVaultSecretName')]", + "properties": { + "value": "[parameters('keyVaultSecretValue')]" + }, + "type": "secrets" + } + ], + "type": "Microsoft.KeyVault/vaults" + } + ], + "variables": { + "apiVersion": "2015-06-01", + "keyVaultSecretName": "packerKeyVaultSecret", + "location": "[resourceGroup().location]" + } +} \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json new file mode 100644 index 000000000..a6fce9d67 --- /dev/null +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json @@ -0,0 +1,160 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('publicIPAddressName')]", + "properties": { + "dnsSettings": { + "domainNameLabel": "[parameters('dnsNameForPublicIP')]" + }, + "publicIPAllocationMethod": "[variables('publicIPAddressType')]" + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('virtualNetworkName')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetAddressPrefix')]" + } + } + ] + }, + "type": "Microsoft.Network/virtualNetworks" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "imageReference": { + "offer": "ImageOffer", + "publisher": "ImagePublisher", + "sku": "ImageSku", + "version": "ImageVersion" + }, + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "name": "osdisk", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "packerSubnet", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "packerNetwork", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } +} \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json new file mode 100644 index 000000000..74a4b767f --- /dev/null +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json @@ -0,0 +1,158 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('publicIPAddressName')]", + "properties": { + "dnsSettings": { + "domainNameLabel": "[parameters('dnsNameForPublicIP')]" + }, + "publicIPAllocationMethod": "[variables('publicIPAddressType')]" + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('virtualNetworkName')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetAddressPrefix')]" + } + } + ] + }, + "type": "Microsoft.Network/virtualNetworks" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "image": { + "uri": "https://localhost/custom.vhd" + }, + "name": "osdisk", + "osType": "Linux", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "packerSubnet", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "packerNetwork", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } +} \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.go b/builder/azure/arm/template_factory_test.go index b098ec37f..d2445c188 100644 --- a/builder/azure/arm/template_factory_test.go +++ b/builder/azure/arm/template_factory_test.go @@ -2,11 +2,10 @@ package arm import ( "encoding/json" - "strings" "testing" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" - "github.com/mitchellh/packer/builder/azure/common/approvals" + "github.com/approvals/go-approval-tests" "github.com/mitchellh/packer/builder/azure/common/constants" "github.com/mitchellh/packer/builder/azure/common/template" ) @@ -115,8 +114,7 @@ func TestVirtualMachineDeployment03(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(string(bs)) - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, bs) if err != nil { t.Fatal(err) } @@ -151,8 +149,7 @@ func TestVirtualMachineDeployment04(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(string(bs)) - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, bs) if err != nil { t.Fatal(err) } @@ -248,8 +245,7 @@ func TestKeyVaultDeployment03(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(string(bs)) - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, bs) if err != nil { t.Fatal(err) } diff --git a/builder/azure/common/approvals/approvals.go b/builder/azure/common/approvals/approvals.go deleted file mode 100644 index 605d9c4a9..000000000 --- a/builder/azure/common/approvals/approvals.go +++ /dev/null @@ -1,122 +0,0 @@ -package approvals - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "os" - "runtime" - "strings" - "testing" -) - -type testState struct { - pc uintptr - fullName string - name string - fileName string - fileLine int -} - -func Verify(t *testing.T, reader io.Reader) error { - state, err := findTestMethod() - if err != nil { - return err - } - - return state.compare(state.getApprovalFile(), reader) -} - -func (s *testState) compare(approvalFile string, reader io.Reader) error { - received, err := ioutil.ReadAll(reader) - if err != nil { - return err - } - - // Ideally, this should only be written if - // 1. the approval file does not exist - // 2. the results differ - err = s.dumpReceivedTestResult(received) - if err != nil { - return err - } - - fh, err := os.Open(approvalFile) - if err != nil { - return err - } - defer fh.Close() - - approved, err := ioutil.ReadAll(fh) - if err != nil { - return err - } - - // The two sides are identical, nothing more to do. - if bytes.Compare(received, approved) == 0 { - return nil - } - - return fmt.Errorf("failed to approved %s", s.name) -} - -func (s *testState) dumpReceivedTestResult(bs []byte) error { - fn := s.getReceivedFile() - err := ioutil.WriteFile(fn, bs, 0644) - - return err -} - -func (s *testState) getReceivedFile() string { - return fmt.Sprintf("%s.received.txt", s.name) -} - -func (s *testState) getApprovalFile() string { - return fmt.Sprintf("%s.approved.txt", s.name) -} - -func newTestState(pc uintptr, f *runtime.Func) (*testState, error) { - state := &testState{ - pc: pc, - fullName: f.Name(), - } - - state.fileName, state.fileLine = f.FileLine(pc) - - splits := strings.Split(state.fullName, ".") - state.name = splits[len(splits)-1] - - return state, nil -} - -// Walk the call stack, and try to find the test method that was executed. -// The test method is identified by looking for the test runner, which is -// *assumed* to be common across all callers. The test runner has a Name() of -// 'testing.tRunner'. The method immediately previous to this is the test -// method. -func findTestMethod() (*testState, error) { - pc := make([]uintptr, 100) - count := runtime.Callers(0, pc) - - i := 0 - var lastFunc *runtime.Func - - for ; i < count; i++ { - lastFunc = runtime.FuncForPC(pc[i]) - if isTestRunner(lastFunc) { - break - } - } - - if i == 0 || !isTestRunner(lastFunc) { - return nil, fmt.Errorf("approvals: could not find the test method") - } - - testMethod := runtime.FuncForPC(pc[i-1]) - return newTestState(pc[i-1], testMethod) -} - -func isTestRunner(f *runtime.Func) bool { - return f != nil && f.Name() == "testing.tRunner" -} diff --git a/builder/azure/common/template/TestBuildLinux00.approved.txt b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json similarity index 86% rename from builder/azure/common/template/TestBuildLinux00.approved.txt rename to builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json index ebba273b8..a8ecfc0be 100644 --- a/builder/azure/common/template/TestBuildLinux00.approved.txt +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json @@ -1,160 +1,160 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "adminPassword": { - "type": "string" - }, - "adminUsername": { - "type": "string" - }, - "dnsNameForPublicIP": { - "type": "string" - }, - "osDiskName": { - "type": "string" - }, - "storageAccountBlobEndpoint": { - "type": "string" - }, - "vmName": { - "type": "string" - }, - "vmSize": { - "type": "string" - } - }, - "variables": { - "addressPrefix": "10.0.0.0/16", - "apiVersion": "2015-06-15", - "location": "[resourceGroup().location]", - "nicName": "packerNic", - "publicIPAddressName": "packerPublicIP", - "publicIPAddressType": "Dynamic", - "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", - "subnetAddressPrefix": "10.0.0.0/24", - "subnetName": "packerSubnet", - "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", - "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('publicIPAddressName')]", - "type": "Microsoft.Network/publicIPAddresses", - "location": "[variables('location')]", - "properties": { - "dnsSettings": { - "domainNameLabel": "[parameters('dnsNameForPublicIP')]" - }, - "publicIPAllocationMethod": "[variables('publicIPAddressType')]" - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('virtualNetworkName')]", - "type": "Microsoft.Network/virtualNetworks", - "location": "[variables('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('addressPrefix')]" - ] - }, - "subnets": [ - { - "properties": { - "addressPrefix": "[variables('subnetAddressPrefix')]" - }, - "name": "[variables('subnetName')]" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('nicName')]", - "type": "Microsoft.Network/networkInterfaces", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "properties": { - "ipConfigurations": [ - { - "properties": { - "privateIPAllocationMethod": "Dynamic", - "subnet": { - "id": "[variables('subnetRef')]" - }, - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" - } - }, - "name": "ipconfig" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[parameters('vmName')]", - "type": "Microsoft.Compute/virtualMachines", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" - ], - "properties": { - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": false - } - }, - "hardwareProfile": { - "vmSize": "[parameters('vmSize')]" - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" - } - ] - }, - "osProfile": { - "computerName": "[parameters('vmName')]", - "adminUsername": "[parameters('adminUsername')]", - "adminPassword": "[parameters('adminPassword')]", - "linuxConfiguration": { - "ssh": { - "publicKeys": [ - { - "path": "[variables('sshKeyPath')]", - "keyData": "--test-ssh-authorized-key--" - } - ] - } - } - }, - "storageProfile": { - "imageReference": { - "publisher": "Canonical", - "offer": "UbuntuServer", - "sku": "16.04", - "version": "latest" - }, - "osDisk": { - "name": "osdisk", - "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" - }, - "caching": "ReadWrite", - "createOption": "FromImage" - } - } - } - } - ] +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('publicIPAddressName')]", + "properties": { + "dnsSettings": { + "domainNameLabel": "[parameters('dnsNameForPublicIP')]" + }, + "publicIPAllocationMethod": "[variables('publicIPAddressType')]" + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('virtualNetworkName')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetAddressPrefix')]" + } + } + ] + }, + "type": "Microsoft.Network/virtualNetworks" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "--test-ssh-authorized-key--", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "imageReference": { + "offer": "UbuntuServer", + "publisher": "Canonical", + "sku": "16.04", + "version": "latest" + }, + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "name": "osdisk", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "packerSubnet", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "packerNetwork", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/TestBuildLinux01.approved.txt b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json similarity index 86% rename from builder/azure/common/template/TestBuildLinux01.approved.txt rename to builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json index 0f7799013..45bf5b271 100644 --- a/builder/azure/common/template/TestBuildLinux01.approved.txt +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json @@ -1,158 +1,158 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "adminPassword": { - "type": "string" - }, - "adminUsername": { - "type": "string" - }, - "dnsNameForPublicIP": { - "type": "string" - }, - "osDiskName": { - "type": "string" - }, - "storageAccountBlobEndpoint": { - "type": "string" - }, - "vmName": { - "type": "string" - }, - "vmSize": { - "type": "string" - } - }, - "variables": { - "addressPrefix": "10.0.0.0/16", - "apiVersion": "2015-06-15", - "location": "[resourceGroup().location]", - "nicName": "packerNic", - "publicIPAddressName": "packerPublicIP", - "publicIPAddressType": "Dynamic", - "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", - "subnetAddressPrefix": "10.0.0.0/24", - "subnetName": "packerSubnet", - "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", - "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('publicIPAddressName')]", - "type": "Microsoft.Network/publicIPAddresses", - "location": "[variables('location')]", - "properties": { - "dnsSettings": { - "domainNameLabel": "[parameters('dnsNameForPublicIP')]" - }, - "publicIPAllocationMethod": "[variables('publicIPAddressType')]" - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('virtualNetworkName')]", - "type": "Microsoft.Network/virtualNetworks", - "location": "[variables('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('addressPrefix')]" - ] - }, - "subnets": [ - { - "properties": { - "addressPrefix": "[variables('subnetAddressPrefix')]" - }, - "name": "[variables('subnetName')]" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('nicName')]", - "type": "Microsoft.Network/networkInterfaces", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "properties": { - "ipConfigurations": [ - { - "properties": { - "privateIPAllocationMethod": "Dynamic", - "subnet": { - "id": "[variables('subnetRef')]" - }, - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" - } - }, - "name": "ipconfig" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[parameters('vmName')]", - "type": "Microsoft.Compute/virtualMachines", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" - ], - "properties": { - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": false - } - }, - "hardwareProfile": { - "vmSize": "[parameters('vmSize')]" - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" - } - ] - }, - "osProfile": { - "computerName": "[parameters('vmName')]", - "adminUsername": "[parameters('adminUsername')]", - "adminPassword": "[parameters('adminPassword')]", - "linuxConfiguration": { - "ssh": { - "publicKeys": [ - { - "path": "[variables('sshKeyPath')]", - "keyData": "--test-ssh-authorized-key--" - } - ] - } - } - }, - "storageProfile": { - "osDisk": { - "osType": "Linux", - "name": "osdisk", - "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" - }, - "image": { - "uri": "http://azure/custom.vhd" - }, - "caching": "ReadWrite", - "createOption": "FromImage" - } - } - } - } - ] +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('publicIPAddressName')]", + "properties": { + "dnsSettings": { + "domainNameLabel": "[parameters('dnsNameForPublicIP')]" + }, + "publicIPAllocationMethod": "[variables('publicIPAddressType')]" + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('virtualNetworkName')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetAddressPrefix')]" + } + } + ] + }, + "type": "Microsoft.Network/virtualNetworks" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "--test-ssh-authorized-key--", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "image": { + "uri": "http://azure/custom.vhd" + }, + "name": "osdisk", + "osType": "Linux", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "packerSubnet", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "packerNetwork", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/TestBuildWindows00.approved.txt b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json similarity index 87% rename from builder/azure/common/template/TestBuildWindows00.approved.txt rename to builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json index 6217322fa..d2460d7b4 100644 --- a/builder/azure/common/template/TestBuildWindows00.approved.txt +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json @@ -1,174 +1,174 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "adminPassword": { - "type": "string" - }, - "adminUsername": { - "type": "string" - }, - "dnsNameForPublicIP": { - "type": "string" - }, - "osDiskName": { - "type": "string" - }, - "storageAccountBlobEndpoint": { - "type": "string" - }, - "vmName": { - "type": "string" - }, - "vmSize": { - "type": "string" - } - }, - "variables": { - "addressPrefix": "10.0.0.0/16", - "apiVersion": "2015-06-15", - "location": "[resourceGroup().location]", - "nicName": "packerNic", - "publicIPAddressName": "packerPublicIP", - "publicIPAddressType": "Dynamic", - "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", - "subnetAddressPrefix": "10.0.0.0/24", - "subnetName": "packerSubnet", - "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", - "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('publicIPAddressName')]", - "type": "Microsoft.Network/publicIPAddresses", - "location": "[variables('location')]", - "properties": { - "dnsSettings": { - "domainNameLabel": "[parameters('dnsNameForPublicIP')]" - }, - "publicIPAllocationMethod": "[variables('publicIPAddressType')]" - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('virtualNetworkName')]", - "type": "Microsoft.Network/virtualNetworks", - "location": "[variables('location')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('addressPrefix')]" - ] - }, - "subnets": [ - { - "properties": { - "addressPrefix": "[variables('subnetAddressPrefix')]" - }, - "name": "[variables('subnetName')]" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[variables('nicName')]", - "type": "Microsoft.Network/networkInterfaces", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "properties": { - "ipConfigurations": [ - { - "properties": { - "privateIPAllocationMethod": "Dynamic", - "subnet": { - "id": "[variables('subnetRef')]" - }, - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" - } - }, - "name": "ipconfig" - } - ] - } - }, - { - "apiVersion": "[variables('apiVersion')]", - "name": "[parameters('vmName')]", - "type": "Microsoft.Compute/virtualMachines", - "location": "[variables('location')]", - "dependsOn": [ - "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" - ], - "properties": { - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": false - } - }, - "hardwareProfile": { - "vmSize": "[parameters('vmSize')]" - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" - } - ] - }, - "osProfile": { - "computerName": "[parameters('vmName')]", - "adminUsername": "[parameters('adminUsername')]", - "adminPassword": "[parameters('adminPassword')]", - "windowsConfiguration": { - "provisionVMAgent": true, - "winRM": { - "listeners": [ - { - "protocol": "https", - "certificateUrl": "--test-winrm-certificate-url--" - } - ] - } - }, - "secrets": [ - { - "sourceVault": { - "id": "[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults', '--test-key-vault-name')]" - }, - "vaultCertificates": [ - { - "certificateUrl": "--test-winrm-certificate-url--", - "certificateStore": "My" - } - ] - } - ] - }, - "storageProfile": { - "imageReference": { - "publisher": "MicrosoftWindowsServer", - "offer": "WindowsServer", - "sku": "2012-R2-Datacenter", - "version": "latest" - }, - "osDisk": { - "name": "osdisk", - "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" - }, - "caching": "ReadWrite", - "createOption": "FromImage" - } - } - } - } - ] +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('publicIPAddressName')]", + "properties": { + "dnsSettings": { + "domainNameLabel": "[parameters('dnsNameForPublicIP')]" + }, + "publicIPAllocationMethod": "[variables('publicIPAddressType')]" + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "apiVersion": "[variables('apiVersion')]", + "location": "[variables('location')]", + "name": "[variables('virtualNetworkName')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[variables('addressPrefix')]" + ] + }, + "subnets": [ + { + "name": "[variables('subnetName')]", + "properties": { + "addressPrefix": "[variables('subnetAddressPrefix')]" + } + } + ] + }, + "type": "Microsoft.Network/virtualNetworks" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", + "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" + ], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" + }, + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "secrets": [ + { + "sourceVault": { + "id": "[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults', '--test-key-vault-name')]" + }, + "vaultCertificates": [ + { + "certificateStore": "My", + "certificateUrl": "--test-winrm-certificate-url--" + } + ] + } + ], + "windowsConfiguration": { + "provisionVMAgent": true, + "winRM": { + "listeners": [ + { + "certificateUrl": "--test-winrm-certificate-url--", + "protocol": "https" + } + ] + } + } + }, + "storageProfile": { + "imageReference": { + "offer": "WindowsServer", + "publisher": "MicrosoftWindowsServer", + "sku": "2012-R2-Datacenter", + "version": "latest" + }, + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "name": "osdisk", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "packerSubnet", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "packerNetwork", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/template_builder_test.go b/builder/azure/common/template/template_builder_test.go index d6775d120..f203acace 100644 --- a/builder/azure/common/template/template_builder_test.go +++ b/builder/azure/common/template/template_builder_test.go @@ -1,11 +1,10 @@ package template import ( - "strings" "testing" "github.com/Azure/azure-sdk-for-go/arm/compute" - "github.com/mitchellh/packer/builder/azure/common/approvals" + "github.com/approvals/go-approval-tests" ) // Ensure that a Linux template is configured as expected. @@ -31,9 +30,7 @@ func TestBuildLinux00(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(*doc) - - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, []byte(*doc)) if err != nil { t.Fatal(err) } @@ -61,9 +58,7 @@ func TestBuildLinux01(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(*doc) - - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, []byte(*doc)) if err != nil { t.Fatal(err) } @@ -93,9 +88,7 @@ func TestBuildWindows00(t *testing.T) { t.Fatal(err) } - reader := strings.NewReader(*doc) - - err = approvals.Verify(t, reader) + err = approvaltests.VerifyJSONBytes(t, []byte(*doc)) if err != nil { t.Fatal(err) } From 874ff0eaa743a8d6a29678c5d88699bd38fa4f48 Mon Sep 17 00:00:00 2001 From: Christian Moscardi Date: Tue, 12 Jul 2016 10:40:26 -0400 Subject: [PATCH 17/31] Adding privileged config variable to documentation. --- website/source/docs/builders/docker.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/source/docs/builders/docker.html.md b/website/source/docs/builders/docker.html.md index 076ec8328..d9832bb1e 100644 --- a/website/source/docs/builders/docker.html.md +++ b/website/source/docs/builders/docker.html.md @@ -98,6 +98,9 @@ You must specify (only) one of `commit`, `discard`, or `export_path`. - `login_server` (string) - The server address to login to. +- `privileged` (boolean) - If true, run the docker container with the + `--privileged` flag. This defaults to false if not set. + - `pull` (boolean) - If true, the configured image will be pulled using `docker pull` prior to use. Otherwise, it is assumed the image already exists and can be used. This defaults to true if not set. From bd6c0dbde02abf7bd73b98973960b68d50acc297 Mon Sep 17 00:00:00 2001 From: Sijis Aviles Date: Tue, 12 Jul 2016 13:26:44 -0500 Subject: [PATCH 18/31] Remove Communicator section from amazon-chroot docs Closes #3711 --- website/source/docs/builders/amazon-chroot.html.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/website/source/docs/builders/amazon-chroot.html.md b/website/source/docs/builders/amazon-chroot.html.md index 3570a1f0f..692c31f52 100644 --- a/website/source/docs/builders/amazon-chroot.html.md +++ b/website/source/docs/builders/amazon-chroot.html.md @@ -54,10 +54,6 @@ There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters. Within each category, the available configuration keys are alphabetized. -In addition to the options listed here, a -[communicator](/docs/templates/communicator.html) can be configured for this -builder. - ### Required: - `access_key` (string) - The access key used to communicate with AWS. [Learn From a7de9d9a2fb68cfa830476f796783afa5b37d2e8 Mon Sep 17 00:00:00 2001 From: Adron Hall Date: Thu, 14 Jul 2016 07:05:46 -0700 Subject: [PATCH 19/31] Changed based level example so it can be copied. The base level example doesn't actually work unless enclosed with a "builders" section. All fixed now. Previous: { "type": "googlecompute", "account_file": "account.json", "project_id": "my project", "source_image": "debian-7-wheezy-v20150127", "zone": "us-central1-a" } Now: { "builders": [ { "type": "googlecompute", "account_file": "account.json", "project_id": "my project", "source_image": "debian-7-wheezy-v20150127", "zone": "us-central1-a" } ] } --- website/source/docs/builders/googlecompute.html.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/website/source/docs/builders/googlecompute.html.md b/website/source/docs/builders/googlecompute.html.md index 63f988a47..82e3cb5e0 100644 --- a/website/source/docs/builders/googlecompute.html.md +++ b/website/source/docs/builders/googlecompute.html.md @@ -83,11 +83,15 @@ the path to the file containing the JSON. ``` {.javascript} { - "type": "googlecompute", - "account_file": "account.json", - "project_id": "my-project", - "source_image": "debian-7-wheezy-v20150127", - "zone": "us-central1-a" + "builders": [ + { + "type": "googlecompute", + "account_file": "account.json", + "project_id": "my project", + "source_image": "debian-7-wheezy-v20150127", + "zone": "us-central1-a" + } + ] } ``` From c4b93d00ad7e6eb77818f663acecf04443bf7be9 Mon Sep 17 00:00:00 2001 From: Adron Hall Date: Thu, 14 Jul 2016 14:54:02 -0700 Subject: [PATCH 20/31] Format change to spaces vs. tabs. & indentation cleanup. --- .../source/docs/builders/googlecompute.html.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/website/source/docs/builders/googlecompute.html.md b/website/source/docs/builders/googlecompute.html.md index 82e3cb5e0..c4842b976 100644 --- a/website/source/docs/builders/googlecompute.html.md +++ b/website/source/docs/builders/googlecompute.html.md @@ -83,15 +83,13 @@ the path to the file containing the JSON. ``` {.javascript} { - "builders": [ - { - "type": "googlecompute", - "account_file": "account.json", - "project_id": "my project", - "source_image": "debian-7-wheezy-v20150127", - "zone": "us-central1-a" - } - ] + "builders": [{ + "type": "googlecompute", + "account_file": "account.json", + "project_id": "my project", + "source_image": "debian-7-wheezy-v20150127", + "zone": "us-central1-a" + }] } ``` From c7262d64266bd09864a343fba25bfc9e297f02cd Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Thu, 14 Jul 2016 14:55:31 -0700 Subject: [PATCH 21/31] Ignore Created and Updated The Azure response has changed, and is breaking the code's ability to properly deserailize the response. --- builder/azure/common/vault.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/builder/azure/common/vault.go b/builder/azure/common/vault.go index 3ab48c692..27909958a 100644 --- a/builder/azure/common/vault.go +++ b/builder/azure/common/vault.go @@ -27,13 +27,6 @@ type VaultClient struct { type Secret struct { ID *string `json:"id,omitempty"` Value string `json:"value"` - Attributes SecretAttributes `json:"attributes"` -} - -type SecretAttributes struct { - Enabled bool `json:"enabled"` - Created *string `json:"created"` - Updated *string `json:"updated"` } func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, error) { From 31b5cee287a54ab802b5fc7d3afd499468ceed49 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Mon, 11 Jul 2016 15:08:28 -0700 Subject: [PATCH 22/31] Add Approvals dependency --- .gitignore | 3 + Godeps/Godeps.json | 12 + .../approvals/go-approval-tests/.gitignore | 25 ++ .../approvals/go-approval-tests/LICENSE.md | 201 ++++++++++++ .../approvals/go-approval-tests/README.md | 53 ++++ .../go-approval-tests/approval_name.go | 130 ++++++++ .../approvals/go-approval-tests/approvals.go | 204 ++++++++++++ .../combination_approvals.go | 296 ++++++++++++++++++ .../reporters/all_failing.go | 18 ++ .../reporters/beyond_compare.go | 15 + .../go-approval-tests/reporters/clipboard.go | 66 ++++ .../reporters/continuous_integration.go | 28 ++ .../reporters/diff_reporter.go | 40 +++ .../reporters/file_launcher.go | 27 ++ .../go-approval-tests/reporters/intellij.go | 15 + .../go-approval-tests/reporters/newbie.go | 18 ++ .../go-approval-tests/reporters/quiet.go | 29 ++ .../go-approval-tests/reporters/reporter.go | 53 ++++ .../utils/collection_utils.go | 77 +++++ .../go-approval-tests/utils/file_utils.go | 24 ++ .../go-approval-tests/utils/testing_utils.go | 11 + 21 files changed, 1345 insertions(+) create mode 100644 vendor/github.com/approvals/go-approval-tests/.gitignore create mode 100644 vendor/github.com/approvals/go-approval-tests/LICENSE.md create mode 100644 vendor/github.com/approvals/go-approval-tests/README.md create mode 100644 vendor/github.com/approvals/go-approval-tests/approval_name.go create mode 100644 vendor/github.com/approvals/go-approval-tests/approvals.go create mode 100644 vendor/github.com/approvals/go-approval-tests/combination_approvals.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/all_failing.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/beyond_compare.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/clipboard.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/continuous_integration.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/diff_reporter.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/file_launcher.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/intellij.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/newbie.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/quiet.go create mode 100644 vendor/github.com/approvals/go-approval-tests/reporters/reporter.go create mode 100644 vendor/github.com/approvals/go-approval-tests/utils/collection_utils.go create mode 100644 vendor/github.com/approvals/go-approval-tests/utils/file_utils.go create mode 100644 vendor/github.com/approvals/go-approval-tests/utils/testing_utils.go diff --git a/.gitignore b/.gitignore index 199855319..8dd382f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ website/.bundle website/vendor packer-test*.log + +*.received.txt +*.received.json diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 548b82018..1d18273b0 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -66,6 +66,18 @@ "ImportPath": "github.com/armon/go-radix", "Rev": "4239b77079c7b5d1243b7b4736304ce8ddb6f0f2" }, + { + "ImportPath": "github.com/approvals/go-approval-tests", + "Rev": "ad96e53bea43a905c17beeb983a0f9ce087dc48d" + }, + { + "ImportPath": "github.com/approvals/go-approval-tests/reporters", + "Rev": "ad96e53bea43a905c17beeb983a0f9ce087dc48d" + }, + { + "ImportPath": "github.com/approvals/go-approval-tests/utils", + "Rev": "ad96e53bea43a905c17beeb983a0f9ce087dc48d" + }, { "ImportPath": "github.com/aws/aws-sdk-go/aws", "Comment": "v1.1.2", diff --git a/vendor/github.com/approvals/go-approval-tests/.gitignore b/vendor/github.com/approvals/go-approval-tests/.gitignore new file mode 100644 index 000000000..6ed91fe2c --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/.gitignore @@ -0,0 +1,25 @@ +*.received.* +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/approvals/go-approval-tests/LICENSE.md b/vendor/github.com/approvals/go-approval-tests/LICENSE.md new file mode 100644 index 000000000..c0ee81299 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/LICENSE.md @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/github.com/approvals/go-approval-tests/README.md b/vendor/github.com/approvals/go-approval-tests/README.md new file mode 100644 index 000000000..ef9b41761 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/README.md @@ -0,0 +1,53 @@ +# ApprovalTests.go + +ApprovalTests for go + +[![Build Status](https://travis-ci.org/approvals/go-approval-tests.png?branch=master)](https://travis-ci.org/approvals/go-approval-tests) + +# Golden master Verification Library +ApprovalTests allows for easy testing of larger objects, strings and anything else that can be saved to a file (images, sounds, csv, etc...) + +#Examples +##In Project +Note: ApprovalTests uses approvaltests to test itself. Therefore there are many examples in the code itself. + + * [approvals_test.go](approvals_test.go) + +##JSON +VerifyJSONBytes - Simple Formatting for easy comparison. Also uses the .json file extension + +```go +func TestVerifyJSON(t *testing.T) { + jsonb := []byte("{ \"foo\": \"bar\", \"age\": 42, \"bark\": \"woof\" }") + VerifyJSONBytes(t, jsonb) +} +``` +Matches file: approvals_test.TestVerifyJSON.received.json + +```json +{ + "age": 42, + "bark": "woof", + "foo": "bar" +} +``` + +##Reporters +ApprovalTests becomes *much* more powerful with reporters. Reporters launch programs on failure to help you understand, fix and approve results. + +You can make your own easily, [here's an example](reporters/beyond_compare.go) +You can also declare which one to use. Either at the +### Method level +```go +r := UseReporter(reporters.NewIntelliJ()) +defer r.Close() +``` +### Test Level +```go +func TestMain(m *testing.M) { + r := UseReporter(reporters.NewBeyondCompareReporter()) + defer r.Close() + + m.Run() +} +``` diff --git a/vendor/github.com/approvals/go-approval-tests/approval_name.go b/vendor/github.com/approvals/go-approval-tests/approval_name.go new file mode 100644 index 000000000..1ef043efc --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/approval_name.go @@ -0,0 +1,130 @@ +package approvaltests + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "os" + "path" + "runtime" + "strings" +) + +type approvalName struct { + pc uintptr + fullName string + name string + fileName string + fileLine int +} + +func newApprovalName(pc uintptr, f *runtime.Func) (*approvalName, error) { + namer := &approvalName{ + pc: pc, + fullName: f.Name(), + } + + namer.fileName, namer.fileLine = f.FileLine(pc) + + splits := strings.Split(namer.fullName, ".") + namer.name = splits[len(splits)-1] + + return namer, nil +} + +// Walk the call stack, and try to find the test method that was executed. +// The test method is identified by looking for the test runner, which is +// *assumed* to be common across all callers. The test runner has a Name() of +// 'testing.tRunner'. The method immediately previous to this is the test +// method. +func getApprovalName() (*approvalName, error) { + pc := make([]uintptr, 100) + count := runtime.Callers(0, pc) + + i := 0 + var lastFunc *runtime.Func + + for ; i < count; i++ { + lastFunc = runtime.FuncForPC(pc[i]) + if isTestRunner(lastFunc) { + break + } + } + + if i == 0 || !isTestRunner(lastFunc) { + return nil, fmt.Errorf("approvals: could not find the test method") + } + + testMethod := runtime.FuncForPC(pc[i-1]) + return newApprovalName(pc[i-1], testMethod) +} + +func isTestRunner(f *runtime.Func) bool { + return f != nil && f.Name() == "testing.tRunner" +} + +func (s *approvalName) compare(approvalFile, receivedFile string, reader io.Reader) error { + received, err := ioutil.ReadAll(reader) + if err != nil { + return err + } + + // Ideally, this should only be written if + // 1. the approval file does not exist + // 2. the results differ + err = s.dumpReceivedTestResult(received, receivedFile) + if err != nil { + return err + } + + fh, err := os.Open(approvalFile) + if err != nil { + return err + } + defer fh.Close() + + approved, err := ioutil.ReadAll(fh) + if err != nil { + return err + } + + received = s.normalizeLineEndings(received) + approved = s.normalizeLineEndings(approved) + + // The two sides are identical, nothing more to do. + if bytes.Compare(received, approved) == 0 { + return nil + } + + return fmt.Errorf("failed to approved %s", s.name) +} + +func (s *approvalName) normalizeLineEndings(bs []byte) []byte { + return bytes.Replace(bs, []byte("\r\n"), []byte("\n"), -1) +} + +func (s *approvalName) dumpReceivedTestResult(bs []byte, receivedFile string) error { + err := ioutil.WriteFile(receivedFile, bs, 0644) + + return err +} + +func (s *approvalName) getFileName(extWithDot string, suffix string) string { + if !strings.HasPrefix(extWithDot, ".") { + extWithDot = fmt.Sprintf(".%s", extWithDot) + } + + baseName := path.Base(s.fileName) + baseWithoutExt := baseName[:len(baseName)-len(path.Ext(s.fileName))] + + return fmt.Sprintf("%s.%s.%s%s", baseWithoutExt, s.name, suffix, extWithDot) +} + +func (s *approvalName) getReceivedFile(extWithDot string) string { + return s.getFileName(extWithDot, "received") +} + +func (s *approvalName) getApprovalFile(extWithDot string) string { + return s.getFileName(extWithDot, "approved") +} diff --git a/vendor/github.com/approvals/go-approval-tests/approvals.go b/vendor/github.com/approvals/go-approval-tests/approvals.go new file mode 100644 index 000000000..f4b3a839e --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/approvals.go @@ -0,0 +1,204 @@ +package approvaltests + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "os" + "strings" + + "encoding/xml" + "github.com/approvals/go-approval-tests/reporters" + "github.com/approvals/go-approval-tests/utils" + "reflect" +) + +var ( + defaultReporter = reporters.NewDiffReporter() + defaultFrontLoadedReporter = reporters.NewFrontLoadedReporter() +) + +// Failable is an interface wrapper around testing.T +type Failable interface { + Fail() +} + +// VerifyWithExtension Example: +// VerifyWithExtension(t, strings.NewReader("Hello"), ".txt") +func VerifyWithExtension(t Failable, reader io.Reader, extWithDot string) error { + namer, err := getApprovalName() + if err != nil { + return err + } + + reporter := getReporter() + err = namer.compare(namer.getApprovalFile(extWithDot), namer.getReceivedFile(extWithDot), reader) + if err != nil { + reporter.Report(namer.getApprovalFile(extWithDot), namer.getReceivedFile(extWithDot)) + t.Fail() + } else { + os.Remove(namer.getReceivedFile(extWithDot)) + } + + return err +} + +// Verify Example: +// Verify(t, strings.NewReader("Hello")) +func Verify(t Failable, reader io.Reader) error { + return VerifyWithExtension(t, reader, ".txt") +} + +// VerifyString Example: +// VerifyString(t, "Hello") +func VerifyString(t Failable, s string) error { + reader := strings.NewReader(s) + return Verify(t, reader) +} + +// VerifyXMLStruct Example: +// VerifyXMLStruct(t, xml) +func VerifyXMLStruct(t Failable, obj interface{}) error { + xmlb, err := xml.MarshalIndent(obj, "", " ") + if err != nil { + tip := "" + if reflect.TypeOf(obj).Name() == "" { + tip = "when using anonymous types be sure to include\n XMLName xml.Name `xml:\"Your_Name_Here\"`\n" + } + message := fmt.Sprintf("error while pretty printing XML\n%verror:\n %v\nXML:\n %v\n", tip, err, obj) + return VerifyWithExtension(t, strings.NewReader(message), ".xml") + } + + return VerifyWithExtension(t, bytes.NewReader(xmlb), ".xml") +} + +// VerifyXMLBytes Example: +// VerifyXMLBytes(t, []byte("")) +func VerifyXMLBytes(t Failable, bs []byte) error { + type node struct { + Attr []xml.Attr + XMLName xml.Name + Children []node `xml:",any"` + Text string `xml:",chardata"` + } + x := node{} + + err := xml.Unmarshal(bs, &x) + if err != nil { + message := fmt.Sprintf("error while parsing XML\nerror:\n %s\nXML:\n %s\n", err, string(bs)) + return VerifyWithExtension(t, strings.NewReader(message), ".xml") + } + + return VerifyXMLStruct(t, x) +} + +// VerifyJSONStruct Example: +// VerifyJSONStruct(t, json) +func VerifyJSONStruct(t Failable, obj interface{}) error { + jsonb, err := json.MarshalIndent(obj, "", " ") + if err != nil { + message := fmt.Sprintf("error while pretty printing JSON\nerror:\n %s\nJSON:\n %s\n", err, obj) + return VerifyWithExtension(t, strings.NewReader(message), ".json") + } + + return VerifyWithExtension(t, bytes.NewReader(jsonb), ".json") +} + +// VerifyJSONBytes Example: +// VerifyJSONBytes(t, []byte("{ \"Greeting\": \"Hello\" }")) +func VerifyJSONBytes(t Failable, bs []byte) error { + var obj map[string]interface{} + err := json.Unmarshal(bs, &obj) + if err != nil { + message := fmt.Sprintf("error while parsing JSON\nerror:\n %s\nJSON:\n %s\n", err, string(bs)) + return VerifyWithExtension(t, strings.NewReader(message), ".json") + } + + return VerifyJSONStruct(t, obj) +} + +// VerifyMap Example: +// VerifyMap(t, map[string][string] { "dog": "bark" }) +func VerifyMap(t Failable, m interface{}) error { + outputText := utils.PrintMap(m) + return VerifyString(t, outputText) +} + +// VerifyArray Example: +// VerifyArray(t, []string{"dog", "cat"}) +func VerifyArray(t Failable, array interface{}) error { + outputText := utils.PrintArray(array) + return VerifyString(t, outputText) +} + +// VerifyAll Example: +// VerifyAll(t, "uppercase", []string("dog", "cat"}, func(x interface{}) string { return strings.ToUpper(x.(string)) }) +func VerifyAll(t Failable, header string, collection interface{}, transform func(interface{}) string) error { + if len(header) != 0 { + header = fmt.Sprintf("%s\n\n\n", header) + } + + outputText := header + strings.Join(utils.MapToString(collection, transform), "\n") + return VerifyString(t, outputText) +} + +type reporterCloser struct { + reporter *reporters.Reporter +} + +func (s *reporterCloser) Close() error { + defaultReporter = s.reporter + return nil +} + +type frontLoadedReporterCloser struct { + reporter *reporters.Reporter +} + +func (s *frontLoadedReporterCloser) Close() error { + defaultFrontLoadedReporter = s.reporter + return nil +} + +// UseReporter configures which reporter to use on failure. +// Add at the test or method level to configure your reporter. +// +// The following examples shows how to use a reporter for all of your test cases +// in a package directory through go's setup feature. +// +// +// func TestMain(m *testing.M) { +// r := UseReporter(reporters.NewBeyondCompareReporter()) +// defer r.Close() +// +// os.Exit(m.Run()) +// } +// +func UseReporter(reporter reporters.Reporter) io.Closer { + closer := &reporterCloser{ + reporter: defaultReporter, + } + + defaultReporter = &reporter + return closer +} + +// UseFrontLoadedReporter configures reporters ahead of all other reporters to +// handle situations like CI. These reporters usually prevent reporting in +// scenarios that are headless. +func UseFrontLoadedReporter(reporter reporters.Reporter) io.Closer { + closer := &frontLoadedReporterCloser{ + reporter: defaultFrontLoadedReporter, + } + + defaultFrontLoadedReporter = &reporter + return closer +} + +func getReporter() reporters.Reporter { + return reporters.NewFirstWorkingReporter( + *defaultFrontLoadedReporter, + *defaultReporter, + ) +} diff --git a/vendor/github.com/approvals/go-approval-tests/combination_approvals.go b/vendor/github.com/approvals/go-approval-tests/combination_approvals.go new file mode 100644 index 000000000..9c775a823 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/combination_approvals.go @@ -0,0 +1,296 @@ +package approvaltests + +import ( + "fmt" + "strings" + + "reflect" +) + +type emptyType struct{} + +var ( + // SkipThisCombination should be returned if you do not want to process a particular combination + SkipThisCombination = "♬ SKIP THIS COMBINATION ♬" + + empty = emptyType{} + emptyCollection = []emptyType{empty} +) + +// VerifyAllCombinationsFor1 Example: +// VerifyAllCombinationsFor1(t, "uppercase", func(x interface{}) string { return strings.ToUpper(x.(string)) }, []string("dog", "cat"}) +func VerifyAllCombinationsFor1(t Failable, header string, transform func(interface{}) string, collection1 interface{}) error { + transform2 := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1) + } + + return VerifyAllCombinationsFor9(t, header, transform2, collection1, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor2 Example: +// VerifyAllCombinationsFor2(t, "uppercase", func(x interface{}) string { return strings.ToUpper(x.(string)) }, []string("dog", "cat"}, []int{1,2) +func VerifyAllCombinationsFor2(t Failable, header string, transform func(interface{}, interface{}) string, collection1 interface{}, collection2 interface{}) error { + transform2 := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2) + } + + return VerifyAllCombinationsFor9(t, header, transform2, collection1, + collection2, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor3 is for combinations of 3. +func VerifyAllCombinationsFor3( + t Failable, + header string, + transform func(p1, p2, p3 interface{}) string, + collection1, collection2, collection3 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor4 is for combinations of 4. +func VerifyAllCombinationsFor4( + t Failable, + header string, + transform func(p1, p2, p3, p4 interface{}) string, + collection1, collection2, collection3, collection4 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3, p4) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + collection4, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor5 is for combinations of 5. +func VerifyAllCombinationsFor5( + t Failable, + header string, + transform func(p1, p2, p3, p4, p5 interface{}) string, + collection1, collection2, collection3, collection4, collection5 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3, p4, p5) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + collection4, + collection5, + emptyCollection, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor6 is for combinations of 6. +func VerifyAllCombinationsFor6( + t Failable, + header string, + transform func(p1, p2, p3, p4, p5, p6 interface{}) string, + collection1, collection2, collection3, collection4, collection5, collection6 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3, p4, p5, p6) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + collection4, + collection5, + collection6, + emptyCollection, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor7 is for combinations of 7. +func VerifyAllCombinationsFor7( + t Failable, + header string, + transform func(p1, p2, p3, p4, p5, p6, p7 interface{}) string, + collection1, collection2, collection3, collection4, collection5, collection6, collection7 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3, p4, p5, p6, p7) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + collection4, + collection5, + collection6, + collection7, + emptyCollection, + emptyCollection) +} + +// VerifyAllCombinationsFor8 is for combinations of 8. +func VerifyAllCombinationsFor8( + t Failable, + header string, + transform func(p1, p2, p3, p4, p5, p6, p7, p8 interface{}) string, + collection1, collection2, collection3, collection4, collection5, collection6, collection7, collection8 interface{}) error { + + kerning := func(p1, p2, p3, p4, p5, p6, p7, p8, p9 interface{}) string { + return transform(p1, p2, p3, p4, p5, p6, p7, p8) + } + + return VerifyAllCombinationsFor9(t, header, kerning, + collection1, + collection2, + collection3, + collection4, + collection5, + collection6, + collection7, + collection8, + emptyCollection) +} + +// VerifyAllCombinationsFor9 is for combinations of 9. +func VerifyAllCombinationsFor9( + t Failable, + header string, + transform func(a, b, c, d, e, f, g, h, i interface{}) string, + collection1, + collection2, + collection3, + collection4, + collection5, + collection6, + collection7, + collection8, + collection9 interface{}) error { + + if len(header) != 0 { + header = fmt.Sprintf("%s\n\n\n", header) + } + + var mapped []string + + slice1 := reflect.ValueOf(collection1) + slice2 := reflect.ValueOf(collection2) + slice3 := reflect.ValueOf(collection3) + slice4 := reflect.ValueOf(collection4) + slice5 := reflect.ValueOf(collection5) + slice6 := reflect.ValueOf(collection6) + slice7 := reflect.ValueOf(collection7) + slice8 := reflect.ValueOf(collection8) + slice9 := reflect.ValueOf(collection9) + + for i1 := 0; i1 < slice1.Len(); i1++ { + for i2 := 0; i2 < slice2.Len(); i2++ { + for i3 := 0; i3 < slice3.Len(); i3++ { + for i4 := 0; i4 < slice4.Len(); i4++ { + for i5 := 0; i5 < slice5.Len(); i5++ { + for i6 := 0; i6 < slice6.Len(); i6++ { + for i7 := 0; i7 < slice7.Len(); i7++ { + for i8 := 0; i8 < slice8.Len(); i8++ { + for i9 := 0; i9 < slice9.Len(); i9++ { + p1 := slice1.Index(i1).Interface() + p2 := slice2.Index(i2).Interface() + p3 := slice3.Index(i3).Interface() + p4 := slice4.Index(i4).Interface() + p5 := slice5.Index(i5).Interface() + p6 := slice6.Index(i6).Interface() + p7 := slice7.Index(i7).Interface() + p8 := slice8.Index(i8).Interface() + p9 := slice9.Index(i9).Interface() + + parameterText := getParameterText(p1, p2, p3, p4, p5, p6, p7, p8, p9) + transformText := getTransformText(transform, p1, p2, p3, p4, p5, p6, p7, p8, p9) + if transformText != SkipThisCombination { + mapped = append(mapped, fmt.Sprintf("%s => %s", parameterText, transformText)) + } + } + } + } + } + } + } + } + } + } + + outputText := header + strings.Join(mapped, "\n") + return VerifyString(t, outputText) +} + +func getParameterText(args ...interface{}) string { + parameterText := "[" + for _, x := range args { + if x != empty { + parameterText += fmt.Sprintf("%v,", x) + } + } + + parameterText = parameterText[0 : len(parameterText)-1] + parameterText += "]" + + return parameterText +} + +func getTransformText( + transform func(a, b, c, d, e, f, g, h, i interface{}) string, + p1, + p2, + p3, + p4, + p5, + p6, + p7, + p8, + p9 interface{}) (s string) { + defer func() { + r := recover() + if r != nil { + s = "panic occurred" + } + }() + + return transform(p1, p2, p3, p4, p5, p6, p7, p8, p9) +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/all_failing.go b/vendor/github.com/approvals/go-approval-tests/reporters/all_failing.go new file mode 100644 index 000000000..788a1e3b0 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/all_failing.go @@ -0,0 +1,18 @@ +package reporters + +var ( + clipboardScratchData = "" +) + +type allFailing struct{} + +// NewAllFailingTestReporter copies move file command to your clipboard +func NewAllFailingTestReporter() Reporter { + return &allFailing{} +} + +func (s *allFailing) Report(approved, received string) bool { + move := getMoveCommandText(approved, received) + clipboardScratchData = clipboardScratchData + move + "\n" + return copyToClipboard(clipboardScratchData) +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/beyond_compare.go b/vendor/github.com/approvals/go-approval-tests/reporters/beyond_compare.go new file mode 100644 index 000000000..81dccd25c --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/beyond_compare.go @@ -0,0 +1,15 @@ +package reporters + +type beyondCompare struct{} + +// NewBeyondCompareReporter creates a new reporter for Beyond Compare 4. +func NewBeyondCompareReporter() Reporter { + return &beyondCompare{} +} + +func (s *beyondCompare) Report(approved, received string) bool { + xs := []string{received, approved} + programName := "C:/Program Files/Beyond Compare 4/BComp.exe" + + return launchProgram(programName, approved, xs...) +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/clipboard.go b/vendor/github.com/approvals/go-approval-tests/reporters/clipboard.go new file mode 100644 index 000000000..4f4f9ffe9 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/clipboard.go @@ -0,0 +1,66 @@ +package reporters + +import ( + "fmt" + "os/exec" + "path/filepath" + "runtime" +) + +type clipboard struct{} + +// NewClipboardReporter copies move file command to your clipboard +func NewClipboardReporter() Reporter { + return &clipboard{} +} + +func (s *clipboard) Report(approved, received string) bool { + move := getMoveCommandText(approved, received) + return copyToClipboard(move) +} + +func copyToClipboard(move string) bool { + switch runtime.GOOS { + case "windows": + return copyToWindowsClipboard(move) + default: + return copyToDarwinClipboard(move) + } +} + +func getMoveCommandText(approved, received string) string { + receivedFull, _ := filepath.Abs(received) + approvedFull, _ := filepath.Abs(approved) + + var move string + + switch runtime.GOOS { + case "windows": + move = fmt.Sprintf("move /Y \"%s\" \"%s\"", receivedFull, approvedFull) + default: + move = fmt.Sprintf("mv %s %s", receivedFull, approvedFull) + } + + return move +} +func copyToWindowsClipboard(text string) bool { + return pipeToProgram("clip", text) +} + +func copyToDarwinClipboard(text string) bool { + return pipeToProgram("pbcopy", text) +} + +func pipeToProgram(programName, text string) bool { + c := exec.Command(programName) + pipe, err := c.StdinPipe() + if err != nil { + fmt.Printf("StdinPipe: err=%s", err) + return false + } + pipe.Write([]byte(text)) + pipe.Close() + + c.Start() + return true +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/continuous_integration.go b/vendor/github.com/approvals/go-approval-tests/reporters/continuous_integration.go new file mode 100644 index 000000000..923feb793 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/continuous_integration.go @@ -0,0 +1,28 @@ +package reporters + +import ( + "os" + "strconv" +) + +type continuousIntegration struct{} + +// NewContinuousIntegrationReporter creates a new reporter for CI. +// +// The reporter checks the environment variable CI for a value of true. +func NewContinuousIntegrationReporter() Reporter { + return &continuousIntegration{} +} + +func (s *continuousIntegration) Report(approved, received string) bool { + value, exists := os.LookupEnv("CI") + + if exists { + ci, err := strconv.ParseBool(value) + if err == nil { + return ci + } + } + + return false +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/diff_reporter.go b/vendor/github.com/approvals/go-approval-tests/reporters/diff_reporter.go new file mode 100644 index 000000000..630548e2a --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/diff_reporter.go @@ -0,0 +1,40 @@ +package reporters + +import ( + "os/exec" + + "github.com/approvals/go-approval-tests/utils" +) + +// NewFrontLoadedReporter creates the default front loaded reporter. +func NewFrontLoadedReporter() *Reporter { + tmp := NewFirstWorkingReporter( + NewContinuousIntegrationReporter(), + ) + + return &tmp +} + +// NewDiffReporter creates the default diff reporter. +func NewDiffReporter() *Reporter { + tmp := NewFirstWorkingReporter( + NewBeyondCompareReporter(), + NewIntelliJReporter(), + NewPrintSupportedDiffProgramsReporter(), + NewQuietReporter(), + ) + + return &tmp +} + +func launchProgram(programName, approved string, args ...string) bool { + if !utils.DoesFileExist(programName) { + return false + } + + utils.EnsureExists(approved) + + cmd := exec.Command(programName, args...) + cmd.Start() + return true +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/file_launcher.go b/vendor/github.com/approvals/go-approval-tests/reporters/file_launcher.go new file mode 100644 index 000000000..cb9bd5b2d --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/file_launcher.go @@ -0,0 +1,27 @@ +package reporters + +import ( + "os/exec" + "runtime" +) + +type fileLauncher struct{} + +// NewFileLauncherReporter launches registered application of the received file's type only. +func NewFileLauncherReporter() Reporter { + return &fileLauncher{} +} + +func (s *fileLauncher) Report(approved, received string) bool { + var cmd *exec.Cmd + + switch runtime.GOOS { + case "windows": + cmd = exec.Command("cmd", "/C", "start", "Needed Title", received, "/B") + default: + cmd = exec.Command("open", received) + } + + cmd.Start() + return true +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/intellij.go b/vendor/github.com/approvals/go-approval-tests/reporters/intellij.go new file mode 100644 index 000000000..63e9506aa --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/intellij.go @@ -0,0 +1,15 @@ +package reporters + +type intellij struct{} + +// NewIntelliJReporter creates a new reporter for IntelliJ. +func NewIntelliJReporter() Reporter { + return &intellij{} +} + +func (s *intellij) Report(approved, received string) bool { + xs := []string{"diff", received, approved} + programName := "C:/Program Files (x86)/JetBrains/IntelliJ IDEA 2016/bin/idea.exe" + + return launchProgram(programName, approved, xs...) +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/newbie.go b/vendor/github.com/approvals/go-approval-tests/reporters/newbie.go new file mode 100644 index 000000000..8e662bf84 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/newbie.go @@ -0,0 +1,18 @@ +package reporters + +import ( + "fmt" +) + +type printSupportedDiffPrograms struct{} + +// NewPrintSupportedDiffProgramsReporter creates a new reporter that states what reporters are supported. +func NewPrintSupportedDiffProgramsReporter() Reporter { + return &quiet{} +} + +func (s *printSupportedDiffPrograms) Report(approved, received string) bool { + fmt.Printf("no diff reporters found on your system\ncurrently supported reporters are [in order of preference]:\nBeyond Compare\nIntelliJ") + + return false +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/quiet.go b/vendor/github.com/approvals/go-approval-tests/reporters/quiet.go new file mode 100644 index 000000000..a715c0eac --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/quiet.go @@ -0,0 +1,29 @@ +package reporters + +import ( + "fmt" + "path/filepath" + + "github.com/approvals/go-approval-tests/utils" +) + +type quiet struct{} + +// NewQuietReporter creates a new reporter that does nothing. +func NewQuietReporter() Reporter { + return &quiet{} +} + +func (s *quiet) Report(approved, received string) bool { + approvedFull, _ := filepath.Abs(approved) + receivedFull, _ := filepath.Abs(received) + + if utils.DoesFileExist(approved) { + fmt.Printf("approval files did not match\napproved: %v\nreceived: %v\n", approvedFull, receivedFull) + + } else { + fmt.Printf("result never approved\napproved: %v\nreceived: %v\n", approvedFull, receivedFull) + } + + return true +} diff --git a/vendor/github.com/approvals/go-approval-tests/reporters/reporter.go b/vendor/github.com/approvals/go-approval-tests/reporters/reporter.go new file mode 100644 index 000000000..99d6866f6 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/reporters/reporter.go @@ -0,0 +1,53 @@ +package reporters + +// Reporter are called on failing approvals. +type Reporter interface { + // Report is called when the approved and received file do not match. + Report(approved, received string) bool +} + +// FirstWorkingReporter reports using the first possible reporter. +type FirstWorkingReporter struct { + Reporters []Reporter +} + +// Report is called when the approved and received file do not match. +func (s *FirstWorkingReporter) Report(approved, received string) bool { + for _, reporter := range s.Reporters { + result := reporter.Report(approved, received) + if result { + return true + } + } + + return false +} + +// NewFirstWorkingReporter creates in the order reporters are passed in. +func NewFirstWorkingReporter(reporters ...Reporter) Reporter { + return &FirstWorkingReporter{ + Reporters: reporters, + } +} + +// MultiReporter reports all reporters. +type MultiReporter struct { + Reporters []Reporter +} + +// Report is called when the approved and received file do not match. +func (s *MultiReporter) Report(approved, received string) bool { + result := false + for _, reporter := range s.Reporters { + result = reporter.Report(approved, received) || result + } + + return result +} + +// NewMultiReporter calls all reporters. +func NewMultiReporter(reporters ...Reporter) Reporter { + return &MultiReporter{ + Reporters: reporters, + } +} diff --git a/vendor/github.com/approvals/go-approval-tests/utils/collection_utils.go b/vendor/github.com/approvals/go-approval-tests/utils/collection_utils.go new file mode 100644 index 000000000..1602fa6e5 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/utils/collection_utils.go @@ -0,0 +1,77 @@ +package utils + +import ( + "fmt" + "reflect" + "sort" + "strings" +) + +// PrintMap prints a map +func PrintMap(m interface{}) string { + var outputText string + + v := reflect.ValueOf(m) + if v.Kind() != reflect.Map { + outputText = fmt.Sprintf("error while printing map\nreceived a %T\n %s\n", m, m) + } else { + + keys := v.MapKeys() + var xs []string + + for _, k := range keys { + xs = append(xs, fmt.Sprintf("[%s]=%s", k, v.MapIndex(k))) + } + + sort.Strings(xs) + if len(xs) == 0 { + outputText = "len(map) == 0" + } else { + outputText = strings.Join(xs, "\n") + } + } + + return outputText +} + +// PrintArray prints an array +func PrintArray(m interface{}) string { + var outputText string + + switch reflect.TypeOf(m).Kind() { + case reflect.Slice: + var xs []string + + slice := reflect.ValueOf(m) + for i := 0; i < slice.Len(); i++ { + xs = append(xs, fmt.Sprintf("[%d]=%s", i, slice.Index(i))) + } + + if len(xs) == 0 { + outputText = "len(array) == 0" + } else { + outputText = strings.Join(xs, "\n") + } + default: + outputText = fmt.Sprintf("error while printing array\nreceived a %T\n %s\n", m, m) + } + + return outputText +} + +// MapToString maps a collection to a string collection +func MapToString(collection interface{}, transform func(x interface{}) string) []string { + switch reflect.TypeOf(collection).Kind() { + case reflect.Slice: + var xs []string + + slice := reflect.ValueOf(collection) + for i := 0; i < slice.Len(); i++ { + xs = append(xs, transform(slice.Index(i).Interface())) + } + + return xs + default: + panic(fmt.Sprintf("error while mapping array to string\nreceived a %T\n %s\n", collection, collection)) + } +} diff --git a/vendor/github.com/approvals/go-approval-tests/utils/file_utils.go b/vendor/github.com/approvals/go-approval-tests/utils/file_utils.go new file mode 100644 index 000000000..bec3b950b --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/utils/file_utils.go @@ -0,0 +1,24 @@ +package utils + +import ( + "io/ioutil" + "os" +) + +// DoesFileExist checks if a file exists. +func DoesFileExist(fileName string) bool { + _, err := os.Stat(fileName) + if os.IsNotExist(err) { + return false + } + return true +} + +// EnsureExists creates if the file does not already exist. +func EnsureExists(fileName string) { + if DoesFileExist(fileName) { + return + } + + ioutil.WriteFile(fileName, []byte(""), 0644) +} diff --git a/vendor/github.com/approvals/go-approval-tests/utils/testing_utils.go b/vendor/github.com/approvals/go-approval-tests/utils/testing_utils.go new file mode 100644 index 000000000..c6c9c8ab6 --- /dev/null +++ b/vendor/github.com/approvals/go-approval-tests/utils/testing_utils.go @@ -0,0 +1,11 @@ +package utils + +import "testing" + +// AssertEqual Example: +// AssertEqual(t, 10, number, "number") +func AssertEqual(t *testing.T, expected, actual interface{}, message string) { + if expected != actual { + t.Fatalf(message+"\n[expected != actual]\n[%s != %s]", expected, actual) + } +} From e33a32532399a14abf8bf1a86f2bd72dabcdfaeb Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Fri, 15 Jul 2016 21:31:03 -0700 Subject: [PATCH 23/31] Use VerifyJSONStruct --- .../arm/TestKeyVaultDeployment03.approved.txt | 67 -------- ...estVirtualMachineDeployment03.approved.txt | 160 ------------------ ...estVirtualMachineDeployment04.approved.txt | 158 ----------------- builder/azure/arm/template_factory_test.go | 21 +-- 4 files changed, 3 insertions(+), 403 deletions(-) delete mode 100644 builder/azure/arm/TestKeyVaultDeployment03.approved.txt delete mode 100644 builder/azure/arm/TestVirtualMachineDeployment03.approved.txt delete mode 100644 builder/azure/arm/TestVirtualMachineDeployment04.approved.txt diff --git a/builder/azure/arm/TestKeyVaultDeployment03.approved.txt b/builder/azure/arm/TestKeyVaultDeployment03.approved.txt deleted file mode 100644 index fa683ce8c..000000000 --- a/builder/azure/arm/TestKeyVaultDeployment03.approved.txt +++ /dev/null @@ -1,67 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "keyVaultName": { - "type": "string" - }, - "keyVaultSecretValue": { - "type": "securestring" - }, - "objectId": { - "type": "string" - }, - "tenantId": { - "type": "string" - } - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "location": "[variables('location')]", - "name": "[parameters('keyVaultName')]", - "properties": { - "accessPolicies": [ - { - "objectId": "[parameters('objectId')]", - "permissions": { - "keys": [ - "all" - ], - "secrets": [ - "all" - ] - }, - "tenantId": "[parameters('tenantId')]" - } - ], - "enabledForDeployment": "true", - "enabledForTemplateDeployment": "true", - "sku": { - "family": "A", - "name": "standard" - }, - "tenantId": "[parameters('tenantId')]" - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "dependsOn": [ - "[concat('Microsoft.KeyVault/vaults/', parameters('keyVaultName'))]" - ], - "name": "[variables('keyVaultSecretName')]", - "properties": { - "value": "[parameters('keyVaultSecretValue')]" - }, - "type": "secrets" - } - ], - "type": "Microsoft.KeyVault/vaults" - } - ], - "variables": { - "apiVersion": "2015-06-01", - "keyVaultSecretName": "packerKeyVaultSecret", - "location": "[resourceGroup().location]" - } -} \ No newline at end of file diff --git a/builder/azure/arm/TestVirtualMachineDeployment03.approved.txt b/builder/azure/arm/TestVirtualMachineDeployment03.approved.txt deleted file mode 100644 index 8cd4ae5c6..000000000 --- a/builder/azure/arm/TestVirtualMachineDeployment03.approved.txt +++ /dev/null @@ -1,160 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "adminPassword": { - "type": "string" - }, - "adminUsername": { - "type": "string" - }, - "dnsNameForPublicIP": { - "type": "string" - }, - "osDiskName": { - "type": "string" - }, - "storageAccountBlobEndpoint": { - "type": "string" - }, - "vmName": { - "type": "string" - }, - "vmSize": { - "type": "string" - } - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "location": "[variables('location')]", - "name": "[variables('publicIPAddressName')]", - "properties": { - "dnsSettings": { - "domainNameLabel": "[parameters('dnsNameForPublicIP')]" - }, - "publicIPAllocationMethod": "[variables('publicIPAddressType')]" - }, - "type": "Microsoft.Network/publicIPAddresses" - }, - { - "apiVersion": "[variables('apiVersion')]", - "location": "[variables('location')]", - "name": "[variables('virtualNetworkName')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('addressPrefix')]" - ] - }, - "subnets": [ - { - "name": "[variables('subnetName')]", - "properties": { - "addressPrefix": "[variables('subnetAddressPrefix')]" - } - } - ] - }, - "type": "Microsoft.Network/virtualNetworks" - }, - { - "apiVersion": "[variables('apiVersion')]", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "location": "[variables('location')]", - "name": "[variables('nicName')]", - "properties": { - "ipConfigurations": [ - { - "name": "ipconfig", - "properties": { - "privateIPAllocationMethod": "Dynamic", - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" - }, - "subnet": { - "id": "[variables('subnetRef')]" - } - } - } - ] - }, - "type": "Microsoft.Network/networkInterfaces" - }, - { - "apiVersion": "[variables('apiVersion')]", - "dependsOn": [ - "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" - ], - "location": "[variables('location')]", - "name": "[parameters('vmName')]", - "properties": { - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": false - } - }, - "hardwareProfile": { - "vmSize": "[parameters('vmSize')]" - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" - } - ] - }, - "osProfile": { - "adminPassword": "[parameters('adminPassword')]", - "adminUsername": "[parameters('adminUsername')]", - "computerName": "[parameters('vmName')]", - "linuxConfiguration": { - "ssh": { - "publicKeys": [ - { - "keyData": "", - "path": "[variables('sshKeyPath')]" - } - ] - } - } - }, - "storageProfile": { - "imageReference": { - "offer": "ImageOffer", - "publisher": "ImagePublisher", - "sku": "ImageSku", - "version": "ImageVersion" - }, - "osDisk": { - "caching": "ReadWrite", - "createOption": "FromImage", - "name": "osdisk", - "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" - } - } - } - }, - "type": "Microsoft.Compute/virtualMachines" - } - ], - "variables": { - "addressPrefix": "10.0.0.0/16", - "apiVersion": "2015-06-15", - "location": "[resourceGroup().location]", - "nicName": "packerNic", - "publicIPAddressName": "packerPublicIP", - "publicIPAddressType": "Dynamic", - "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", - "subnetAddressPrefix": "10.0.0.0/24", - "subnetName": "packerSubnet", - "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", - "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } -} \ No newline at end of file diff --git a/builder/azure/arm/TestVirtualMachineDeployment04.approved.txt b/builder/azure/arm/TestVirtualMachineDeployment04.approved.txt deleted file mode 100644 index 9aa27815c..000000000 --- a/builder/azure/arm/TestVirtualMachineDeployment04.approved.txt +++ /dev/null @@ -1,158 +0,0 @@ -{ - "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", - "contentVersion": "1.0.0.0", - "parameters": { - "adminPassword": { - "type": "string" - }, - "adminUsername": { - "type": "string" - }, - "dnsNameForPublicIP": { - "type": "string" - }, - "osDiskName": { - "type": "string" - }, - "storageAccountBlobEndpoint": { - "type": "string" - }, - "vmName": { - "type": "string" - }, - "vmSize": { - "type": "string" - } - }, - "resources": [ - { - "apiVersion": "[variables('apiVersion')]", - "location": "[variables('location')]", - "name": "[variables('publicIPAddressName')]", - "properties": { - "dnsSettings": { - "domainNameLabel": "[parameters('dnsNameForPublicIP')]" - }, - "publicIPAllocationMethod": "[variables('publicIPAddressType')]" - }, - "type": "Microsoft.Network/publicIPAddresses" - }, - { - "apiVersion": "[variables('apiVersion')]", - "location": "[variables('location')]", - "name": "[variables('virtualNetworkName')]", - "properties": { - "addressSpace": { - "addressPrefixes": [ - "[variables('addressPrefix')]" - ] - }, - "subnets": [ - { - "name": "[variables('subnetName')]", - "properties": { - "addressPrefix": "[variables('subnetAddressPrefix')]" - } - } - ] - }, - "type": "Microsoft.Network/virtualNetworks" - }, - { - "apiVersion": "[variables('apiVersion')]", - "dependsOn": [ - "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", - "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" - ], - "location": "[variables('location')]", - "name": "[variables('nicName')]", - "properties": { - "ipConfigurations": [ - { - "name": "ipconfig", - "properties": { - "privateIPAllocationMethod": "Dynamic", - "publicIPAddress": { - "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" - }, - "subnet": { - "id": "[variables('subnetRef')]" - } - } - } - ] - }, - "type": "Microsoft.Network/networkInterfaces" - }, - { - "apiVersion": "[variables('apiVersion')]", - "dependsOn": [ - "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" - ], - "location": "[variables('location')]", - "name": "[parameters('vmName')]", - "properties": { - "diagnosticsProfile": { - "bootDiagnostics": { - "enabled": false - } - }, - "hardwareProfile": { - "vmSize": "[parameters('vmSize')]" - }, - "networkProfile": { - "networkInterfaces": [ - { - "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" - } - ] - }, - "osProfile": { - "adminPassword": "[parameters('adminPassword')]", - "adminUsername": "[parameters('adminUsername')]", - "computerName": "[parameters('vmName')]", - "linuxConfiguration": { - "ssh": { - "publicKeys": [ - { - "keyData": "", - "path": "[variables('sshKeyPath')]" - } - ] - } - } - }, - "storageProfile": { - "osDisk": { - "caching": "ReadWrite", - "createOption": "FromImage", - "image": { - "uri": "https://localhost/custom.vhd" - }, - "name": "osdisk", - "osType": "Linux", - "vhd": { - "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" - } - } - } - }, - "type": "Microsoft.Compute/virtualMachines" - } - ], - "variables": { - "addressPrefix": "10.0.0.0/16", - "apiVersion": "2015-06-15", - "location": "[resourceGroup().location]", - "nicName": "packerNic", - "publicIPAddressName": "packerPublicIP", - "publicIPAddressType": "Dynamic", - "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", - "subnetAddressPrefix": "10.0.0.0/24", - "subnetName": "packerSubnet", - "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", - "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } -} \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.go b/builder/azure/arm/template_factory_test.go index d2445c188..4ab976f9c 100644 --- a/builder/azure/arm/template_factory_test.go +++ b/builder/azure/arm/template_factory_test.go @@ -109,12 +109,7 @@ func TestVirtualMachineDeployment03(t *testing.T) { t.Fatal(err) } - bs, err := json.MarshalIndent(deployment.Properties.Template, "", " ") - if err != nil { - t.Fatal(err) - } - - err = approvaltests.VerifyJSONBytes(t, bs) + err = approvaltests.VerifyJSONStruct(t, deployment.Properties.Template) if err != nil { t.Fatal(err) } @@ -144,12 +139,7 @@ func TestVirtualMachineDeployment04(t *testing.T) { t.Fatal(err) } - bs, err := json.MarshalIndent(deployment.Properties.Template, "", " ") - if err != nil { - t.Fatal(err) - } - - err = approvaltests.VerifyJSONBytes(t, bs) + err = approvaltests.VerifyJSONStruct(t, deployment.Properties.Template) if err != nil { t.Fatal(err) } @@ -240,12 +230,7 @@ func TestKeyVaultDeployment03(t *testing.T) { t.Fatal(err) } - bs, err := json.MarshalIndent(deployment.Properties.Template, "", " ") - if err != nil { - t.Fatal(err) - } - - err = approvaltests.VerifyJSONBytes(t, bs) + err = approvaltests.VerifyJSONStruct(t, deployment.Properties.Template) if err != nil { t.Fatal(err) } From 408fe9bc181cdc7c97b23b84fd5ba60034e1add2 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Fri, 15 Jul 2016 22:23:53 -0700 Subject: [PATCH 24/31] Lint issues --- builder/azure/arm/artifact_test.go | 8 ++--- builder/azure/arm/builder.go | 2 +- builder/azure/arm/config.go | 4 +-- builder/azure/arm/config_test.go | 7 ++--- builder/azure/arm/step_capture_image_test.go | 8 ++--- .../arm/step_create_resource_group_test.go | 6 ++-- .../arm/step_delete_resource_group_test.go | 2 +- .../azure/arm/step_deploy_template_test.go | 4 +-- .../azure/arm/step_get_certificate_test.go | 4 +-- builder/azure/arm/step_get_ip_address_test.go | 4 +-- builder/azure/arm/step_get_os_disk_test.go | 4 +-- .../azure/arm/step_power_off_compute_test.go | 4 +-- builder/azure/arm/step_test.go | 6 ++-- .../azure/arm/step_validate_template_test.go | 4 +-- builder/azure/common/devicelogin.go | 8 ++--- .../azure/common/interruptible_task_test.go | 2 +- builder/azure/common/lin/step_create_cert.go | 12 ++++---- .../azure/common/lin/step_generalize_os.go | 2 +- .../azure/common/template/template_builder.go | 8 ++--- .../template/template_parameters_test.go | 30 +++++++++---------- builder/azure/common/vault.go | 4 +-- builder/azure/pkcs12/bmp-string_test.go | 2 +- builder/azure/pkcs12/pkcs12.go | 2 +- builder/azure/pkcs12/pkcs12_test.go | 2 +- builder/azure/pkcs12/pkcs8.go | 2 +- builder/azure/pkcs12/pkcs8_test.go | 2 +- builder/azure/pkcs12/safebags_test.go | 2 +- 27 files changed, 72 insertions(+), 73 deletions(-) diff --git a/builder/azure/arm/artifact_test.go b/builder/azure/arm/artifact_test.go index a60e27a9d..e7900ff53 100644 --- a/builder/azure/arm/artifact_test.go +++ b/builder/azure/arm/artifact_test.go @@ -16,7 +16,7 @@ func getFakeSasUrl(name string) string { func TestArtifactString(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -57,7 +57,7 @@ func TestArtifactString(t *testing.T) { func TestArtifactProperties(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -97,7 +97,7 @@ func TestArtifactProperties(t *testing.T) { func TestArtifactOverHypenatedCaptureUri(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ @@ -134,7 +134,7 @@ func TestArtifactRejectMalformedTemplates(t *testing.T) { func TestArtifactRejectMalformedStorageUri(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ - CaptureResources{ + { Properties: CaptureProperties{ StorageProfile: CaptureStorageProfile{ OSDisk: CaptureDisk{ diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 95eb8811d..ac79d2d74 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -228,7 +228,7 @@ func (b *Builder) getServicePrincipalTokens(say func(string)) (*azure.ServicePri var err error if b.config.useDeviceLogin { - servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.SubscriptionID, b.config.TenantID, say) + servicePrincipalToken, err = packerAzureCommon.Authenticate(*b.config.cloudEnvironment, b.config.TenantID, say) if err != nil { return nil, nil, err } diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 660dca94c..aba92b817 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -121,7 +121,7 @@ func (c *Config) toVirtualMachineCaptureParameters() *compute.VirtualMachineCapt func (c *Config) createCertificate() (string, error) { privateKey, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { - err := fmt.Errorf("Failed to Generate Private Key: %s", err) + err = fmt.Errorf("Failed to Generate Private Key: %s", err) return "", err } @@ -131,7 +131,7 @@ func (c *Config) createCertificate() (string, error) { serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) if err != nil { - err := fmt.Errorf("Failed to Generate Serial Number: %v", err) + err = fmt.Errorf("Failed to Generate Serial Number: %v", err) return "", err } diff --git a/builder/azure/arm/config_test.go b/builder/azure/arm/config_test.go index 780e02889..ae66cc09b 100644 --- a/builder/azure/arm/config_test.go +++ b/builder/azure/arm/config_test.go @@ -4,7 +4,6 @@ package arm import ( - "fmt" "strings" "testing" "time" @@ -345,7 +344,7 @@ func TestUseDeviceLoginIsDisabledForWindows(t *testing.T) { _, _, err := newConfig(config, getPackerConfiguration()) if err == nil { - t.Fatalf("Expected test to fail, but it succeeded") + t.Fatal("Expected test to fail, but it succeeded") } multiError, _ := err.(*packer.MultiError) @@ -465,7 +464,7 @@ func TestConfigShouldRejectMalformedCaptureContainerName(t *testing.T) { func getArmBuilderConfiguration() map[string]string { m := make(map[string]string) for _, v := range requiredConfigValues { - m[v] = fmt.Sprintf("ignored00") + m[v] = "ignored00" } m["communicator"] = "none" @@ -476,7 +475,7 @@ func getArmBuilderConfiguration() map[string]string { func getArmBuilderConfigurationWithWindows() map[string]string { m := make(map[string]string) for _, v := range requiredConfigValues { - m[v] = fmt.Sprintf("ignored00") + m[v] = "ignored00" } m["object_id"] = "ignored00" diff --git a/builder/azure/arm/step_capture_image_test.go b/builder/azure/arm/step_capture_image_test.go index 66a18c0df..f1fe2c06a 100644 --- a/builder/azure/arm/step_capture_image_test.go +++ b/builder/azure/arm/step_capture_image_test.go @@ -97,19 +97,19 @@ func TestStepCaptureImageShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedCaptureTemplate = stateBag.Get(constants.ArmCaptureTemplate).(*CaptureTemplate) if actualComputeName != expectedComputeName { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmComputeName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualVirtualMachineCaptureParameters != expectedVirtualMachineCaptureParameters { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmVirtualMachineCaptureParameters' from the state bag, but it did not.") } if actualCaptureTemplate != expectedCaptureTemplate { - t.Fatalf("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.") + t.Fatal("Expected StepCaptureImage to source 'constants.ArmCaptureTemplate' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_create_resource_group_test.go b/builder/azure/arm/step_create_resource_group_test.go index 02cdac66a..ff53e59df 100644 --- a/builder/azure/arm/step_create_resource_group_test.go +++ b/builder/azure/arm/step_create_resource_group_test.go @@ -74,16 +74,16 @@ func TestStepCreateResourceGroupShouldTakeStepArgumentsFromStateBag(t *testing.T var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualLocation != expectedLocation { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } _, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated) if !ok { - t.Fatalf("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.") + t.Fatal("Expected the step to add item to stateBag['constants.ArmIsResourceGroupCreated'], but it did not.") } } diff --git a/builder/azure/arm/step_delete_resource_group_test.go b/builder/azure/arm/step_delete_resource_group_test.go index bd6bf79cc..310116d0f 100644 --- a/builder/azure/arm/step_delete_resource_group_test.go +++ b/builder/azure/arm/step_delete_resource_group_test.go @@ -63,7 +63,7 @@ func TestStepDeleteResourceGroupShouldDeleteStateBagArmResourceGroupCreated(t *t value, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated) if !ok { - t.Fatalf("Expected the resource bag value arm.IsResourceGroupCreated to exist") + t.Fatal("Expected the resource bag value arm.IsResourceGroupCreated to exist") } if value.(bool) { diff --git a/builder/azure/arm/step_deploy_template_test.go b/builder/azure/arm/step_deploy_template_test.go index 2e19ca33e..171c2659a 100644 --- a/builder/azure/arm/step_deploy_template_test.go +++ b/builder/azure/arm/step_deploy_template_test.go @@ -77,11 +77,11 @@ func TestStepDeployTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualDeploymentName != expectedDeploymentName { - t.Fatalf("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.") + t.Fatal("Expected StepValidateTemplate to source 'constants.ArmDeploymentName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_get_certificate_test.go b/builder/azure/arm/step_get_certificate_test.go index ebeb5227c..46b105291 100644 --- a/builder/azure/arm/step_get_certificate_test.go +++ b/builder/azure/arm/step_get_certificate_test.go @@ -77,10 +77,10 @@ func TestStepGetCertificateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedKeyVaultName = stateBag.Get(constants.ArmKeyVaultName).(string) if actualKeyVaultName != expectedKeyVaultName { - t.Fatalf("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.") + t.Fatal("Expected StepGetCertificate to source 'constants.ArmKeyVaultName' from the state bag, but it did not.") } if actualSecretName != DefaultSecretName { - t.Fatalf("Expected StepGetCertificate to use default value for secret, but it did not.") + t.Fatal("Expected StepGetCertificate to use default value for secret, but it did not.") } expectedCertificateUrl, ok := stateBag.GetOk(constants.ArmCertificateUrl) diff --git a/builder/azure/arm/step_get_ip_address_test.go b/builder/azure/arm/step_get_ip_address_test.go index 3240083c6..8f35ad8da 100644 --- a/builder/azure/arm/step_get_ip_address_test.go +++ b/builder/azure/arm/step_get_ip_address_test.go @@ -75,11 +75,11 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedIPAddressName = stateBag.Get(constants.ArmPublicIPAddressName).(string) if actualIPAddressName != expectedIPAddressName { - t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.") + t.Fatal("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } expectedIPAddress, ok := stateBag.GetOk(constants.SSHHost) diff --git a/builder/azure/arm/step_get_os_disk_test.go b/builder/azure/arm/step_get_os_disk_test.go index 298cb4ef4..2062fd444 100644 --- a/builder/azure/arm/step_get_os_disk_test.go +++ b/builder/azure/arm/step_get_os_disk_test.go @@ -82,11 +82,11 @@ func TestStepGetOSDiskShouldTakeValidateArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualComputeName != expectedComputeName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } expectedOSDiskVhd, ok := stateBag.GetOk(constants.ArmOSDiskVhd) diff --git a/builder/azure/arm/step_power_off_compute_test.go b/builder/azure/arm/step_power_off_compute_test.go index a3ceaa7dd..a1b8a7b37 100644 --- a/builder/azure/arm/step_power_off_compute_test.go +++ b/builder/azure/arm/step_power_off_compute_test.go @@ -75,11 +75,11 @@ func TestStepPowerOffComputeShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualComputeName != expectedComputeName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/arm/step_test.go b/builder/azure/arm/step_test.go index f0c365bf1..b0f2bfe81 100644 --- a/builder/azure/arm/step_test.go +++ b/builder/azure/arm/step_test.go @@ -14,7 +14,7 @@ import ( func TestProcessStepResultShouldContinueForNonErrors(t *testing.T) { stateBag := new(multistep.BasicStateBag) - code := processStepResult(nil, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processStepResult(nil, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } @@ -49,7 +49,7 @@ func TestProcessStepResultShouldContinueOnSuccessfulTask(t *testing.T) { Err: nil, } - code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } @@ -66,7 +66,7 @@ func TestProcessStepResultShouldHaltWhenTaskIsCancelled(t *testing.T) { Err: nil, } - code := processInterruptibleResult(result, func(error) { t.Fatalf("Should not be called!") }, stateBag) + code := processInterruptibleResult(result, func(error) { t.Fatal("Should not be called!") }, stateBag) if _, ok := stateBag.GetOk(constants.Error); ok { t.Errorf("Error was nil, but was still in the state bag.") } diff --git a/builder/azure/arm/step_validate_template_test.go b/builder/azure/arm/step_validate_template_test.go index 887638aac..eb82a8848 100644 --- a/builder/azure/arm/step_validate_template_test.go +++ b/builder/azure/arm/step_validate_template_test.go @@ -75,11 +75,11 @@ func TestStepValidateTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) if actualDeploymentName != expectedDeploymentName { - t.Fatalf("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmDeploymentName' from the state bag, but it did not.") } if actualResourceGroupName != expectedResourceGroupName { - t.Fatalf("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") + t.Fatal("Expected the step to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } } diff --git a/builder/azure/common/devicelogin.go b/builder/azure/common/devicelogin.go index d5cd259cd..5e8821f8c 100644 --- a/builder/azure/common/devicelogin.go +++ b/builder/azure/common/devicelogin.go @@ -39,7 +39,7 @@ var ( // Authenticate fetches a token from the local file cache or initiates a consent // flow and waits for token to be obtained. -func Authenticate(env azure.Environment, subscriptionID, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) { +func Authenticate(env azure.Environment, tenantID string, say func(string)) (*azure.ServicePrincipalToken, error) { clientID, ok := clientIDs[env.Name] if !ok { return nil, fmt.Errorf("packer-azure application not set up for Azure environment %q", env.Name) @@ -81,7 +81,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu // will go stale every 14 days and we will delete the token file, // re-initiate the device flow. say("Validating the token.") - if err := validateToken(env, spt); err != nil { + if err = validateToken(env, spt); err != nil { say(fmt.Sprintf("Error: %v", err)) say("Stored Azure credentials expired. Please reauthenticate.") say(fmt.Sprintf("Deleting %s", tokenPath)) @@ -96,7 +96,7 @@ func Authenticate(env azure.Environment, subscriptionID, tenantID string, say fu // Start an OAuth 2.0 device flow say(fmt.Sprintf("Initiating device flow: %s", tokenPath)) - spt, err = tokenFromDeviceFlow(say, *oauthCfg, tokenPath, clientID, apiScope) + spt, err = tokenFromDeviceFlow(say, *oauthCfg, clientID, apiScope) if err != nil { return nil, err } @@ -136,7 +136,7 @@ func tokenFromFile(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clie // consent application on a browser and in the meanwhile the authentication // endpoint is polled until user gives consent, denies or the flow times out. // Returned token must be saved. -func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, tokenPath, clientID, resource string) (*azure.ServicePrincipalToken, error) { +func tokenFromDeviceFlow(say func(string), oauthCfg azure.OAuthConfig, clientID, resource string) (*azure.ServicePrincipalToken, error) { cl := autorest.NewClientWithUserAgent(userAgent) deviceCode, err := azure.InitiateDeviceAuth(&cl, oauthCfg, clientID, resource) if err != nil { diff --git a/builder/azure/common/interruptible_task_test.go b/builder/azure/common/interruptible_task_test.go index 22a969700..44e849f62 100644 --- a/builder/azure/common/interruptible_task_test.go +++ b/builder/azure/common/interruptible_task_test.go @@ -20,7 +20,7 @@ func TestInterruptibleTaskShouldImmediatelyEndOnCancel(t *testing.T) { result := testSubject.Run() if result.IsCancelled != true { - t.Fatalf("Expected the task to be cancelled, but it was not.") + t.Fatal("Expected the task to be cancelled, but it was not.") } } diff --git a/builder/azure/common/lin/step_create_cert.go b/builder/azure/common/lin/step_create_cert.go index d8b7ef48a..08b60f45a 100644 --- a/builder/azure/common/lin/step_create_cert.go +++ b/builder/azure/common/lin/step_create_cert.go @@ -32,7 +32,7 @@ func (s *StepCreateCert) Run(state multistep.StateBag) multistep.StepAction { err := s.createCert(state) if err != nil { - err := fmt.Errorf("Error creating temporary certificate: %s", err) + err = fmt.Errorf("Error creating temporary certificate: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt @@ -45,11 +45,11 @@ func (s *StepCreateCert) Cleanup(state multistep.StateBag) {} func (s *StepCreateCert) createCert(state multistep.StateBag) error { - log.Printf("createCert: Generating RSA key pair...") + log.Println("createCert: Generating RSA key pair...") priv, err := rsa.GenerateKey(rand.Reader, 2048) if err != nil { - err := fmt.Errorf("Failed to Generate Private Key: %s", err) + err = fmt.Errorf("Failed to Generate Private Key: %s", err) return err } @@ -63,7 +63,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { state.Put(constants.PrivateKey, privkey) log.Printf("createCert: Private key:\n%s", privkey) - log.Printf("createCert: Creating certificate...") + log.Println("createCert: Creating certificate...") host := fmt.Sprintf("%s.cloudapp.net", s.TmpServiceName) notBefore := time.Now() @@ -71,7 +71,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { serialNumber, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 128)) if err != nil { - err := fmt.Errorf("Failed to Generate Serial Number: %v", err) + err = fmt.Errorf("Failed to Generate Serial Number: %v", err) return err } @@ -93,7 +93,7 @@ func (s *StepCreateCert) createCert(state multistep.StateBag) error { derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) if err != nil { - err := fmt.Errorf("Failed to Create Certificate: %s", err) + err = fmt.Errorf("Failed to Create Certificate: %s", err) return err } diff --git a/builder/azure/common/lin/step_generalize_os.go b/builder/azure/common/lin/step_generalize_os.go index f377cb3e3..e36d39009 100644 --- a/builder/azure/common/lin/step_generalize_os.go +++ b/builder/azure/common/lin/step_generalize_os.go @@ -29,7 +29,7 @@ func (s *StepGeneralizeOS) Run(state multistep.StateBag) multistep.StepAction { } if err := comm.Start(cmd); err != nil { - err := fmt.Errorf("Failed executing OS generalization command: %s", err) + err = fmt.Errorf("Failed executing OS generalization command: %s", err) state.Put("error", err) ui.Error(err.Error()) return multistep.ActionHalt diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index 0b0ba1809..d69d782e7 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -46,7 +46,7 @@ func (s *TemplateBuilder) BuildLinux(sshAuthorizedKey string) error { profile.LinuxConfiguration = &compute.LinuxConfiguration{ SSH: &compute.SSHConfiguration{ PublicKeys: &[]compute.SSHPublicKey{ - compute.SSHPublicKey{ + { Path: to.StringPtr(s.toVariable(variableSshKeyPath)), KeyData: to.StringPtr(sshAuthorizedKey), }, @@ -66,12 +66,12 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string) profile := resource.Properties.OsProfile profile.Secrets = &[]compute.VaultSecretGroup{ - compute.VaultSecretGroup{ + { SourceVault: &compute.SubResource{ ID: to.StringPtr(s.toResourceID(resourceKeyVaults, keyVaultName)), }, VaultCertificates: &[]compute.VaultCertificate{ - compute.VaultCertificate{ + { CertificateStore: to.StringPtr("My"), CertificateURL: to.StringPtr(winRMCertificateUrl), }, @@ -83,7 +83,7 @@ func (s *TemplateBuilder) BuildWindows(keyVaultName, winRMCertificateUrl string) ProvisionVMAgent: to.BoolPtr(true), WinRM: &compute.WinRMConfiguration{ Listeners: &[]compute.WinRMListener{ - compute.WinRMListener{ + { Protocol: "https", CertificateURL: to.StringPtr(winRMCertificateUrl), }, diff --git a/builder/azure/common/template/template_parameters_test.go b/builder/azure/common/template/template_parameters_test.go index b3bedfcff..d9f12ad82 100644 --- a/builder/azure/common/template/template_parameters_test.go +++ b/builder/azure/common/template/template_parameters_test.go @@ -12,13 +12,13 @@ import ( func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"sentinel"}, - AdminPassword: &TemplateParameter{"sentinel"}, - DnsNameForPublicIP: &TemplateParameter{"sentinel"}, - OSDiskName: &TemplateParameter{"sentinel"}, - StorageAccountBlobEndpoint: &TemplateParameter{"sentinel"}, - VMName: &TemplateParameter{"sentinel"}, - VMSize: &TemplateParameter{"sentinel"}, + AdminUsername: &TemplateParameter{Value: "sentinel"}, + AdminPassword: &TemplateParameter{Value: "sentinel"}, + DnsNameForPublicIP: &TemplateParameter{Value: "sentinel"}, + OSDiskName: &TemplateParameter{Value: "sentinel"}, + StorageAccountBlobEndpoint: &TemplateParameter{Value: "sentinel"}, + VMName: &TemplateParameter{Value: "sentinel"}, + VMSize: &TemplateParameter{Value: "sentinel"}, } bs, err := json.Marshal(params) @@ -53,13 +53,13 @@ func TestTemplateParametersShouldHaveExpectedKeys(t *testing.T) { func TestParameterValuesShouldBeSet(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"adminusername00"}, - AdminPassword: &TemplateParameter{"adminpassword00"}, - DnsNameForPublicIP: &TemplateParameter{"dnsnameforpublicip00"}, - OSDiskName: &TemplateParameter{"osdiskname00"}, - StorageAccountBlobEndpoint: &TemplateParameter{"storageaccountblobendpoint00"}, - VMName: &TemplateParameter{"vmname00"}, - VMSize: &TemplateParameter{"vmsize00"}, + AdminUsername: &TemplateParameter{Value: "adminusername00"}, + AdminPassword: &TemplateParameter{Value: "adminpassword00"}, + DnsNameForPublicIP: &TemplateParameter{Value: "dnsnameforpublicip00"}, + OSDiskName: &TemplateParameter{Value: "osdiskname00"}, + StorageAccountBlobEndpoint: &TemplateParameter{Value: "storageaccountblobendpoint00"}, + VMName: &TemplateParameter{Value: "vmname00"}, + VMSize: &TemplateParameter{Value: "vmsize00"}, } bs, err := json.Marshal(params) @@ -89,7 +89,7 @@ func TestParameterValuesShouldBeSet(t *testing.T) { func TestEmptyValuesShouldBeOmitted(t *testing.T) { params := TemplateParameters{ - AdminUsername: &TemplateParameter{"adminusername00"}, + AdminUsername: &TemplateParameter{Value: "adminusername00"}, } bs, err := json.Marshal(params) diff --git a/builder/azure/common/vault.go b/builder/azure/common/vault.go index 27909958a..e0eea671c 100644 --- a/builder/azure/common/vault.go +++ b/builder/azure/common/vault.go @@ -25,8 +25,8 @@ type VaultClient struct { } type Secret struct { - ID *string `json:"id,omitempty"` - Value string `json:"value"` + ID *string `json:"id,omitempty"` + Value string `json:"value"` } func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, error) { diff --git a/builder/azure/pkcs12/bmp-string_test.go b/builder/azure/pkcs12/bmp-string_test.go index 85dd96fb4..fcbc7b7b1 100644 --- a/builder/azure/pkcs12/bmp-string_test.go +++ b/builder/azure/pkcs12/bmp-string_test.go @@ -29,7 +29,7 @@ func decodeBMPString(bmpString []byte) (string, error) { func TestBMPStringDecode(t *testing.T) { _, err := decodeBMPString([]byte("a")) if err == nil { - t.Fatalf("expected decode to fail, but it succeeded") + t.Fatal("expected decode to fail, but it succeeded") } } diff --git a/builder/azure/pkcs12/pkcs12.go b/builder/azure/pkcs12/pkcs12.go index 5772b2d4d..316c2e731 100644 --- a/builder/azure/pkcs12/pkcs12.go +++ b/builder/azure/pkcs12/pkcs12.go @@ -200,7 +200,7 @@ func makeSalt(saltByteCount int) ([]byte, error) { // // derBytes is a DER encoded certificate. // privateKey is an RSA -func Encode(derBytes []byte, privateKey interface{}, password string) (pfxBytes []byte, err error) { +func Encode(derBytes []byte, privateKey interface{}, password string) ([]byte, error) { secret, err := bmpString(password) if err != nil { return nil, ErrIncorrectPassword diff --git a/builder/azure/pkcs12/pkcs12_test.go b/builder/azure/pkcs12/pkcs12_test.go index b48e618a0..2cfbc44d8 100644 --- a/builder/azure/pkcs12/pkcs12_test.go +++ b/builder/azure/pkcs12/pkcs12_test.go @@ -25,7 +25,7 @@ func TestPfxRoundTriRsa(t *testing.T) { actualPrivateKey, ok := key.(*rsa.PrivateKey) if !ok { - t.Fatalf("failed to decode private key") + t.Fatal("failed to decode private key") } if privateKey.D.Cmp(actualPrivateKey.D) != 0 { diff --git a/builder/azure/pkcs12/pkcs8.go b/builder/azure/pkcs12/pkcs8.go index 1eb8850f9..5203d394f 100644 --- a/builder/azure/pkcs12/pkcs8.go +++ b/builder/azure/pkcs12/pkcs8.go @@ -28,7 +28,7 @@ var ( // marshalPKCS8PrivateKey converts a private key to PKCS#8 encoded form. // See http://www.rsa.com/rsalabs/node.asp?id=2130 and RFC5208. -func marshalPKCS8PrivateKey(key interface{}) (der []byte, err error) { +func marshalPKCS8PrivateKey(key interface{}) ([]byte, error) { pkcs := pkcs8{ Version: 0, } diff --git a/builder/azure/pkcs12/pkcs8_test.go b/builder/azure/pkcs12/pkcs8_test.go index 7d12119f5..1f891ef80 100644 --- a/builder/azure/pkcs12/pkcs8_test.go +++ b/builder/azure/pkcs12/pkcs8_test.go @@ -35,7 +35,7 @@ func TestRoundTripPkcs8Rsa(t *testing.T) { } if actualPrivateKey.Validate() != nil { - t.Fatalf("private key did not validate") + t.Fatal("private key did not validate") } if actualPrivateKey.N.Cmp(privateKey.N) != 0 { diff --git a/builder/azure/pkcs12/safebags_test.go b/builder/azure/pkcs12/safebags_test.go index bb30d4e55..384dd5ce3 100644 --- a/builder/azure/pkcs12/safebags_test.go +++ b/builder/azure/pkcs12/safebags_test.go @@ -97,6 +97,6 @@ func TestRoundTripPkcs8ShroudedKeyBag(t *testing.T) { actualPrivateKey := key.(*rsa.PrivateKey) if actualPrivateKey.D.Cmp(privateKey.D) != 0 { - t.Fatalf("failed to round-trip rsa.PrivateKey.D") + t.Fatal("failed to round-trip rsa.PrivateKey.D") } } From ba0f20225846aa83dca2919b0b1b834e9ec35a9d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 18 Jul 2016 22:50:41 +0530 Subject: [PATCH 25/31] Removed redundant print message from post-processor/vsphere Fixes: https://github.com/mitchellh/packer/issues/3387 Signed-off-by: Abhijeet Kasurde --- post-processor/vsphere/post-processor.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index c340662b1..3c76024c0 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -121,8 +121,6 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac ovftool_uri += "/Resources/" + p.config.ResourcePool } - ui.Message(fmt.Sprintf("Uploading %s to vSphere", source)) - args, err := p.BuildArgs(source, ovftool_uri) if err != nil { ui.Message(fmt.Sprintf("Failed: %s\n", err)) From 7d259ab0987c411b0b21a5cd88ca022f89158d72 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Thu, 7 Jul 2016 17:28:47 -0700 Subject: [PATCH 26/31] Update Azure dependencies. * azure-sdk-for-go to 3.1.0-beta * go-autorest to 7.0.7 * dgrijalva/jwt-go to 3.0.0 Add the German cloud configuration. Ensure the different cloud URLs are _actually_ used. --- Godeps/Godeps.json | 69 +- builder/azure/arm/authenticate.go | 6 +- builder/azure/arm/azure_client.go | 22 +- builder/azure/arm/builder.go | 5 +- builder/azure/arm/config.go | 2 + builder/azure/common/devicelogin.go | 12 +- builder/azure/common/vault.go | 28 +- builder/azure/common/vault_test.go | 27 + .../github.com/Azure/azure-sdk-for-go/LICENSE | 2 +- .../arm/compute/availabilitysets.go | 129 +-- .../azure-sdk-for-go/arm/compute/client.go | 8 +- .../azure-sdk-for-go/arm/compute/models.go | 168 ++-- .../arm/compute/usageoperations.go | 16 +- .../azure-sdk-for-go/arm/compute/version.go | 8 +- .../compute/virtualmachineextensionimages.go | 74 +- .../arm/compute/virtualmachineextensions.go | 59 +- .../arm/compute/virtualmachineimages.go | 94 +-- .../arm/compute/virtualmachines.go | 288 ++++--- .../arm/compute/virtualmachinescalesets.go | 319 ++++--- .../arm/compute/virtualmachinescalesetvms.go | 257 +++--- .../arm/compute/virtualmachinesizes.go | 43 +- .../arm/network/applicationgateways.go | 101 ++- .../azure-sdk-for-go/arm/network/client.go | 24 +- .../expressroutecircuitauthorizations.go | 68 +- .../network/expressroutecircuitpeerings.go | 68 +- .../arm/network/expressroutecircuits.go | 431 ++++++---- .../network/expressrouteserviceproviders.go | 14 +- .../arm/network/interfaces.go | 126 ++- .../arm/network/loadbalancers.go | 73 +- .../arm/network/localnetworkgateways.go | 60 +- .../azure-sdk-for-go/arm/network/models.go | 151 ++-- .../arm/network/publicipaddresses.go | 73 +- .../azure-sdk-for-go/arm/network/routes.go | 68 +- .../arm/network/routetables.go | 73 +- .../arm/network/securitygroups.go | 73 +- .../arm/network/securityrules.go | 68 +- .../azure-sdk-for-go/arm/network/subnets.go | 70 +- .../azure-sdk-for-go/arm/network/usages.go | 40 +- .../azure-sdk-for-go/arm/network/version.go | 8 +- .../virtualnetworkgatewayconnections.go | 103 ++- .../arm/network/virtualnetworkgateways.go | 88 +- .../arm/network/virtualnetworks.go | 73 +- .../arm/resources/resources/client.go | 133 ++- .../resources/deploymentoperations.go | 37 +- .../arm/resources/resources/deployments.go | 179 ++-- .../arm/resources/resources/groups.go | 171 ++-- .../arm/resources/resources/models.go | 156 ++-- .../resources/resources/policyassignments.go | 786 ------------------ .../resources/resources/policydefinitions.go | 231 ----- .../resources/provideroperationdetails.go | 130 --- .../arm/resources/resources/providers.go | 55 +- .../arm/resources/resources/resources.go | 127 ++- .../arm/resources/resources/tags.go | 70 +- .../arm/resources/resources/version.go | 8 +- .../arm/resources/subscriptions/client.go | 71 +- .../arm/resources/subscriptions/models.go | 32 +- .../resources/subscriptions/subscriptions.go | 63 +- .../arm/resources/subscriptions/tenants.go | 16 +- .../arm/resources/subscriptions/version.go | 6 +- .../azure-sdk-for-go/arm/storage/accounts.go | 173 ++-- .../azure-sdk-for-go/arm/storage/client.go | 8 +- .../azure-sdk-for-go/arm/storage/models.go | 120 ++- .../arm/storage/usageoperations.go | 14 +- .../azure-sdk-for-go/arm/storage/version.go | 8 +- .../Azure/azure-sdk-for-go/storage/blob.go | 67 +- .../Azure/azure-sdk-for-go/storage/client.go | 110 ++- .../Azure/azure-sdk-for-go/storage/table.go | 129 +++ .../storage/table_entities.go | 351 ++++++++ .../Azure/go-autorest/autorest/azure/async.go | 3 +- .../Azure/go-autorest/autorest/azure/azure.go | 33 +- .../autorest/azure/environments.go | 76 +- .../Azure/go-autorest/autorest/azure/token.go | 4 +- .../Azure/go-autorest/autorest/client.go | 39 +- .../Azure/go-autorest/autorest/error.go | 2 +- .../Azure/go-autorest/autorest/preparer.go | 37 +- .../Azure/go-autorest/autorest/sender.go | 39 +- .../Azure/go-autorest/autorest/utility.go | 58 ++ .../github.com/dgrijalva/jwt-go/.travis.yml | 5 +- .../dgrijalva/jwt-go/MIGRATION_GUIDE.md | 96 +++ vendor/github.com/dgrijalva/jwt-go/README.md | 49 +- .../dgrijalva/jwt-go/VERSION_HISTORY.md | 38 + vendor/github.com/dgrijalva/jwt-go/claims.go | 134 +++ vendor/github.com/dgrijalva/jwt-go/ecdsa.go | 4 +- vendor/github.com/dgrijalva/jwt-go/errors.go | 36 +- vendor/github.com/dgrijalva/jwt-go/hmac.go | 2 +- .../github.com/dgrijalva/jwt-go/map_claims.go | 94 +++ vendor/github.com/dgrijalva/jwt-go/none.go | 52 ++ vendor/github.com/dgrijalva/jwt-go/parser.go | 62 +- vendor/github.com/dgrijalva/jwt-go/rsa.go | 30 +- vendor/github.com/dgrijalva/jwt-go/rsa_pss.go | 2 +- .../github.com/dgrijalva/jwt-go/rsa_utils.go | 3 +- .../dgrijalva/jwt-go/signing_method.go | 11 + vendor/github.com/dgrijalva/jwt-go/token.go | 52 +- website/source/docs/builders/azure.html.md | 2 +- 94 files changed, 3975 insertions(+), 3728 deletions(-) create mode 100644 builder/azure/common/vault_test.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policyassignments.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policydefinitions.go delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/provideroperationdetails.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/storage/table.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go create mode 100644 vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md create mode 100644 vendor/github.com/dgrijalva/jwt-go/claims.go create mode 100644 vendor/github.com/dgrijalva/jwt-go/map_claims.go create mode 100644 vendor/github.com/dgrijalva/jwt-go/none.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 548b82018..54c0b2b7b 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -10,53 +10,53 @@ }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/resources/resources", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/azure-sdk-for-go/storage", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v3.1.0-beta", + "Rev": "902d95d9f311ae585ee98cfd18f418b467d60d5a" }, { "ImportPath": "github.com/Azure/go-autorest/autorest", - "Comment": "v7.0.6", - "Rev": "451ba0760a7fd73d7175e2d3d1c3911020619561" + "Comment": "v7.0.7", + "Rev": "6f40a8acfe03270d792cb8155e2942c09d7cff95" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/azure", - "Comment": "v7.0.6", - "Rev": "451ba0760a7fd73d7175e2d3d1c3911020619561" + "Comment": "v7.0.7", + "Rev": "6f40a8acfe03270d792cb8155e2942c09d7cff95" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/date", - "Comment": "v7.0.6", - "Rev": "451ba0760a7fd73d7175e2d3d1c3911020619561" + "Comment": "v7.0.7", + "Rev": "6f40a8acfe03270d792cb8155e2942c09d7cff95" }, { "ImportPath": "github.com/Azure/go-autorest/autorest/to", - "Comment": "v7.0.6", - "Rev": "451ba0760a7fd73d7175e2d3d1c3911020619561" + "Comment": "v7.0.7", + "Rev": "6f40a8acfe03270d792cb8155e2942c09d7cff95" }, { "ImportPath": "github.com/Azure/go-ntlmssp", @@ -211,8 +211,8 @@ }, { "ImportPath": "github.com/dgrijalva/jwt-go", - "Comment": "v2.4.0-11-gf219341", - "Rev": "f2193411bd642f7db03249fd79d5292c9b34916a" + "Comment": "v3.0.0", + "Rev": "d2709f9f1f31ebcda9651b03077758c1f3a0018c" }, { "ImportPath": "github.com/digitalocean/godo", @@ -632,6 +632,31 @@ { "ImportPath": "gopkg.in/xmlpath.v2", "Rev": "860cbeca3ebcc600db0b213c0e83ad6ce91f5739" + }, + { + "ImportPath": "github.com/Azure/azure-sdk-for-go/vendor/github.com/Azure/go-autorest/autorest", + "Comment": "v7.0.5-4-g0a0ee7d", + "Rev": "0a0ee7d5b9b1b3d980434cbb0afff33e9ca9e907" + }, + { + "ImportPath": "github.com/Azure/azure-sdk-for-go/vendor/github.com/Azure/go-autorest/autorest/azure", + "Comment": "v7.0.5-4-g0a0ee7d", + "Rev": "0a0ee7d5b9b1b3d980434cbb0afff33e9ca9e907" + }, + { + "ImportPath": "github.com/Azure/azure-sdk-for-go/vendor/github.com/Azure/go-autorest/autorest/date", + "Comment": "v7.0.5-4-g0a0ee7d", + "Rev": "0a0ee7d5b9b1b3d980434cbb0afff33e9ca9e907" + }, + { + "ImportPath": "github.com/Azure/azure-sdk-for-go/vendor/github.com/Azure/go-autorest/autorest/to", + "Comment": "v7.0.5-4-g0a0ee7d", + "Rev": "0a0ee7d5b9b1b3d980434cbb0afff33e9ca9e907" + }, + { + "ImportPath": "github.com/Azure/azure-sdk-for-go/vendor/github.com/dgrijalva/jwt-go", + "Comment": "v3.0.0-2-gf077707", + "Rev": "f0777076321ab64f6efc15a82d9d23b98539b943" } ] } diff --git a/builder/azure/arm/authenticate.go b/builder/azure/arm/authenticate.go index 54178eb87..75f3f9c87 100644 --- a/builder/azure/arm/authenticate.go +++ b/builder/azure/arm/authenticate.go @@ -26,7 +26,7 @@ func (a *Authenticate) getServicePrincipalToken() (*azure.ServicePrincipalToken, } func (a *Authenticate) getServicePrincipalTokenWithResource(resource string) (*azure.ServicePrincipalToken, error) { - oauthConfig, err := newOAuthConfigWithTenant(a.tenantID) + oauthConfig, err := a.env.OAuthConfigForTenant(a.tenantID) if err != nil { return nil, err } @@ -39,7 +39,3 @@ func (a *Authenticate) getServicePrincipalTokenWithResource(resource string) (*a return spt, err } - -func newOAuthConfigWithTenant(tenantID string) (*azure.OAuthConfig, error) { - return azure.PublicCloud.OAuthConfigForTenant(tenantID) -} diff --git a/builder/azure/arm/azure_client.go b/builder/azure/arm/azure_client.go index 4e60b7467..546bf9fb1 100644 --- a/builder/azure/arm/azure_client.go +++ b/builder/azure/arm/azure_client.go @@ -8,6 +8,7 @@ import ( "fmt" "math" "net/http" + "net/url" "os" "strconv" @@ -102,6 +103,7 @@ func byConcatDecorators(decorators ...autorest.RespondDecorator) autorest.Respon } func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string, + cloud *azure.Environment, servicePrincipalToken, servicePrincipalTokenVault *azure.ServicePrincipalToken) (*AzureClient, error) { var azureClient = &AzureClient{} @@ -113,32 +115,42 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string azureClient.DeploymentsClient.RequestInspector = withInspection(maxlen) azureClient.DeploymentsClient.ResponseInspector = byInspecting(maxlen) azureClient.DeploymentsClient.UserAgent += packerUserAgent + azureClient.DeploymentsClient.BaseURI = cloud.ResourceManagerEndpoint azureClient.GroupsClient = resources.NewGroupsClient(subscriptionID) azureClient.GroupsClient.Authorizer = servicePrincipalToken azureClient.GroupsClient.RequestInspector = withInspection(maxlen) azureClient.GroupsClient.ResponseInspector = byInspecting(maxlen) azureClient.GroupsClient.UserAgent += packerUserAgent + azureClient.GroupsClient.BaseURI = cloud.ResourceManagerEndpoint azureClient.PublicIPAddressesClient = network.NewPublicIPAddressesClient(subscriptionID) azureClient.PublicIPAddressesClient.Authorizer = servicePrincipalToken azureClient.PublicIPAddressesClient.RequestInspector = withInspection(maxlen) azureClient.PublicIPAddressesClient.ResponseInspector = byInspecting(maxlen) azureClient.PublicIPAddressesClient.UserAgent += packerUserAgent + azureClient.PublicIPAddressesClient.BaseURI = cloud.ResourceManagerEndpoint azureClient.VirtualMachinesClient = compute.NewVirtualMachinesClient(subscriptionID) azureClient.VirtualMachinesClient.Authorizer = servicePrincipalToken azureClient.VirtualMachinesClient.RequestInspector = withInspection(maxlen) azureClient.VirtualMachinesClient.ResponseInspector = byConcatDecorators(byInspecting(maxlen), templateCapture(azureClient)) azureClient.VirtualMachinesClient.UserAgent += packerUserAgent + azureClient.VirtualMachinesClient.BaseURI = cloud.ResourceManagerEndpoint azureClient.AccountsClient = armStorage.NewAccountsClient(subscriptionID) azureClient.AccountsClient.Authorizer = servicePrincipalToken azureClient.AccountsClient.RequestInspector = withInspection(maxlen) azureClient.AccountsClient.ResponseInspector = byInspecting(maxlen) azureClient.AccountsClient.UserAgent += packerUserAgent + azureClient.AccountsClient.BaseURI = cloud.ResourceManagerEndpoint - azureClient.VaultClient = common.VaultClient{} + keyVaultURL, err := url.Parse(cloud.KeyVaultEndpoint) + if err != nil { + return nil, err + } + + azureClient.VaultClient = common.NewVaultClient(*keyVaultURL) azureClient.VaultClient.Authorizer = servicePrincipalTokenVault azureClient.VaultClient.RequestInspector = withInspection(maxlen) azureClient.VaultClient.ResponseInspector = byInspecting(maxlen) @@ -149,7 +161,13 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string return nil, err } - storageClient, err := storage.NewBasicClient(storageAccountName, *accountKeys.Key1) + storageClient, err := storage.NewClient( + storageAccountName, + *(*accountKeys.Keys)[0].Value, + cloud.StorageEndpointSuffix, + storage.DefaultAPIVersion, + true /*useHttps*/) + if err != nil { return nil, err } diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 95eb8811d..dcf897451 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -74,6 +74,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe b.config.SubscriptionID, b.config.ResourceGroupName, b.config.StorageAccount, + b.config.cloudEnvironment, spnCloud, spnKeyVault) @@ -240,7 +241,9 @@ func (b *Builder) getServicePrincipalTokens(say func(string)) (*azure.ServicePri return nil, nil, err } - servicePrincipalTokenVault, err = auth.getServicePrincipalTokenWithResource(packerAzureCommon.AzureVaultScope) + servicePrincipalTokenVault, err = auth.getServicePrincipalTokenWithResource( + strings.TrimRight(b.config.cloudEnvironment.KeyVaultEndpoint, "/")) + if err != nil { return nil, nil, err } diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 660dca94c..1d2cd632d 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -303,6 +303,8 @@ func setCloudEnvironment(c *Config) error { switch name { case "CHINA", "CHINACLOUD", "AZURECHINACLOUD": c.cloudEnvironment = &azure.ChinaCloud + case "GERMAN", "GERMANCLOUD", "AZUREGERMANCLOUD": + c.cloudEnvironment = &azure.GermanCloud case "PUBLIC", "PUBLICCLOUD", "AZUREPUBLICCLOUD": c.cloudEnvironment = &azure.PublicCloud case "USGOVERNMENT", "USGOVERNMENTCLOUD", "AZUREUSGOVERNMENTCLOUD": diff --git a/builder/azure/common/devicelogin.go b/builder/azure/common/devicelogin.go index d5cd259cd..700b2b4f8 100644 --- a/builder/azure/common/devicelogin.go +++ b/builder/azure/common/devicelogin.go @@ -231,7 +231,13 @@ func FindTenantID(env azure.Environment, subscriptionID string) (string, error) } func subscriptionsClient(baseURI string) subscriptions.Client { - c := subscriptions.NewClientWithBaseURI(baseURI, "") // used only for unauthenticated requests for generic subs IDs - c.Client.UserAgent += userAgent - return c + client := subscriptions.Client{ + subscriptions.ManagementClient{ + Client: autorest.NewClientWithUserAgent(subscriptions.UserAgent() + userAgent), + BaseURI: baseURI, + APIVersion: subscriptions.APIVersion, + }, + } + + return client } diff --git a/builder/azure/common/vault.go b/builder/azure/common/vault.go index 3ab48c692..452d221f6 100644 --- a/builder/azure/common/vault.go +++ b/builder/azure/common/vault.go @@ -9,19 +9,24 @@ package common import ( "fmt" "net/http" - "strings" + "net/url" "github.com/Azure/go-autorest/autorest" ) const ( - AzureVaultApiVersion = "2015-06-01" - AzureVaultScope = "https://vault.azure.net" - AzureVaultSecretTemplate = "https://{vault-name}.vault.azure.net/secrets/{secret-name}" + AzureVaultApiVersion = "2015-06-01" ) type VaultClient struct { autorest.Client + keyVaultEndpoint url.URL +} + +func NewVaultClient(keyVaultEndpoint url.URL) VaultClient { + return VaultClient{ + keyVaultEndpoint: keyVaultEndpoint, + } } type Secret struct { @@ -38,18 +43,17 @@ type SecretAttributes struct { func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, error) { p := map[string]interface{}{ - "secret-name": secretName, + "secret-name": autorest.Encode("path", secretName), } q := map[string]interface{}{ "api-version": AzureVaultApiVersion, } - secretURL := strings.Replace(AzureVaultSecretTemplate, "{vault-name}", vaultName, -1) - - req, err := autorest.Prepare(&http.Request{}, + req, err := autorest.Prepare( + &http.Request{}, autorest.AsGet(), - autorest.WithBaseURL(secretURL), - autorest.WithPathParameters(p), + autorest.WithBaseURL(client.getVaultUrl(vaultName)), + autorest.WithPathParameters("/secrets/{secret-name}", p), autorest.WithQueryParameters(q)) if err != nil { @@ -81,3 +85,7 @@ func (client *VaultClient) GetSecret(vaultName, secretName string) (*Secret, err return &secret, nil } + +func (client *VaultClient) getVaultUrl(vaultName string) string { + return fmt.Sprintf("%s://%s.%s/", client.keyVaultEndpoint.Scheme, vaultName, client.keyVaultEndpoint.Host) +} diff --git a/builder/azure/common/vault_test.go b/builder/azure/common/vault_test.go new file mode 100644 index 000000000..cf7dc65cd --- /dev/null +++ b/builder/azure/common/vault_test.go @@ -0,0 +1,27 @@ +package common + +import ( + "net/url" + "testing" +) + +func TestVaultClientKeyVaultEndpoint(t *testing.T) { + u, _ := url.Parse("https://vault.azure.net") + testSubject := NewVaultClient(*u) + + vaultUrl := testSubject.getVaultUrl("my") + if vaultUrl != "https://my.vault.azure.net/" { + t.Errorf("expected \"https://my.vault.azure.net/\", got %q", vaultUrl) + } +} + +func TestVaultClientKeyVaultEndpointPreserveScheme(t *testing.T) { + u, _ := url.Parse("http://vault.azure.net") + testSubject := NewVaultClient(*u) + + vaultUrl := testSubject.getVaultUrl("my") + if vaultUrl != "http://my.vault.azure.net/" { + t.Errorf("expected \"http://my.vault.azure.net/\", got %q", vaultUrl) + } +} + diff --git a/vendor/github.com/Azure/azure-sdk-for-go/LICENSE b/vendor/github.com/Azure/azure-sdk-for-go/LICENSE index d64569567..af39a91e7 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/LICENSE +++ b/vendor/github.com/Azure/azure-sdk-for-go/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2016 Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go index d2eb1d396..013a6af9a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // AvailabilitySetsClient is the the Compute Management Client. @@ -70,23 +69,23 @@ func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, na // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client AvailabilitySetsClient) CreateOrUpdatePreparer(resourceGroupName string, name string, parameters AvailabilitySet) (*http.Request, error) { pathParameters := map[string]interface{}{ - "name": url.QueryEscape(name), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{name}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{name}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -135,22 +134,21 @@ func (client AvailabilitySetsClient) Delete(resourceGroupName string, availabili // DeletePreparer prepares the Delete request. func (client AvailabilitySetsClient) DeletePreparer(resourceGroupName string, availabilitySetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "availabilitySetName": url.QueryEscape(availabilitySetName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "availabilitySetName": autorest.Encode("path", availabilitySetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteSender sends the Delete request. The method will close the @@ -165,7 +163,7 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return @@ -198,22 +196,21 @@ func (client AvailabilitySetsClient) Get(resourceGroupName string, availabilityS // GetPreparer prepares the Get request. func (client AvailabilitySetsClient) GetPreparer(resourceGroupName string, availabilitySetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "availabilitySetName": url.QueryEscape(availabilitySetName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "availabilitySetName": autorest.Encode("path", availabilitySetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -261,21 +258,20 @@ func (client AvailabilitySetsClient) List(resourceGroupName string) (result Avai // ListPreparer prepares the List request. func (client AvailabilitySetsClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -297,32 +293,8 @@ func (client AvailabilitySetsClient) ListResponder(resp *http.Response) (result return } -// ListNextResults retrieves the next set of results, if any. -func (client AvailabilitySetsClient) ListNextResults(lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) { - req, err := lastResults.AvailabilitySetListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending next results request request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure responding to next results request request") - } - - return -} - -// ListAvailableSizes lists virtual-machine-sizes available to be used for an -// availability set. +// ListAvailableSizes lists all available virtual machine sizes that can be +// used to create a new virtual machine in an existing availability set. // // resourceGroupName is the name of the resource group. availabilitySetName is // the name of the availability set. @@ -349,22 +321,21 @@ func (client AvailabilitySetsClient) ListAvailableSizes(resourceGroupName string // ListAvailableSizesPreparer prepares the ListAvailableSizes request. func (client AvailabilitySetsClient) ListAvailableSizesPreparer(resourceGroupName string, availabilitySetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "availabilitySetName": url.QueryEscape(availabilitySetName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "availabilitySetName": autorest.Encode("path", availabilitySetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAvailableSizesSender sends the ListAvailableSizes request. The method will close the @@ -385,27 +356,3 @@ func (client AvailabilitySetsClient) ListAvailableSizesResponder(resp *http.Resp result.Response = autorest.Response{Response: resp} return } - -// ListAvailableSizesNextResults retrieves the next set of results, if any. -func (client AvailabilitySetsClient) ListAvailableSizesNextResults(lastResults VirtualMachineSizeListResult) (result VirtualMachineSizeListResult, err error) { - req, err := lastResults.VirtualMachineSizeListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListAvailableSizesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending next results request request") - } - - result, err = client.ListAvailableSizesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go index 5ed123ca2..e8f3fb3e6 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go @@ -1,5 +1,5 @@ // Package compute implements the Azure ARM Compute service API version -// 2015-06-15. +// 2016-03-30. // // The Compute Management Client. package compute @@ -18,7 +18,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -28,7 +28,7 @@ import ( const ( // APIVersion is the version of the Compute - APIVersion = "2015-06-15" + APIVersion = "2016-03-30" // DefaultBaseURI is the default URI used for the service Compute DefaultBaseURI = "https://management.azure.com" @@ -38,6 +38,7 @@ const ( type ManagementClient struct { autorest.Client BaseURI string + APIVersion string SubscriptionID string } @@ -51,6 +52,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, + APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go index 0de602404..e38a3a122 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -58,6 +58,14 @@ const ( FromImage DiskCreateOptionTypes = "fromImage" ) +// InstanceViewTypes enumerates the values for instance view types. +type InstanceViewTypes string + +const ( + // InstanceView specifies the instance view state for instance view types. + InstanceView InstanceViewTypes = "instanceView" +) + // OperatingSystemTypes enumerates the values for operating system types. type OperatingSystemTypes string @@ -68,36 +76,6 @@ const ( Windows OperatingSystemTypes = "Windows" ) -// OperationStatus enumerates the values for operation status. -type OperationStatus string - -const ( - // Failed specifies the failed state for operation status. - Failed OperationStatus = "Failed" - // InProgress specifies the in progress state for operation status. - InProgress OperationStatus = "InProgress" - // Succeeded specifies the succeeded state for operation status. - Succeeded OperationStatus = "Succeeded" -) - -// OperationStatusEnum enumerates the values for operation status enum. -type OperationStatusEnum string - -const ( - // OperationStatusEnumFailed specifies the operation status enum failed - // state for operation status enum. - OperationStatusEnumFailed OperationStatusEnum = "Failed" - // OperationStatusEnumInProgress specifies the operation status enum in - // progress state for operation status enum. - OperationStatusEnumInProgress OperationStatusEnum = "InProgress" - // OperationStatusEnumPreempted specifies the operation status enum - // preempted state for operation status enum. - OperationStatusEnumPreempted OperationStatusEnum = "Preempted" - // OperationStatusEnumSucceeded specifies the operation status enum - // succeeded state for operation status enum. - OperationStatusEnumSucceeded OperationStatusEnum = "Succeeded" -) - // PassNames enumerates the values for pass names. type PassNames string @@ -149,14 +127,6 @@ const ( Manual UpgradeMode = "Manual" ) -// UsageUnit enumerates the values for usage unit. -type UsageUnit string - -const ( - // Count specifies the count state for usage unit. - Count UsageUnit = "Count" -) - // VirtualMachineScaleSetSkuScaleType enumerates the values for virtual // machine scale set sku scale type. type VirtualMachineScaleSetSkuScaleType string @@ -250,6 +220,9 @@ const ( // StandardD14V2 specifies the standard d14v2 state for virtual machine // size types. StandardD14V2 VirtualMachineSizeTypes = "Standard_D14_v2" + // StandardD15V2 specifies the standard d15v2 state for virtual machine + // size types. + StandardD15V2 VirtualMachineSizeTypes = "Standard_D15_v2" // StandardD1V2 specifies the standard d1v2 state for virtual machine size // types. StandardD1V2 VirtualMachineSizeTypes = "Standard_D1_v2" @@ -280,24 +253,54 @@ const ( // StandardDS11 specifies the standard ds11 state for virtual machine size // types. StandardDS11 VirtualMachineSizeTypes = "Standard_DS11" + // StandardDS11V2 specifies the standard ds11v2 state for virtual machine + // size types. + StandardDS11V2 VirtualMachineSizeTypes = "Standard_DS11_v2" // StandardDS12 specifies the standard ds12 state for virtual machine size // types. StandardDS12 VirtualMachineSizeTypes = "Standard_DS12" + // StandardDS12V2 specifies the standard ds12v2 state for virtual machine + // size types. + StandardDS12V2 VirtualMachineSizeTypes = "Standard_DS12_v2" // StandardDS13 specifies the standard ds13 state for virtual machine size // types. StandardDS13 VirtualMachineSizeTypes = "Standard_DS13" + // StandardDS13V2 specifies the standard ds13v2 state for virtual machine + // size types. + StandardDS13V2 VirtualMachineSizeTypes = "Standard_DS13_v2" // StandardDS14 specifies the standard ds14 state for virtual machine size // types. StandardDS14 VirtualMachineSizeTypes = "Standard_DS14" + // StandardDS14V2 specifies the standard ds14v2 state for virtual machine + // size types. + StandardDS14V2 VirtualMachineSizeTypes = "Standard_DS14_v2" + // StandardDS15V2 specifies the standard ds15v2 state for virtual machine + // size types. + StandardDS15V2 VirtualMachineSizeTypes = "Standard_DS15_v2" + // StandardDS1V2 specifies the standard ds1v2 state for virtual machine + // size types. + StandardDS1V2 VirtualMachineSizeTypes = "Standard_DS1_v2" // StandardDS2 specifies the standard ds2 state for virtual machine size // types. StandardDS2 VirtualMachineSizeTypes = "Standard_DS2" + // StandardDS2V2 specifies the standard ds2v2 state for virtual machine + // size types. + StandardDS2V2 VirtualMachineSizeTypes = "Standard_DS2_v2" // StandardDS3 specifies the standard ds3 state for virtual machine size // types. StandardDS3 VirtualMachineSizeTypes = "Standard_DS3" + // StandardDS3V2 specifies the standard ds3v2 state for virtual machine + // size types. + StandardDS3V2 VirtualMachineSizeTypes = "Standard_DS3_v2" // StandardDS4 specifies the standard ds4 state for virtual machine size // types. StandardDS4 VirtualMachineSizeTypes = "Standard_DS4" + // StandardDS4V2 specifies the standard ds4v2 state for virtual machine + // size types. + StandardDS4V2 VirtualMachineSizeTypes = "Standard_DS4_v2" + // StandardDS5V2 specifies the standard ds5v2 state for virtual machine + // size types. + StandardDS5V2 VirtualMachineSizeTypes = "Standard_DS5_v2" // StandardG1 specifies the standard g1 state for virtual machine size // types. StandardG1 VirtualMachineSizeTypes = "Standard_G1" @@ -330,10 +333,10 @@ const ( StandardGS5 VirtualMachineSizeTypes = "Standard_GS5" ) -// AdditionalUnattendContent is gets or sets additional XML formatted -// information that can be included in the Unattend.xml file, which is used -// by Windows Setup. Contents are defined by setting name, component name, -// and the pass in which the content is a applied. +// AdditionalUnattendContent is additional XML formatted information that can +// be included in the Unattend.xml file, which is used by Windows Setup. +// Contents are defined by setting name, component name, and the pass in +// which the content is a applied. type AdditionalUnattendContent struct { PassName PassNames `json:"passName,omitempty"` ComponentName ComponentNames `json:"componentName,omitempty"` @@ -377,19 +380,6 @@ type AvailabilitySet struct { type AvailabilitySetListResult struct { autorest.Response `json:"-"` Value *[]AvailabilitySet `json:"value,omitempty"` - NextLink *string `json:",omitempty"` -} - -// AvailabilitySetListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client AvailabilitySetListResult) AvailabilitySetListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) } // AvailabilitySetProperties is the instance view of a resource. @@ -429,15 +419,6 @@ type DataDiskImage struct { Lun *int32 `json:"lun,omitempty"` } -// DeleteOperationResult is the compute long running operation response. -type DeleteOperationResult struct { - OperationID *string `json:"operationId,omitempty"` - Status OperationStatus `json:"status,omitempty"` - StartTime *date.Time `json:"startTime,omitempty"` - EndTime *date.Time `json:"endTime,omitempty"` - Error *APIError `json:"error,omitempty"` -} - // DiagnosticsProfile is describes a diagnostics profile. type DiagnosticsProfile struct { BootDiagnostics *BootDiagnostics `json:"bootDiagnostics,omitempty"` @@ -447,6 +428,7 @@ type DiagnosticsProfile struct { type DiskEncryptionSettings struct { DiskEncryptionKey *KeyVaultSecretReference `json:"diskEncryptionKey,omitempty"` KeyEncryptionKey *KeyVaultKeyReference `json:"keyEncryptionKey,omitempty"` + Enabled *bool `json:"enabled,omitempty"` } // DiskInstanceView is the instance view of the disk. @@ -505,7 +487,7 @@ type LinuxConfiguration struct { type ListUsagesResult struct { autorest.Response `json:"-"` Value *[]Usage `json:"value,omitempty"` - NextLink *string `json:",omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // ListUsagesResultPreparer prepares a request to retrieve the next set of results. It returns @@ -520,6 +502,12 @@ func (client ListUsagesResult) ListUsagesResultPreparer() (*http.Request, error) autorest.WithBaseURL(to.String(client.NextLink))) } +// ListVirtualMachineExtensionImage is +type ListVirtualMachineExtensionImage struct { + autorest.Response `json:"-"` + Value *[]VirtualMachineExtensionImage `json:"value,omitempty"` +} + // ListVirtualMachineImageResource is type ListVirtualMachineImageResource struct { autorest.Response `json:"-"` @@ -532,17 +520,6 @@ type LongRunningOperationProperties struct { Output *map[string]interface{} `json:"output,omitempty"` } -// LongRunningOperationResult is the Compute service response for long-running -// operations. -type LongRunningOperationResult struct { - OperationID *string `json:"operationId,omitempty"` - Status OperationStatusEnum `json:"status,omitempty"` - StartTime *date.Time `json:"startTime,omitempty"` - EndTime *date.Time `json:"endTime,omitempty"` - Properties *LongRunningOperationProperties `json:"properties,omitempty"` - Error *APIError `json:"error,omitempty"` -} - // NetworkInterfaceReference is describes a network interface reference. type NetworkInterfaceReference struct { ID *string `json:"id,omitempty"` @@ -651,7 +628,7 @@ type UpgradePolicy struct { // Usage is describes Compute Resource Usage. type Usage struct { - Unit UsageUnit `json:"unit,omitempty"` + Unit *string `json:"unit,omitempty"` CurrentValue *int32 `json:"currentValue,omitempty"` Limit *int64 `json:"limit,omitempty"` Name *UsageName `json:"name,omitempty"` @@ -746,10 +723,11 @@ type VirtualMachineExtensionHandlerInstanceView struct { type VirtualMachineExtensionImage struct { autorest.Response `json:"-"` ID *string `json:"id,omitempty"` - Properties *VirtualMachineExtensionImageProperties `json:"properties,omitempty"` Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Properties *VirtualMachineExtensionImageProperties `json:"properties,omitempty"` } // VirtualMachineExtensionImageProperties is describes the properties of a @@ -775,6 +753,7 @@ type VirtualMachineExtensionInstanceView struct { // VirtualMachineExtensionProperties is describes the properties of a Virtual // Machine Extension. type VirtualMachineExtensionProperties struct { + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` Publisher *string `json:"publisher,omitempty"` Type *string `json:"type,omitempty"` TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` @@ -789,10 +768,10 @@ type VirtualMachineExtensionProperties struct { type VirtualMachineImage struct { autorest.Response `json:"-"` ID *string `json:"id,omitempty"` - Properties *VirtualMachineImageProperties `json:"properties,omitempty"` Name *string `json:"name,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Properties *VirtualMachineImageProperties `json:"properties,omitempty"` } // VirtualMachineImageProperties is describes the properties of a Virtual @@ -852,6 +831,8 @@ type VirtualMachineProperties struct { AvailabilitySet *SubResource `json:"availabilitySet,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` InstanceView *VirtualMachineInstanceView `json:"instanceView,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` + VMID *string `json:"vmId,omitempty"` } // VirtualMachineScaleSet is describes a Virtual Machine Scale Set. @@ -918,8 +899,10 @@ type VirtualMachineScaleSetIPConfiguration struct { // VirtualMachineScaleSetIPConfigurationProperties is describes a virtual // machine scale set network profile's IP configuration properties. type VirtualMachineScaleSetIPConfigurationProperties struct { - Subnet *APIEntityReference `json:"subnet,omitempty"` - LoadBalancerBackendAddressPools *[]SubResource `json:"loadBalancerBackendAddressPools,omitempty"` + Subnet *APIEntityReference `json:"subnet,omitempty"` + ApplicationGatewayBackendAddressPools *[]SubResource `json:"applicationGatewayBackendAddressPools,omitempty"` + LoadBalancerBackendAddressPools *[]SubResource `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatPools *[]SubResource `json:"loadBalancerInboundNatPools,omitempty"` } // VirtualMachineScaleSetListResult is the List Virtual Machine operation @@ -927,7 +910,7 @@ type VirtualMachineScaleSetIPConfigurationProperties struct { type VirtualMachineScaleSetListResult struct { autorest.Response `json:"-"` Value *[]VirtualMachineScaleSet `json:"value,omitempty"` - NextLink *string `json:",omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // VirtualMachineScaleSetListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -947,7 +930,7 @@ func (client VirtualMachineScaleSetListResult) VirtualMachineScaleSetListResultP type VirtualMachineScaleSetListSkusResult struct { autorest.Response `json:"-"` Value *[]VirtualMachineScaleSetSku `json:"value,omitempty"` - NextLink *string `json:",omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // VirtualMachineScaleSetListSkusResultPreparer prepares a request to retrieve the next set of results. It returns @@ -1032,6 +1015,7 @@ type VirtualMachineScaleSetProperties struct { UpgradePolicy *UpgradePolicy `json:"upgradePolicy,omitempty"` VirtualMachineProfile *VirtualMachineScaleSetVMProfile `json:"virtualMachineProfile,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` + OverProvision *bool `json:"overProvision,omitempty"` } // VirtualMachineScaleSetSku is describes an available virtual machine scale @@ -1111,7 +1095,7 @@ type VirtualMachineScaleSetVMInstanceView struct { type VirtualMachineScaleSetVMListResult struct { autorest.Response `json:"-"` Value *[]VirtualMachineScaleSetVM `json:"value,omitempty"` - NextLink *string `json:",omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // VirtualMachineScaleSetVMListResultPreparer prepares a request to retrieve the next set of results. It returns @@ -1147,6 +1131,7 @@ type VirtualMachineScaleSetVMProperties struct { DiagnosticsProfile *DiagnosticsProfile `json:"diagnosticsProfile,omitempty"` AvailabilitySet *SubResource `json:"availabilitySet,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` + LicenseType *string `json:"licenseType,omitempty"` } // VirtualMachineSize is describes the properties of a VM size. @@ -1163,19 +1148,6 @@ type VirtualMachineSize struct { type VirtualMachineSizeListResult struct { autorest.Response `json:"-"` Value *[]VirtualMachineSize `json:"value,omitempty"` - NextLink *string `json:",omitempty"` -} - -// VirtualMachineSizeListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client VirtualMachineSizeListResult) VirtualMachineSizeListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) } // VirtualMachineStatusCodeCount is the status code and count of the virtual diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usageoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usageoperations.go index 11a607688..922ae1d98 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usageoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/usageoperations.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // UsageOperationsClient is the the Compute Management Client. @@ -68,21 +67,20 @@ func (client UsageOperationsClient) List(location string) (result ListUsagesResu // ListPreparer prepares the List request. func (client UsageOperationsClient) ListPreparer(location string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go index eef4c7e7a..fa38ce9f1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,9 +23,9 @@ import ( ) const ( - major = "2" + major = "3" minor = "1" - patch = "1" + patch = "0" // Always begin a "tag" with a dash (as per http://semver.org) tag = "-beta" semVerFormat = "%s.%s.%s%s" @@ -34,7 +34,7 @@ const ( // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "compute", "2015-06-15") + return fmt.Sprintf(userAgentFormat, Version(), "compute", "2016-03-30") } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go index cf0a5acf8..089ebe10e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensionimages.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineExtensionImagesClient is the the Compute Management Client. @@ -67,24 +66,23 @@ func (client VirtualMachineExtensionImagesClient) Get(location string, publisher // GetPreparer prepares the Get request. func (client VirtualMachineExtensionImagesClient) GetPreparer(location string, publisherName string, typeParameter string, version string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "publisherName": url.QueryEscape(publisherName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "type": url.QueryEscape(typeParameter), - "version": url.QueryEscape(version), + "location": autorest.Encode("path", location), + "publisherName": autorest.Encode("path", publisherName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "type": autorest.Encode("path", typeParameter), + "version": autorest.Encode("path", version), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -108,7 +106,7 @@ func (client VirtualMachineExtensionImagesClient) GetResponder(resp *http.Respon // ListTypes gets a list of virtual machine extension image types. // -func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineImageResource, err error) { +func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) { req, err := client.ListTypesPreparer(location, publisherName) if err != nil { return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") @@ -131,22 +129,21 @@ func (client VirtualMachineExtensionImagesClient) ListTypes(location string, pub // ListTypesPreparer prepares the ListTypes request. func (client VirtualMachineExtensionImagesClient) ListTypesPreparer(location string, publisherName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "publisherName": url.QueryEscape(publisherName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "publisherName": autorest.Encode("path", publisherName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListTypesSender sends the ListTypes request. The method will close the @@ -157,7 +154,7 @@ func (client VirtualMachineExtensionImagesClient) ListTypesSender(req *http.Requ // ListTypesResponder handles the response to the ListTypes request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) { +func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http.Response) (result ListVirtualMachineExtensionImage, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -171,8 +168,8 @@ func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http. // ListVersions gets a list of virtual machine extension image versions. // // filter is the filter to apply on the operation. -func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderBy string) (result ListVirtualMachineImageResource, err error) { - req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderBy) +func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) { + req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderby) if err != nil { return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") } @@ -192,34 +189,33 @@ func (client VirtualMachineExtensionImagesClient) ListVersions(location string, } // ListVersionsPreparer prepares the ListVersions request. -func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(location string, publisherName string, typeParameter string, filter string, top *int32, orderBy string) (*http.Request, error) { +func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "publisherName": url.QueryEscape(publisherName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "type": url.QueryEscape(typeParameter), + "location": autorest.Encode("path", location), + "publisherName": autorest.Encode("path", publisherName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "type": autorest.Encode("path", typeParameter), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - if len(orderBy) > 0 { - queryParameters["$orderBy"] = orderBy + if len(orderby) > 0 { + queryParameters["$orderby"] = autorest.Encode("query", orderby) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListVersionsSender sends the ListVersions request. The method will close the @@ -230,7 +226,7 @@ func (client VirtualMachineExtensionImagesClient) ListVersionsSender(req *http.R // ListVersionsResponder handles the response to the ListVersions request. The method always // closes the http.Response Body. -func (client VirtualMachineExtensionImagesClient) ListVersionsResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) { +func (client VirtualMachineExtensionImagesClient) ListVersionsResponder(resp *http.Response) (result ListVirtualMachineExtensionImage, err error) { err = autorest.Respond( resp, client.ByInspecting(), diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go index af937c6f4..826687b04 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineExtensionsClient is the the Compute Management Client. @@ -75,24 +74,24 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName st // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmExtensionName": url.QueryEscape(vmExtensionName), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmExtensionName": autorest.Encode("path", vmExtensionName), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", pathParameters), autorest.WithJSON(extensionParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -109,7 +108,7 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http. err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByClosing()) result.Response = resp return @@ -146,23 +145,22 @@ func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, vm // DeletePreparer prepares the Delete request. func (client VirtualMachineExtensionsClient) DeletePreparer(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmExtensionName": url.QueryEscape(vmExtensionName), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmExtensionName": autorest.Encode("path", vmExtensionName), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -179,7 +177,7 @@ func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return @@ -214,26 +212,25 @@ func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmNam // GetPreparer prepares the Get request. func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, vmName string, vmExtensionName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmExtensionName": url.QueryEscape(vmExtensionName), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmExtensionName": autorest.Encode("path", vmExtensionName), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go index 487332eb3..50d961460 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineImagesClient is the the Compute Management Client. @@ -67,25 +66,24 @@ func (client VirtualMachineImagesClient) Get(location string, publisherName stri // GetPreparer prepares the Get request. func (client VirtualMachineImagesClient) GetPreparer(location string, publisherName string, offer string, skus string, version string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "offer": url.QueryEscape(offer), - "publisherName": url.QueryEscape(publisherName), - "skus": url.QueryEscape(skus), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "version": url.QueryEscape(version), + "location": autorest.Encode("path", location), + "offer": autorest.Encode("path", offer), + "publisherName": autorest.Encode("path", publisherName), + "skus": autorest.Encode("path", skus), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "version": autorest.Encode("path", version), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -133,33 +131,32 @@ func (client VirtualMachineImagesClient) List(location string, publisherName str // ListPreparer prepares the List request. func (client VirtualMachineImagesClient) ListPreparer(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "offer": url.QueryEscape(offer), - "publisherName": url.QueryEscape(publisherName), - "skus": url.QueryEscape(skus), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "offer": autorest.Encode("path", offer), + "publisherName": autorest.Encode("path", publisherName), + "skus": autorest.Encode("path", skus), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } if len(orderby) > 0 { - queryParameters["$orderby"] = orderby + queryParameters["$orderby"] = autorest.Encode("query", orderby) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -206,22 +203,21 @@ func (client VirtualMachineImagesClient) ListOffers(location string, publisherNa // ListOffersPreparer prepares the ListOffers request. func (client VirtualMachineImagesClient) ListOffersPreparer(location string, publisherName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "publisherName": url.QueryEscape(publisherName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "publisherName": autorest.Encode("path", publisherName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListOffersSender sends the ListOffers request. The method will close the @@ -268,21 +264,20 @@ func (client VirtualMachineImagesClient) ListPublishers(location string) (result // ListPublishersPreparer prepares the ListPublishers request. func (client VirtualMachineImagesClient) ListPublishersPreparer(location string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListPublishersSender sends the ListPublishers request. The method will close the @@ -329,23 +324,22 @@ func (client VirtualMachineImagesClient) ListSkus(location string, publisherName // ListSkusPreparer prepares the ListSkus request. func (client VirtualMachineImagesClient) ListSkusPreparer(location string, publisherName string, offer string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "offer": url.QueryEscape(offer), - "publisherName": url.QueryEscape(publisherName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "offer": autorest.Encode("path", offer), + "publisherName": autorest.Encode("path", publisherName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSkusSender sends the ListSkus request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go index 37f9f3f87..a55c845de 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachinesClient is the the Compute Management Client. @@ -42,9 +41,9 @@ func NewVirtualMachinesClientWithBaseURI(baseURI string, subscriptionID string) return VirtualMachinesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Capture captures the VM by copying VirtualHardDisks of the VM and outputs a -// template that can be used to create similar VMs. This method may poll for -// completion. Polling can be canceled by passing the cancel channel +// Capture captures the VM by copying virtual hard disks of the VM and outputs +// a template that can be used to create similar VMs. This method may poll +// for completion. Polling can be canceled by passing the cancel channel // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. // @@ -74,23 +73,23 @@ func (client VirtualMachinesClient) Capture(resourceGroupName string, vmName str // CapturePreparer prepares the Capture request. func (client VirtualMachinesClient) CapturePreparer(resourceGroupName string, vmName string, parameters VirtualMachineCaptureParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CaptureSender sends the Capture request. The method will close the @@ -144,23 +143,23 @@ func (client VirtualMachinesClient) CreateOrUpdate(resourceGroupName string, vmN // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualMachinesClient) CreateOrUpdatePreparer(resourceGroupName string, vmName string, parameters VirtualMachine, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -177,7 +176,7 @@ func (client VirtualMachinesClient) CreateOrUpdateResponder(resp *http.Response) err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByClosing()) result.Response = resp return @@ -214,22 +213,21 @@ func (client VirtualMachinesClient) Deallocate(resourceGroupName string, vmName // DeallocatePreparer prepares the Deallocate request. func (client VirtualMachinesClient) DeallocatePreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeallocateSender sends the Deallocate request. The method will close the @@ -282,22 +280,21 @@ func (client VirtualMachinesClient) Delete(resourceGroupName string, vmName stri // DeletePreparer prepares the Delete request. func (client VirtualMachinesClient) DeletePreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -347,22 +344,21 @@ func (client VirtualMachinesClient) Generalize(resourceGroupName string, vmName // GeneralizePreparer prepares the Generalize request. func (client VirtualMachinesClient) GeneralizePreparer(resourceGroupName string, vmName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GeneralizeSender sends the Generalize request. The method will close the @@ -387,8 +383,8 @@ func (client VirtualMachinesClient) GeneralizeResponder(resp *http.Response) (re // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. expand is the expand expression to apply on the -// operation. -func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, expand string) (result VirtualMachine, err error) { +// operation. Possible values include: 'instanceView' +func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, expand InstanceViewTypes) (result VirtualMachine, err error) { req, err := client.GetPreparer(resourceGroupName, vmName, expand) if err != nil { return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Get", nil, "Failure preparing request") @@ -409,27 +405,26 @@ func (client VirtualMachinesClient) Get(resourceGroupName string, vmName string, } // GetPreparer prepares the Get request. -func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, vmName string, expand string) (*http.Request, error) { +func (client VirtualMachinesClient) GetPreparer(resourceGroupName string, vmName string, expand InstanceViewTypes) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - if len(expand) > 0 { - queryParameters["$expand"] = expand + if len(string(expand)) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -477,21 +472,20 @@ func (client VirtualMachinesClient) List(resourceGroupName string) (result Virtu // ListPreparer prepares the List request. func (client VirtualMachinesClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -563,20 +557,19 @@ func (client VirtualMachinesClient) ListAll() (result VirtualMachineListResult, // ListAllPreparer prepares the ListAll request. func (client VirtualMachinesClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the @@ -622,8 +615,8 @@ func (client VirtualMachinesClient) ListAllNextResults(lastResults VirtualMachin return } -// ListAvailableSizes lists virtual-machine-sizes available to be used for a -// virtual machine. +// ListAvailableSizes lists all available virtual machine sizes it can be +// resized to for a virtual machine. // // resourceGroupName is the name of the resource group. vmName is the name of // the virtual machine. @@ -650,22 +643,21 @@ func (client VirtualMachinesClient) ListAvailableSizes(resourceGroupName string, // ListAvailableSizesPreparer prepares the ListAvailableSizes request. func (client VirtualMachinesClient) ListAvailableSizesPreparer(resourceGroupName string, vmName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAvailableSizesSender sends the ListAvailableSizes request. The method will close the @@ -687,30 +679,6 @@ func (client VirtualMachinesClient) ListAvailableSizesResponder(resp *http.Respo return } -// ListAvailableSizesNextResults retrieves the next set of results, if any. -func (client VirtualMachinesClient) ListAvailableSizesNextResults(lastResults VirtualMachineSizeListResult) (result VirtualMachineSizeListResult, err error) { - req, err := lastResults.VirtualMachineSizeListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListAvailableSizesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure sending next results request request") - } - - result, err = client.ListAvailableSizesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "ListAvailableSizes", resp, "Failure responding to next results request request") - } - - return -} - // PowerOff the operation to power off (stop) a virtual machine. This method // may poll for completion. Polling can be canceled by passing the cancel // channel argument. The channel will be used to cancel polling and any @@ -741,22 +709,21 @@ func (client VirtualMachinesClient) PowerOff(resourceGroupName string, vmName st // PowerOffPreparer prepares the PowerOff request. func (client VirtualMachinesClient) PowerOffPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // PowerOffSender sends the PowerOff request. The method will close the @@ -779,6 +746,73 @@ func (client VirtualMachinesClient) PowerOffResponder(resp *http.Response) (resu return } +// Redeploy the operation to redeploy a virtual machine. This method may poll +// for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. vmName is the name of +// the virtual machine. +func (client VirtualMachinesClient) Redeploy(resourceGroupName string, vmName string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.RedeployPreparer(resourceGroupName, vmName, cancel) + if err != nil { + return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", nil, "Failure preparing request") + } + + resp, err := client.RedeploySender(req) + if err != nil { + result.Response = resp + return result, autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure sending request") + } + + result, err = client.RedeployResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachinesClient", "Redeploy", resp, "Failure responding to request") + } + + return +} + +// RedeployPreparer prepares the Redeploy request. +func (client VirtualMachinesClient) RedeployPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// RedeploySender sends the Redeploy request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachinesClient) RedeploySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// RedeployResponder handles the response to the Redeploy request. The method always +// closes the http.Response Body. +func (client VirtualMachinesClient) RedeployResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + // Restart the operation to restart a virtual machine. This method may poll // for completion. Polling can be canceled by passing the cancel channel // argument. The channel will be used to cancel polling and any outstanding @@ -809,22 +843,21 @@ func (client VirtualMachinesClient) Restart(resourceGroupName string, vmName str // RestartPreparer prepares the Restart request. func (client VirtualMachinesClient) RestartPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // RestartSender sends the Restart request. The method will close the @@ -877,22 +910,21 @@ func (client VirtualMachinesClient) Start(resourceGroupName string, vmName strin // StartPreparer prepares the Start request. func (client VirtualMachinesClient) StartPreparer(resourceGroupName string, vmName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmName": url.QueryEscape(vmName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmName": autorest.Encode("path", vmName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // StartSender sends the Start request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go index 7fedc2754..649e008ee 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineScaleSetsClient is the the Compute Management Client. @@ -42,10 +41,11 @@ func NewVirtualMachineScaleSetsClientWithBaseURI(baseURI string, subscriptionID return VirtualMachineScaleSetsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// CreateOrUpdate the operation to create or update a virtual machine scale -// set. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. +// CreateOrUpdate allows you to create or update a virtual machine scale set +// by providing parameters or a path to pre-configured parameter file. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and +// any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. name is parameters // supplied to the Create Virtual Machine Scale Set operation. parameters is @@ -73,23 +73,23 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdate(resourceGroupName str // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualMachineScaleSetsClient) CreateOrUpdatePreparer(resourceGroupName string, name string, parameters VirtualMachineScaleSet, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "name": url.QueryEscape(name), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "name": autorest.Encode("path", name), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{name}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{name}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -106,16 +106,18 @@ func (client VirtualMachineScaleSetsClient) CreateOrUpdateResponder(resp *http.R err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), autorest.ByClosing()) result.Response = resp return } -// Deallocate the operation to deallocate virtual machines in a virtual -// machine scale set. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// Deallocate allows you to deallocate virtual machines in a virtual machine +// scale set. Shuts down the virtual machines and releases the compute +// resources. You are not billed for the compute resources that this virtual +// machine scale set uses. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. vmInstanceIDs is the list of @@ -143,21 +145,20 @@ func (client VirtualMachineScaleSetsClient) Deallocate(resourceGroupName string, // DeallocatePreparer prepares the Deallocate request. func (client VirtualMachineScaleSetsClient) DeallocatePreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate", pathParameters), autorest.WithQueryParameters(queryParameters)) if vmInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, @@ -186,7 +187,7 @@ func (client VirtualMachineScaleSetsClient) DeallocateResponder(resp *http.Respo return } -// Delete the operation to delete a virtual machine scale set. This method may +// Delete allows you to delete a virtual machine scale set. This method may // poll for completion. Polling can be canceled by passing the cancel channel // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. @@ -216,22 +217,21 @@ func (client VirtualMachineScaleSetsClient) Delete(resourceGroupName string, vmS // DeletePreparer prepares the Delete request. func (client VirtualMachineScaleSetsClient) DeletePreparer(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -248,16 +248,16 @@ func (client VirtualMachineScaleSetsClient) DeleteResponder(resp *http.Response) err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return } -// DeleteInstances the operation to delete virtual machines in a virtual -// machine scale set. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// DeleteInstances allows you to delete virtual machines in a virtual machine +// scale set. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. vmInstanceIDs is the list of @@ -285,23 +285,23 @@ func (client VirtualMachineScaleSetsClient) DeleteInstances(resourceGroupName st // DeleteInstancesPreparer prepares the DeleteInstances request. func (client VirtualMachineScaleSetsClient) DeleteInstancesPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete", pathParameters), autorest.WithJSON(vmInstanceIDs), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteInstancesSender sends the DeleteInstances request. The method will close the @@ -324,7 +324,7 @@ func (client VirtualMachineScaleSetsClient) DeleteInstancesResponder(resp *http. return } -// Get the operation to get a virtual machine scale set. +// Get display information about a virtual machine scale set. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. @@ -351,22 +351,21 @@ func (client VirtualMachineScaleSetsClient) Get(resourceGroupName string, vmScal // GetPreparer prepares the Get request. func (client VirtualMachineScaleSetsClient) GetPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -388,8 +387,7 @@ func (client VirtualMachineScaleSetsClient) GetResponder(resp *http.Response) (r return } -// GetInstanceView the operation to get a virtual machine scale set instance -// view. +// GetInstanceView displays status of a virtual machine scale set instance. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. @@ -416,22 +414,21 @@ func (client VirtualMachineScaleSetsClient) GetInstanceView(resourceGroupName st // GetInstanceViewPreparer prepares the GetInstanceView request. func (client VirtualMachineScaleSetsClient) GetInstanceViewPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetInstanceViewSender sends the GetInstanceView request. The method will close the @@ -453,8 +450,7 @@ func (client VirtualMachineScaleSetsClient) GetInstanceViewResponder(resp *http. return } -// List the operation to list virtual machine scale sets under a resource -// group. +// List lists all virtual machine scale sets under a resource group. // // resourceGroupName is the name of the resource group. func (client VirtualMachineScaleSetsClient) List(resourceGroupName string) (result VirtualMachineScaleSetListResult, err error) { @@ -480,21 +476,20 @@ func (client VirtualMachineScaleSetsClient) List(resourceGroupName string) (resu // ListPreparer prepares the List request. func (client VirtualMachineScaleSetsClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -540,10 +535,10 @@ func (client VirtualMachineScaleSetsClient) ListNextResults(lastResults VirtualM return } -// ListAll gets the list of Virtual Machine Scale Sets in the subscription. -// Use nextLink property in the response to get the next page of Virtual -// Machine Scale Sets. Do this till nextLink is not null to fetch all the -// Virtual Machine Scale Sets. +// ListAll lists all Virtual Machine Scale Sets in the subscription. Use +// nextLink property in the response to get the next page of Virtual Machine +// Scale Sets. Do this till nextLink is not null to fetch all the Virtual +// Machine Scale Sets. func (client VirtualMachineScaleSetsClient) ListAll() (result VirtualMachineScaleSetListWithLinkResult, err error) { req, err := client.ListAllPreparer() if err != nil { @@ -567,20 +562,19 @@ func (client VirtualMachineScaleSetsClient) ListAll() (result VirtualMachineScal // ListAllPreparer prepares the ListAll request. func (client VirtualMachineScaleSetsClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the @@ -626,8 +620,9 @@ func (client VirtualMachineScaleSetsClient) ListAllNextResults(lastResults Virtu return } -// ListSkus the operation to list available skus for a virtual machine scale -// set. +// ListSkus displays available skus for your virtual machine scale set +// including the minimum and maximum vm instances allowed for a particular +// sku. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. @@ -654,22 +649,21 @@ func (client VirtualMachineScaleSetsClient) ListSkus(resourceGroupName string, v // ListSkusPreparer prepares the ListSkus request. func (client VirtualMachineScaleSetsClient) ListSkusPreparer(resourceGroupName string, vmScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSkusSender sends the ListSkus request. The method will close the @@ -715,10 +709,12 @@ func (client VirtualMachineScaleSetsClient) ListSkusNextResults(lastResults Virt return } -// PowerOff the operation to power off (stop) virtual machines in a virtual -// machine scale set. This method may poll for completion. Polling can be -// canceled by passing the cancel channel argument. The channel will be used -// to cancel polling and any outstanding HTTP requests. +// PowerOff allows you to power off (stop) virtual machines in a virtual +// machine scale set. Note that resources are still attached and you are +// getting charged for the resources. Use deallocate to release resources. +// This method may poll for completion. Polling can be canceled by passing +// the cancel channel argument. The channel will be used to cancel polling +// and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. vmInstanceIDs is the list of @@ -746,21 +742,20 @@ func (client VirtualMachineScaleSetsClient) PowerOff(resourceGroupName string, v // PowerOffPreparer prepares the PowerOff request. func (client VirtualMachineScaleSetsClient) PowerOffPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff", pathParameters), autorest.WithQueryParameters(queryParameters)) if vmInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, @@ -789,8 +784,76 @@ func (client VirtualMachineScaleSetsClient) PowerOffResponder(resp *http.Respons return } -// Restart the operation to restart virtual machines in a virtual machine -// scale set. This method may poll for completion. Polling can be canceled by +// Reimage allows you to re-image(update the version of the installed +// operating system) virtual machines in a virtual machine scale set. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and +// any outstanding HTTP requests. +// +// resourceGroupName is the name of the resource group. vmScaleSetName is the +// name of the virtual machine scale set. +func (client VirtualMachineScaleSetsClient) Reimage(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, cancel) + if err != nil { + return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", nil, "Failure preparing request") + } + + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = resp + return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure sending request") + } + + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetsClient", "Reimage", resp, "Failure responding to request") + } + + return +} + +// ReimagePreparer prepares the Reimage request. +func (client VirtualMachineScaleSetsClient) ReimagePreparer(resourceGroupName string, vmScaleSetName string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ReimageSender sends the Reimage request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineScaleSetsClient) ReimageSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ReimageResponder handles the response to the Reimage request. The method always +// closes the http.Response Body. +func (client VirtualMachineScaleSetsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Restart allows you to restart virtual machines in a virtual machine scale +// set. This method may poll for completion. Polling can be canceled by // passing the cancel channel argument. The channel will be used to cancel // polling and any outstanding HTTP requests. // @@ -820,21 +883,20 @@ func (client VirtualMachineScaleSetsClient) Restart(resourceGroupName string, vm // RestartPreparer prepares the Restart request. func (client VirtualMachineScaleSetsClient) RestartPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart", pathParameters), autorest.WithQueryParameters(queryParameters)) if vmInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, @@ -863,10 +925,10 @@ func (client VirtualMachineScaleSetsClient) RestartResponder(resp *http.Response return } -// Start the operation to start virtual machines in a virtual machine scale -// set. This method may poll for completion. Polling can be canceled by -// passing the cancel channel argument. The channel will be used to cancel -// polling and any outstanding HTTP requests. +// Start allows you to start virtual machines in a virtual machine scale set. +// This method may poll for completion. Polling can be canceled by passing +// the cancel channel argument. The channel will be used to cancel polling +// and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. vmInstanceIDs is the list of @@ -894,21 +956,20 @@ func (client VirtualMachineScaleSetsClient) Start(resourceGroupName string, vmSc // StartPreparer prepares the Start request. func (client VirtualMachineScaleSetsClient) StartPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs *VirtualMachineScaleSetVMInstanceIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start", pathParameters), autorest.WithQueryParameters(queryParameters)) if vmInstanceIDs != nil { preparer = autorest.DecoratePreparer(preparer, @@ -937,7 +998,7 @@ func (client VirtualMachineScaleSetsClient) StartResponder(resp *http.Response) return } -// UpdateInstances the operation to manually upgrade virtual machines in a +// UpdateInstances allows you to manually upgrade virtual machines in a // virtual machine scale set. This method may poll for completion. Polling // can be canceled by passing the cancel channel argument. The channel will // be used to cancel polling and any outstanding HTTP requests. @@ -968,23 +1029,23 @@ func (client VirtualMachineScaleSetsClient) UpdateInstances(resourceGroupName st // UpdateInstancesPreparer prepares the UpdateInstances request. func (client VirtualMachineScaleSetsClient) UpdateInstancesPreparer(resourceGroupName string, vmScaleSetName string, vmInstanceIDs VirtualMachineScaleSetVMInstanceRequiredIDs, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade", pathParameters), autorest.WithJSON(vmInstanceIDs), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // UpdateInstancesSender sends the UpdateInstances request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go index a301e8f7b..1db4a1360 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineScaleSetVMsClient is the the Compute Management Client. @@ -42,10 +41,12 @@ func NewVirtualMachineScaleSetVMsClientWithBaseURI(baseURI string, subscriptionI return VirtualMachineScaleSetVMsClient{NewWithBaseURI(baseURI, subscriptionID)} } -// Deallocate the operation to deallocate a virtual machine scale set. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// Deallocate allows you to deallocate a virtual machine scale set virtual +// machine. Shuts down the virtual machine and releases the compute +// resources. You are not billed for the compute resources that this virtual +// machine uses. This method may poll for completion. Polling can be canceled +// by passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. instanceID is the instance id of @@ -73,23 +74,22 @@ func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName strin // DeallocatePreparer prepares the Deallocate request. func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeallocateSender sends the Deallocate request. The method will close the @@ -112,7 +112,7 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Res return } -// Delete the operation to delete a virtual machine scale set. This method may +// Delete allows you to delete a virtual machine scale set. This method may // poll for completion. Polling can be canceled by passing the cancel channel // argument. The channel will be used to cancel polling and any outstanding // HTTP requests. @@ -143,23 +143,22 @@ func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, v // DeletePreparer prepares the Delete request. func (client VirtualMachineScaleSetVMsClient) DeletePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -176,13 +175,13 @@ func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Respons err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusAccepted), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), autorest.ByClosing()) result.Response = resp return } -// Get the operation to get a virtual machine scale set virtual machine. +// Get displays information about a virtual machine scale set virtual machine. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. instanceID is the instance id of @@ -210,23 +209,22 @@ func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmSc // GetPreparer prepares the Get request. func (client VirtualMachineScaleSetVMsClient) GetPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -248,7 +246,7 @@ func (client VirtualMachineScaleSetVMsClient) GetResponder(resp *http.Response) return } -// GetInstanceView the operation to get a virtual machine scale set virtual +// GetInstanceView displays the status of a virtual machine scale set virtual // machine. // // resourceGroupName is the name of the resource group. vmScaleSetName is the @@ -277,23 +275,22 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName // GetInstanceViewPreparer prepares the GetInstanceView request. func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetInstanceViewSender sends the GetInstanceView request. The method will close the @@ -315,7 +312,7 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceViewResponder(resp *htt return } -// List the operation to list virtual machine scale sets VMs. +// List lists all virtual machines in a VM scale sets. // // resourceGroupName is the name of the resource group. // virtualMachineScaleSetName is the name of the virtual machine scale set. @@ -345,31 +342,30 @@ func (client VirtualMachineScaleSetVMsClient) List(resourceGroupName string, vir // ListPreparer prepares the List request. func (client VirtualMachineScaleSetVMsClient) ListPreparer(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualMachineScaleSetName": url.QueryEscape(virtualMachineScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if len(selectParameter) > 0 { - queryParameters["$select"] = selectParameter + queryParameters["$select"] = autorest.Encode("query", selectParameter) } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -415,10 +411,10 @@ func (client VirtualMachineScaleSetVMsClient) ListNextResults(lastResults Virtua return } -// PowerOff the operation to power off (stop) a virtual machine scale set. -// This method may poll for completion. Polling can be canceled by passing -// the cancel channel argument. The channel will be used to cancel polling -// and any outstanding HTTP requests. +// PowerOff allows you to power off (stop) a virtual machine in a VM scale +// set. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. instanceID is the instance id of @@ -446,23 +442,22 @@ func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, // PowerOffPreparer prepares the PowerOff request. func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // PowerOffSender sends the PowerOff request. The method will close the @@ -485,10 +480,80 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Respo return } -// Restart the operation to restart a virtual machine scale set. This method -// may poll for completion. Polling can be canceled by passing the cancel -// channel argument. The channel will be used to cancel polling and any -// outstanding HTTP requests. +// Reimage allows you to re-image(update the version of the installed +// operating system) a virtual machine scale set instance. This method may +// poll for completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. +// +// resourceGroupName is the name of the resource group. vmScaleSetName is the +// name of the virtual machine scale set. instanceID is the instance id of +// the virtual machine. +func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) + if err != nil { + return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") + } + + resp, err := client.ReimageSender(req) + if err != nil { + result.Response = resp + return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") + } + + result, err = client.ReimageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") + } + + return +} + +// ReimagePreparer prepares the Reimage request. +func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) +} + +// ReimageSender sends the Reimage request. The method will close the +// http.Response Body if it receives an error. +func (client VirtualMachineScaleSetVMsClient) ReimageSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) +} + +// ReimageResponder handles the response to the Reimage request. The method always +// closes the http.Response Body. +func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Restart allows you to restart a virtual machine in a VM scale set. This +// method may poll for completion. Polling can be canceled by passing the +// cancel channel argument. The channel will be used to cancel polling and +// any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. instanceID is the instance id of @@ -516,23 +581,22 @@ func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, // RestartPreparer prepares the Restart request. func (client VirtualMachineScaleSetVMsClient) RestartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // RestartSender sends the Restart request. The method will close the @@ -555,10 +619,10 @@ func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Respon return } -// Start the operation to start a virtual machine scale set. This method may -// poll for completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// Start allows you to start a virtual machine in a VM scale set. This method +// may poll for completion. Polling can be canceled by passing the cancel +// channel argument. The channel will be used to cancel polling and any +// outstanding HTTP requests. // // resourceGroupName is the name of the resource group. vmScaleSetName is the // name of the virtual machine scale set. instanceID is the instance id of @@ -586,23 +650,22 @@ func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, vm // StartPreparer prepares the Start request. func (client VirtualMachineScaleSetVMsClient) StartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "instanceId": url.QueryEscape(instanceID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "vmScaleSetName": url.QueryEscape(vmScaleSetName), + "instanceId": autorest.Encode("path", instanceID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vmScaleSetName": autorest.Encode("path", vmScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // StartSender sends the Start request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go index cccba5308..3cdeecedb 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go @@ -14,7 +14,7 @@ package compute // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualMachineSizesClient is the the Compute Management Client. @@ -42,7 +41,8 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri return VirtualMachineSizesClient{NewWithBaseURI(baseURI, subscriptionID)} } -// List lists virtual-machine-sizes available in a location for a subscription. +// List lists all available virtual machine sizes for a subscription in a +// location. // // location is the location upon which virtual-machine-sizes is queried. func (client VirtualMachineSizesClient) List(location string) (result VirtualMachineSizeListResult, err error) { @@ -68,21 +68,20 @@ func (client VirtualMachineSizesClient) List(location string) (result VirtualMac // ListPreparer prepares the List request. func (client VirtualMachineSizesClient) ListPreparer(location string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -103,27 +102,3 @@ func (client VirtualMachineSizesClient) ListResponder(resp *http.Response) (resu result.Response = autorest.Response{Response: resp} return } - -// ListNextResults retrieves the next set of results, if any. -func (client VirtualMachineSizesClient) ListNextResults(lastResults VirtualMachineSizeListResult) (result VirtualMachineSizeListResult, err error) { - req, err := lastResults.VirtualMachineSizeListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending next results request request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go index 92d40233c..44f53b09e 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ApplicationGatewaysClient is the the Microsoft Azure Network management API @@ -77,23 +76,23 @@ func (client ApplicationGatewaysClient) CreateOrUpdate(resourceGroupName string, // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client ApplicationGatewaysClient) CreateOrUpdatePreparer(resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "applicationGatewayName": url.QueryEscape(applicationGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "applicationGatewayName": autorest.Encode("path", applicationGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -146,22 +145,21 @@ func (client ApplicationGatewaysClient) Delete(resourceGroupName string, applica // DeletePreparer prepares the Delete request. func (client ApplicationGatewaysClient) DeletePreparer(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "applicationGatewayName": url.QueryEscape(applicationGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "applicationGatewayName": autorest.Encode("path", applicationGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,22 +210,21 @@ func (client ApplicationGatewaysClient) Get(resourceGroupName string, applicatio // GetPreparer prepares the Get request. func (client ApplicationGatewaysClient) GetPreparer(resourceGroupName string, applicationGatewayName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "applicationGatewayName": url.QueryEscape(applicationGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "applicationGatewayName": autorest.Encode("path", applicationGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -276,21 +273,20 @@ func (client ApplicationGatewaysClient) List(resourceGroupName string) (result A // ListPreparer prepares the List request. func (client ApplicationGatewaysClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -361,20 +357,19 @@ func (client ApplicationGatewaysClient) ListAll() (result ApplicationGatewayList // ListAllPreparer prepares the ListAll request. func (client ApplicationGatewaysClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGateways"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGateways", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the @@ -451,22 +446,21 @@ func (client ApplicationGatewaysClient) Start(resourceGroupName string, applicat // StartPreparer prepares the Start request. func (client ApplicationGatewaysClient) StartPreparer(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "applicationGatewayName": url.QueryEscape(applicationGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "applicationGatewayName": autorest.Encode("path", applicationGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/start"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/start", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // StartSender sends the Start request. The method will close the @@ -520,22 +514,21 @@ func (client ApplicationGatewaysClient) Stop(resourceGroupName string, applicati // StopPreparer prepares the Stop request. func (client ApplicationGatewaysClient) StopPreparer(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "applicationGatewayName": url.QueryEscape(applicationGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "applicationGatewayName": autorest.Encode("path", applicationGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/stop"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/stop", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // StopSender sends the Stop request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go index ba6a2dace..ef348d2c0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go @@ -1,5 +1,5 @@ // Package network implements the Azure ARM Network service API version -// 2015-06-15. +// 2016-03-30. // // The Microsoft Azure Network management API provides a RESTful set of web // services that interact with Microsoft Azure Networks service to manage @@ -21,7 +21,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -29,12 +29,11 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) const ( // APIVersion is the version of the Network - APIVersion = "2015-06-15" + APIVersion = "2016-03-30" // DefaultBaseURI is the default URI used for the service Network DefaultBaseURI = "https://management.azure.com" @@ -44,6 +43,7 @@ const ( type ManagementClient struct { autorest.Client BaseURI string + APIVersion string SubscriptionID string } @@ -57,6 +57,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, + APIVersion: APIVersion, SubscriptionID: subscriptionID, } } @@ -90,24 +91,23 @@ func (client ManagementClient) CheckDNSNameAvailability(location string, domainN // CheckDNSNameAvailabilityPreparer prepares the CheckDNSNameAvailability request. func (client ManagementClient) CheckDNSNameAvailabilityPreparer(location string, domainNameLabel string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(domainNameLabel) > 0 { - queryParameters["domainNameLabel"] = domainNameLabel + queryParameters["domainNameLabel"] = autorest.Encode("query", domainNameLabel) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckDNSNameAvailabilitySender sends the CheckDNSNameAvailability request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go index 9d4255539..df5e8792d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitauthorizations.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network @@ -79,24 +78,24 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGro // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdatePreparer(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "authorizationName": url.QueryEscape(authorizationName), - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "authorizationName": autorest.Encode("path", authorizationName), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}", pathParameters), autorest.WithJSON(authorizationParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -151,23 +150,22 @@ func (client ExpressRouteCircuitAuthorizationsClient) Delete(resourceGroupName s // DeletePreparer prepares the Delete request. func (client ExpressRouteCircuitAuthorizationsClient) DeletePreparer(resourceGroupName string, circuitName string, authorizationName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "authorizationName": url.QueryEscape(authorizationName), - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "authorizationName": autorest.Encode("path", authorizationName), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -219,23 +217,22 @@ func (client ExpressRouteCircuitAuthorizationsClient) Get(resourceGroupName stri // GetPreparer prepares the Get request. func (client ExpressRouteCircuitAuthorizationsClient) GetPreparer(resourceGroupName string, circuitName string, authorizationName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "authorizationName": url.QueryEscape(authorizationName), - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "authorizationName": autorest.Encode("path", authorizationName), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations/{authorizationName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -285,22 +282,21 @@ func (client ExpressRouteCircuitAuthorizationsClient) List(resourceGroupName str // ListPreparer prepares the List request. func (client ExpressRouteCircuitAuthorizationsClient) ListPreparer(resourceGroupName string, circuitName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/authorizations", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go index e60088084..28c093506 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network @@ -78,24 +77,24 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdatePreparer(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "peeringName": url.QueryEscape(peeringName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}", pathParameters), autorest.WithJSON(peeringParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -148,23 +147,22 @@ func (client ExpressRouteCircuitPeeringsClient) Delete(resourceGroupName string, // DeletePreparer prepares the Delete request. func (client ExpressRouteCircuitPeeringsClient) DeletePreparer(resourceGroupName string, circuitName string, peeringName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "peeringName": url.QueryEscape(peeringName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -215,23 +213,22 @@ func (client ExpressRouteCircuitPeeringsClient) Get(resourceGroupName string, ci // GetPreparer prepares the Get request. func (client ExpressRouteCircuitPeeringsClient) GetPreparer(resourceGroupName string, circuitName string, peeringName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "peeringName": url.QueryEscape(peeringName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -281,22 +278,21 @@ func (client ExpressRouteCircuitPeeringsClient) List(resourceGroupName string, c // ListPreparer prepares the List request. func (client ExpressRouteCircuitPeeringsClient) ListPreparer(resourceGroupName string, circuitName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go index e896827cc..bf9587ae6 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ExpressRouteCircuitsClient is the the Microsoft Azure Network management @@ -77,23 +76,23 @@ func (client ExpressRouteCircuitsClient) CreateOrUpdate(resourceGroupName string // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client ExpressRouteCircuitsClient) CreateOrUpdatePreparer(resourceGroupName string, circuitName string, parameters ExpressRouteCircuit, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -146,22 +145,21 @@ func (client ExpressRouteCircuitsClient) Delete(resourceGroupName string, circui // DeletePreparer prepares the Delete request. func (client ExpressRouteCircuitsClient) DeletePreparer(resourceGroupName string, circuitName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,22 +210,21 @@ func (client ExpressRouteCircuitsClient) Get(resourceGroupName string, circuitNa // GetPreparer prepares the Get request. func (client ExpressRouteCircuitsClient) GetPreparer(resourceGroupName string, circuitName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -249,6 +246,135 @@ func (client ExpressRouteCircuitsClient) GetResponder(resp *http.Response) (resu return } +// GetPeeringStats the Liststats ExpressRouteCircuit opertion retrieves all +// the stats from a ExpressRouteCircuits in a resource group. +// +// resourceGroupName is the name of the resource group. circuitName is the +// name of the circuit. peeringName is the name of the peering. +func (client ExpressRouteCircuitsClient) GetPeeringStats(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitStats, err error) { + req, err := client.GetPeeringStatsPreparer(resourceGroupName, circuitName, peeringName) + if err != nil { + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", nil, "Failure preparing request") + } + + resp, err := client.GetPeeringStatsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure sending request") + } + + result, err = client.GetPeeringStatsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure responding to request") + } + + return +} + +// GetPeeringStatsPreparer prepares the GetPeeringStats request. +func (client ExpressRouteCircuitsClient) GetPeeringStatsPreparer(resourceGroupName string, circuitName string, peeringName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "circuitName": autorest.Encode("path", circuitName), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/stats", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetPeeringStatsSender sends the GetPeeringStats request. The method will close the +// http.Response Body if it receives an error. +func (client ExpressRouteCircuitsClient) GetPeeringStatsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetPeeringStatsResponder handles the response to the GetPeeringStats request. The method always +// closes the http.Response Body. +func (client ExpressRouteCircuitsClient) GetPeeringStatsResponder(resp *http.Response) (result ExpressRouteCircuitStats, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetStats the Liststats ExpressRouteCircuit opertion retrieves all the stats +// from a ExpressRouteCircuits in a resource group. +// +// resourceGroupName is the name of the resource group. circuitName is the +// name of the circuit. +func (client ExpressRouteCircuitsClient) GetStats(resourceGroupName string, circuitName string) (result ExpressRouteCircuitStats, err error) { + req, err := client.GetStatsPreparer(resourceGroupName, circuitName) + if err != nil { + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", nil, "Failure preparing request") + } + + resp, err := client.GetStatsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure sending request") + } + + result, err = client.GetStatsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure responding to request") + } + + return +} + +// GetStatsPreparer prepares the GetStats request. +func (client ExpressRouteCircuitsClient) GetStatsPreparer(resourceGroupName string, circuitName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "circuitName": autorest.Encode("path", circuitName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/stats", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// GetStatsSender sends the GetStats request. The method will close the +// http.Response Body if it receives an error. +func (client ExpressRouteCircuitsClient) GetStatsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// GetStatsResponder handles the response to the GetStats request. The method always +// closes the http.Response Body. +func (client ExpressRouteCircuitsClient) GetStatsResponder(resp *http.Response) (result ExpressRouteCircuitStats, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // List the List ExpressRouteCircuit opertion retrieves all the // ExpressRouteCircuits in a resource group. // @@ -276,21 +402,20 @@ func (client ExpressRouteCircuitsClient) List(resourceGroupName string) (result // ListPreparer prepares the List request. func (client ExpressRouteCircuitsClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -361,20 +486,19 @@ func (client ExpressRouteCircuitsClient) ListAll() (result ExpressRouteCircuitLi // ListAllPreparer prepares the ListAll request. func (client ExpressRouteCircuitsClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteCircuits"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteCircuits", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the @@ -422,19 +546,23 @@ func (client ExpressRouteCircuitsClient) ListAllNextResults(lastResults ExpressR // ListArpTable the ListArpTable from ExpressRouteCircuit opertion retrieves // the currently advertised arp table associated with the -// ExpressRouteCircuits in a resource group. +// ExpressRouteCircuits in a resource group. This method may poll for +// completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. // // resourceGroupName is the name of the resource group. circuitName is the -// name of the circuit. -func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string) (result ExpressRouteCircuitsArpTableListResult, err error) { - req, err := client.ListArpTablePreparer(resourceGroupName, circuitName) +// name of the circuit. peeringName is the name of the peering. devicePath is +// the path of the device. +func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.ListArpTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) if err != nil { return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing request") } resp, err := client.ListArpTableSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.Response = resp return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending request") } @@ -447,84 +575,66 @@ func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, } // ListArpTablePreparer prepares the ListArpTable request. -func (client ExpressRouteCircuitsClient) ListArpTablePreparer(resourceGroupName string, circuitName string) (*http.Request, error) { +func (client ExpressRouteCircuitsClient) ListArpTablePreparer(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "devicePath": autorest.Encode("path", devicePath), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), + preparer := autorest.CreatePreparer( + autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/arpTable"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/arpTables/{devicePath}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // ListArpTableSender sends the ListArpTable request. The method will close the // http.Response Body if it receives an error. func (client ExpressRouteCircuitsClient) ListArpTableSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } // ListArpTableResponder handles the response to the ListArpTable request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result ExpressRouteCircuitsArpTableListResult, err error) { +func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListArpTableNextResults retrieves the next set of results, if any. -func (client ExpressRouteCircuitsClient) ListArpTableNextResults(lastResults ExpressRouteCircuitsArpTableListResult) (result ExpressRouteCircuitsArpTableListResult, err error) { - req, err := lastResults.ExpressRouteCircuitsArpTableListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListArpTableSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending next results request request") - } - - result, err = client.ListArpTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure responding to next results request request") - } - + result.Response = resp return } // ListRoutesTable the ListRoutesTable from ExpressRouteCircuit opertion // retrieves the currently advertised routes table associated with the -// ExpressRouteCircuits in a resource group. +// ExpressRouteCircuits in a resource group. This method may poll for +// completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. // // resourceGroupName is the name of the resource group. circuitName is the -// name of the circuit. -func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string) (result ExpressRouteCircuitsRoutesTableListResult, err error) { - req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName) +// name of the circuit. peeringName is the name of the peering. devicePath is +// the path of the device. +func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) if err != nil { return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing request") } resp, err := client.ListRoutesTableSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.Response = resp return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending request") } @@ -537,154 +647,115 @@ func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName strin } // ListRoutesTablePreparer prepares the ListRoutesTable request. -func (client ExpressRouteCircuitsClient) ListRoutesTablePreparer(resourceGroupName string, circuitName string) (*http.Request, error) { +func (client ExpressRouteCircuitsClient) ListRoutesTablePreparer(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "devicePath": autorest.Encode("path", devicePath), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), + preparer := autorest.CreatePreparer( + autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/routesTable"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/routeTables/{devicePath}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // ListRoutesTableSender sends the ListRoutesTable request. The method will close the // http.Response Body if it receives an error. func (client ExpressRouteCircuitsClient) ListRoutesTableSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } // ListRoutesTableResponder handles the response to the ListRoutesTable request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result ExpressRouteCircuitsRoutesTableListResult, err error) { +func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} + result.Response = resp return } -// ListRoutesTableNextResults retrieves the next set of results, if any. -func (client ExpressRouteCircuitsClient) ListRoutesTableNextResults(lastResults ExpressRouteCircuitsRoutesTableListResult) (result ExpressRouteCircuitsRoutesTableListResult, err error) { - req, err := lastResults.ExpressRouteCircuitsRoutesTableListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListRoutesTableSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending next results request request") - } - - result, err = client.ListRoutesTableResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure responding to next results request request") - } - - return -} - -// ListStats the Liststats ExpressRouteCircuit opertion retrieves all the -// stats from a ExpressRouteCircuits in a resource group. +// ListRoutesTableSummary the ListRoutesTable from ExpressRouteCircuit +// opertion retrieves the currently advertised routes table associated with +// the ExpressRouteCircuits in a resource group. This method may poll for +// completion. Polling can be canceled by passing the cancel channel +// argument. The channel will be used to cancel polling and any outstanding +// HTTP requests. // // resourceGroupName is the name of the resource group. circuitName is the -// name of the loadBalancer. -func (client ExpressRouteCircuitsClient) ListStats(resourceGroupName string, circuitName string) (result ExpressRouteCircuitsStatsListResult, err error) { - req, err := client.ListStatsPreparer(resourceGroupName, circuitName) +// name of the circuit. peeringName is the name of the peering. devicePath is +// the path of the device. +func (client ExpressRouteCircuitsClient) ListRoutesTableSummary(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { + req, err := client.ListRoutesTableSummaryPreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", nil, "Failure preparing request") + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", nil, "Failure preparing request") } - resp, err := client.ListStatsSender(req) + resp, err := client.ListRoutesTableSummarySender(req) if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", resp, "Failure sending request") + result.Response = resp + return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure sending request") } - result, err = client.ListStatsResponder(resp) + result, err = client.ListRoutesTableSummaryResponder(resp) if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", resp, "Failure responding to request") + err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure responding to request") } return } -// ListStatsPreparer prepares the ListStats request. -func (client ExpressRouteCircuitsClient) ListStatsPreparer(resourceGroupName string, circuitName string) (*http.Request, error) { +// ListRoutesTableSummaryPreparer prepares the ListRoutesTableSummary request. +func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryPreparer(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "circuitName": url.QueryEscape(circuitName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "circuitName": autorest.Encode("path", circuitName), + "devicePath": autorest.Encode("path", devicePath), + "peeringName": autorest.Encode("path", peeringName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), + preparer := autorest.CreatePreparer( + autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/stats"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/routeTablesSummary/{devicePath}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } -// ListStatsSender sends the ListStats request. The method will close the +// ListRoutesTableSummarySender sends the ListRoutesTableSummary request. The method will close the // http.Response Body if it receives an error. -func (client ExpressRouteCircuitsClient) ListStatsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) +func (client ExpressRouteCircuitsClient) ListRoutesTableSummarySender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, + req, + azure.DoPollForAsynchronous(client.PollingDelay)) } -// ListStatsResponder handles the response to the ListStats request. The method always +// ListRoutesTableSummaryResponder handles the response to the ListRoutesTableSummary request. The method always // closes the http.Response Body. -func (client ExpressRouteCircuitsClient) ListStatsResponder(resp *http.Response) (result ExpressRouteCircuitsStatsListResult, err error) { +func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryResponder(resp *http.Response) (result autorest.Response, err error) { err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListStatsNextResults retrieves the next set of results, if any. -func (client ExpressRouteCircuitsClient) ListStatsNextResults(lastResults ExpressRouteCircuitsStatsListResult) (result ExpressRouteCircuitsStatsListResult, err error) { - req, err := lastResults.ExpressRouteCircuitsStatsListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListStatsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", resp, "Failure sending next results request request") - } - - result, err = client.ListStatsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListStats", resp, "Failure responding to next results request request") - } - + result.Response = resp return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go index 810243d2e..2f667a6a3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ExpressRouteServiceProvidersClient is the the Microsoft Azure Network @@ -71,20 +70,19 @@ func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServ // ListPreparer prepares the List request. func (client ExpressRouteServiceProvidersClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteServiceProviders"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/expressRouteServiceProviders", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go index b14b21b25..a9e6e4c9a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // InterfacesClient is the the Microsoft Azure Network management API provides @@ -76,23 +75,23 @@ func (client InterfacesClient) CreateOrUpdate(resourceGroupName string, networkI // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client InterfacesClient) CreateOrUpdatePreparer(resourceGroupName string, networkInterfaceName string, parameters Interface, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkInterfaceName": url.QueryEscape(networkInterfaceName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkInterfaceName": autorest.Encode("path", networkInterfaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -145,22 +144,21 @@ func (client InterfacesClient) Delete(resourceGroupName string, networkInterface // DeletePreparer prepares the Delete request. func (client InterfacesClient) DeletePreparer(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkInterfaceName": url.QueryEscape(networkInterfaceName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkInterfaceName": autorest.Encode("path", networkInterfaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,25 +210,24 @@ func (client InterfacesClient) Get(resourceGroupName string, networkInterfaceNam // GetPreparer prepares the Get request. func (client InterfacesClient) GetPreparer(resourceGroupName string, networkInterfaceName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkInterfaceName": url.QueryEscape(networkInterfaceName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkInterfaceName": autorest.Encode("path", networkInterfaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -283,27 +280,26 @@ func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterface(resourc // GetVirtualMachineScaleSetNetworkInterfacePreparer prepares the GetVirtualMachineScaleSetNetworkInterface request. func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterfacePreparer(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkInterfaceName": url.QueryEscape(networkInterfaceName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualmachineIndex": url.QueryEscape(virtualmachineIndex), - "virtualMachineScaleSetName": url.QueryEscape(virtualMachineScaleSetName), + "networkInterfaceName": autorest.Encode("path", networkInterfaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualmachineIndex": autorest.Encode("path", virtualmachineIndex), + "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces/{networkInterfaceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetVirtualMachineScaleSetNetworkInterfaceSender sends the GetVirtualMachineScaleSetNetworkInterface request. The method will close the @@ -352,21 +348,20 @@ func (client InterfacesClient) List(resourceGroupName string) (result InterfaceL // ListPreparer prepares the List request. func (client InterfacesClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -437,20 +432,19 @@ func (client InterfacesClient) ListAll() (result InterfaceListResult, err error) // ListAllPreparer prepares the ListAll request. func (client InterfacesClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkInterfaces"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkInterfaces", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the @@ -525,22 +519,21 @@ func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfaces(resou // ListVirtualMachineScaleSetNetworkInterfacesPreparer prepares the ListVirtualMachineScaleSetNetworkInterfaces request. func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesPreparer(resourceGroupName string, virtualMachineScaleSetName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualMachineScaleSetName": url.QueryEscape(virtualMachineScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/networkInterfaces"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/networkInterfaces", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListVirtualMachineScaleSetNetworkInterfacesSender sends the ListVirtualMachineScaleSetNetworkInterfaces request. The method will close the @@ -616,23 +609,22 @@ func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfaces(res // ListVirtualMachineScaleSetVMNetworkInterfacesPreparer prepares the ListVirtualMachineScaleSetVMNetworkInterfaces request. func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfacesPreparer(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualmachineIndex": url.QueryEscape(virtualmachineIndex), - "virtualMachineScaleSetName": url.QueryEscape(virtualMachineScaleSetName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualmachineIndex": autorest.Encode("path", virtualmachineIndex), + "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines/{virtualmachineIndex}/networkInterfaces", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListVirtualMachineScaleSetVMNetworkInterfacesSender sends the ListVirtualMachineScaleSetVMNetworkInterfaces request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go index f74225f8d..ceff4be3a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // LoadBalancersClient is the the Microsoft Azure Network management API @@ -77,23 +76,23 @@ func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadB // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client LoadBalancersClient) CreateOrUpdatePreparer(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "loadBalancerName": url.QueryEscape(loadBalancerName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "loadBalancerName": autorest.Encode("path", loadBalancerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -146,22 +145,21 @@ func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerN // DeletePreparer prepares the Delete request. func (client LoadBalancersClient) DeletePreparer(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "loadBalancerName": url.QueryEscape(loadBalancerName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "loadBalancerName": autorest.Encode("path", loadBalancerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,25 +210,24 @@ func (client LoadBalancersClient) Get(resourceGroupName string, loadBalancerName // GetPreparer prepares the Get request. func (client LoadBalancersClient) GetPreparer(resourceGroupName string, loadBalancerName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "loadBalancerName": url.QueryEscape(loadBalancerName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "loadBalancerName": autorest.Encode("path", loadBalancerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -279,21 +276,20 @@ func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBal // ListPreparer prepares the List request. func (client LoadBalancersClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -364,20 +360,19 @@ func (client LoadBalancersClient) ListAll() (result LoadBalancerListResult, err // ListAllPreparer prepares the ListAll request. func (client LoadBalancersClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/loadBalancers"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/loadBalancers", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go index 2c3c99f06..bc17e290b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // LocalNetworkGatewaysClient is the the Microsoft Azure Network management @@ -79,23 +78,23 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client LocalNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "localNetworkGatewayName": url.QueryEscape(localNetworkGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "localNetworkGatewayName": autorest.Encode("path", localNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -149,22 +148,21 @@ func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localN // DeletePreparer prepares the Delete request. func (client LocalNetworkGatewaysClient) DeletePreparer(resourceGroupName string, localNetworkGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "localNetworkGatewayName": url.QueryEscape(localNetworkGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "localNetworkGatewayName": autorest.Encode("path", localNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -215,22 +213,21 @@ func (client LocalNetworkGatewaysClient) Get(resourceGroupName string, localNetw // GetPreparer prepares the Get request. func (client LocalNetworkGatewaysClient) GetPreparer(resourceGroupName string, localNetworkGatewayName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "localNetworkGatewayName": url.QueryEscape(localNetworkGatewayName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "localNetworkGatewayName": autorest.Encode("path", localNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways/{localNetworkGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -279,21 +276,20 @@ func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result // ListPreparer prepares the List request. func (client LocalNetworkGatewaysClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/localNetworkGateways", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go index 9e60cb475..efcd7a738 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -200,6 +200,16 @@ const ( Static IPAllocationMethod = "Static" ) +// IPVersion enumerates the values for ip version. +type IPVersion string + +const ( + // IPv4 specifies the i pv 4 state for ip version. + IPv4 IPVersion = "IPv4" + // IPv6 specifies the i pv 6 state for ip version. + IPv6 IPVersion = "IPv6" +) + // LoadDistribution enumerates the values for load distribution. type LoadDistribution string @@ -331,14 +341,6 @@ const ( TransportProtocolUDP TransportProtocol = "Udp" ) -// UsageUnit enumerates the values for usage unit. -type UsageUnit string - -const ( - // Count specifies the count state for usage unit. - Count UsageUnit = "Count" -) - // VirtualNetworkGatewayConnectionStatus enumerates the values for virtual // network gateway connection status. type VirtualNetworkGatewayConnectionStatus string @@ -470,7 +472,7 @@ type ApplicationGatewayBackendAddressPool struct { // ApplicationGatewayBackendAddressPoolPropertiesFormat is properties of // Backend Address Pool of application gateway type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { - BackendIPConfigurations *[]SubResource `json:"backendIPConfigurations,omitempty"` + BackendIPConfigurations *[]InterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } @@ -545,7 +547,7 @@ type ApplicationGatewayHTTPListenerPropertiesFormat struct { Protocol ApplicationGatewayProtocol `json:"protocol,omitempty"` HostName *string `json:"hostName,omitempty"` SslCertificate *SubResource `json:"sslCertificate,omitempty"` - RequireServerNameIndication *string `json:"requireServerNameIndication,omitempty"` + RequireServerNameIndication *bool `json:"requireServerNameIndication,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } @@ -757,6 +759,13 @@ type BackendAddressPoolPropertiesFormat struct { ProvisioningState *string `json:"provisioningState,omitempty"` } +// BgpSettings is +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + PeerWeight *int32 `json:"peerWeight,omitempty"` +} + // ConnectionResetSharedKey is type ConnectionResetSharedKey struct { autorest.Response `json:"-"` @@ -822,6 +831,8 @@ type ExpressRouteCircuit struct { // ExpressRouteCircuitArpTable is the arp table associated with the // ExpressRouteCircuit type ExpressRouteCircuitArpTable struct { + Age *int32 `json:"age,omitempty"` + Interface *string `json:"interface,omitempty"` IPAddress *string `json:"ipAddress,omitempty"` MacAddress *string `json:"macAddress,omitempty"` } @@ -912,6 +923,7 @@ type ExpressRouteCircuitPeeringPropertiesFormat struct { // ExpressRouteCircuitPropertiesFormat is properties of ExpressRouteCircuit type ExpressRouteCircuitPropertiesFormat struct { + AllowClassicOperations *bool `json:"allowClassicOperations,omitempty"` CircuitProvisioningState *string `json:"circuitProvisioningState,omitempty"` ServiceProviderProvisioningState ServiceProviderProvisioningState `json:"serviceProviderProvisioningState,omitempty"` Authorizations *[]ExpressRouteCircuitAuthorization `json:"authorizations,omitempty"` @@ -925,10 +937,21 @@ type ExpressRouteCircuitPropertiesFormat struct { // ExpressRouteCircuitRoutesTable is the routes table associated with the // ExpressRouteCircuit type ExpressRouteCircuitRoutesTable struct { - AddressPrefix *string `json:"addressPrefix,omitempty"` - NextHopType RouteNextHopType `json:"nextHopType,omitempty"` - NextHopIP *string `json:"nextHopIP,omitempty"` - AsPath *string `json:"asPath,omitempty"` + Network *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + LocPrf *string `json:"locPrf,omitempty"` + Weight *int32 `json:"weight,omitempty"` + Path *string `json:"path,omitempty"` +} + +// ExpressRouteCircuitRoutesTableSummary is the routes table associated with +// the ExpressRouteCircuit +type ExpressRouteCircuitRoutesTableSummary struct { + Neighbor *string `json:"neighbor,omitempty"` + V *int32 `json:"v,omitempty"` + As *int32 `json:"as,omitempty"` + UpDown *string `json:"upDown,omitempty"` + StatePfxRcd *string `json:"statePfxRcd,omitempty"` } // ExpressRouteCircuitsArpTableListResult is response for ListArpTable @@ -939,18 +962,6 @@ type ExpressRouteCircuitsArpTableListResult struct { NextLink *string `json:"nextLink,omitempty"` } -// ExpressRouteCircuitsArpTableListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client ExpressRouteCircuitsArpTableListResult) ExpressRouteCircuitsArpTableListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) -} - // ExpressRouteCircuitServiceProviderProperties is contains // ServiceProviderProperties in an ExpressRouteCircuit type ExpressRouteCircuitServiceProviderProperties struct { @@ -974,42 +985,21 @@ type ExpressRouteCircuitsRoutesTableListResult struct { NextLink *string `json:"nextLink,omitempty"` } -// ExpressRouteCircuitsRoutesTableListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client ExpressRouteCircuitsRoutesTableListResult) ExpressRouteCircuitsRoutesTableListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) -} - -// ExpressRouteCircuitsStatsListResult is response for ListStats from Express -// Route Circuits Api service call -type ExpressRouteCircuitsStatsListResult struct { +// ExpressRouteCircuitsRoutesTableSummaryListResult is response for +// ListRoutesTable associated with the Express Route Circuits Api +type ExpressRouteCircuitsRoutesTableSummaryListResult struct { autorest.Response `json:"-"` - Value *[]ExpressRouteCircuitStats `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` -} - -// ExpressRouteCircuitsStatsListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client ExpressRouteCircuitsStatsListResult) ExpressRouteCircuitsStatsListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) + Value *[]ExpressRouteCircuitRoutesTableSummary `json:"value,omitempty"` + NextLink *string `json:"nextLink,omitempty"` } // ExpressRouteCircuitStats is contains Stats associated with the peering type ExpressRouteCircuitStats struct { - BytesIn *int32 `json:"bytesIn,omitempty"` - BytesOut *int32 `json:"bytesOut,omitempty"` + autorest.Response `json:"-"` + PrimarybytesIn *int64 `json:"primarybytesIn,omitempty"` + PrimarybytesOut *int64 `json:"primarybytesOut,omitempty"` + SecondarybytesIn *int64 `json:"secondarybytesIn,omitempty"` + SecondarybytesOut *int64 `json:"secondarybytesOut,omitempty"` } // ExpressRouteServiceProvider is expressRouteResourceProvider object @@ -1131,10 +1121,11 @@ type Interface struct { // InterfaceDNSSettings is dns Settings of a network interface type InterfaceDNSSettings struct { - DNSServers *[]string `json:"dnsServers,omitempty"` - AppliedDNSServers *[]string `json:"appliedDnsServers,omitempty"` - InternalDNSNameLabel *string `json:"internalDnsNameLabel,omitempty"` - InternalFqdn *string `json:"internalFqdn,omitempty"` + DNSServers *[]string `json:"dnsServers,omitempty"` + AppliedDNSServers *[]string `json:"appliedDnsServers,omitempty"` + InternalDNSNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` } // InterfaceIPConfiguration is iPConfiguration in a NetworkInterface @@ -1147,13 +1138,16 @@ type InterfaceIPConfiguration struct { // InterfaceIPConfigurationPropertiesFormat is properties of IPConfiguration type InterfaceIPConfigurationPropertiesFormat struct { - LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` - LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` - PrivateIPAddress *string `json:"privateIPAddress,omitempty"` - PrivateIPAllocationMethod IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` - Subnet *Subnet `json:"subnet,omitempty"` - PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` - ProvisioningState *string `json:"provisioningState,omitempty"` + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateIPAddressVersion IPVersion `json:"privateIPAddressVersion,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + Primary *bool `json:"primary,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` } // InterfaceListResult is response for ListNetworkInterface Api service call @@ -1307,6 +1301,7 @@ func (client LocalNetworkGatewayListResult) LocalNetworkGatewayListResultPrepare type LocalNetworkGatewayPropertiesFormat struct { LocalNetworkAddressSpace *AddressSpace `json:"localNetworkAddressSpace,omitempty"` GatewayIPAddress *string `json:"gatewayIpAddress,omitempty"` + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` ResourceGUID *string `json:"resourceGuid,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } @@ -1389,6 +1384,7 @@ func (client PublicIPAddressListResult) PublicIPAddressListResultPreparer() (*ht // PublicIPAddressPropertiesFormat is publicIpAddress properties type PublicIPAddressPropertiesFormat struct { PublicIPAllocationMethod IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPAddressVersion IPVersion `json:"publicIPAddressVersion,omitempty"` IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` DNSSettings *PublicIPAddressDNSSettings `json:"dnsSettings,omitempty"` IPAddress *string `json:"ipAddress,omitempty"` @@ -1616,7 +1612,7 @@ type SubResource struct { // Usage is describes Network Resource Usage. type Usage struct { - Unit UsageUnit `json:"unit,omitempty"` + Unit *string `json:"unit,omitempty"` CurrentValue *int64 `json:"currentValue,omitempty"` Limit *int64 `json:"limit,omitempty"` Name *UsageName `json:"name,omitempty"` @@ -1632,19 +1628,6 @@ type UsageName struct { type UsagesListResult struct { autorest.Response `json:"-"` Value *[]Usage `json:"value,omitempty"` - NextLink *string `json:",omitempty"` -} - -// UsagesListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client UsagesListResult) UsagesListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) } // VirtualNetwork is virtual Network resource @@ -1718,6 +1701,7 @@ type VirtualNetworkGatewayConnectionPropertiesFormat struct { EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` Peer *SubResource `json:"peer,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` ResourceGUID *string `json:"resourceGuid,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } @@ -1770,6 +1754,7 @@ type VirtualNetworkGatewayPropertiesFormat struct { GatewayDefaultSite *SubResource `json:"gatewayDefaultSite,omitempty"` Sku *VirtualNetworkGatewaySku `json:"sku,omitempty"` VpnClientConfiguration *VpnClientConfiguration `json:"vpnClientConfiguration,omitempty"` + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` ResourceGUID *string `json:"resourceGuid,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"` } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go index c33d66908..3d23c7f2f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // PublicIPAddressesClient is the the Microsoft Azure Network management API @@ -77,23 +76,23 @@ func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, p // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client PublicIPAddressesClient) CreateOrUpdatePreparer(resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "publicIpAddressName": url.QueryEscape(publicIPAddressName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "publicIpAddressName": autorest.Encode("path", publicIPAddressName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -146,22 +145,21 @@ func (client PublicIPAddressesClient) Delete(resourceGroupName string, publicIPA // DeletePreparer prepares the Delete request. func (client PublicIPAddressesClient) DeletePreparer(resourceGroupName string, publicIPAddressName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "publicIpAddressName": url.QueryEscape(publicIPAddressName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "publicIpAddressName": autorest.Encode("path", publicIPAddressName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,25 +210,24 @@ func (client PublicIPAddressesClient) Get(resourceGroupName string, publicIPAddr // GetPreparer prepares the Get request. func (client PublicIPAddressesClient) GetPreparer(resourceGroupName string, publicIPAddressName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "publicIpAddressName": url.QueryEscape(publicIPAddressName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "publicIpAddressName": autorest.Encode("path", publicIPAddressName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses/{publicIpAddressName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -279,21 +276,20 @@ func (client PublicIPAddressesClient) List(resourceGroupName string) (result Pub // ListPreparer prepares the List request. func (client PublicIPAddressesClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPAddresses", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -364,20 +360,19 @@ func (client PublicIPAddressesClient) ListAll() (result PublicIPAddressListResul // ListAllPreparer prepares the ListAll request. func (client PublicIPAddressesClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/publicIPAddresses"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/publicIPAddresses", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go index 624b26b27..afe589e99 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // RoutesClient is the the Microsoft Azure Network management API provides a @@ -75,24 +74,24 @@ func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableNa // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client RoutesClient) CreateOrUpdatePreparer(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeName": url.QueryEscape(routeName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeName": autorest.Encode("path", routeName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}", pathParameters), autorest.WithJSON(routeParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -145,23 +144,22 @@ func (client RoutesClient) Delete(resourceGroupName string, routeTableName strin // DeletePreparer prepares the Delete request. func (client RoutesClient) DeletePreparer(resourceGroupName string, routeTableName string, routeName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeName": url.QueryEscape(routeName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeName": autorest.Encode("path", routeName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -212,23 +210,22 @@ func (client RoutesClient) Get(resourceGroupName string, routeTableName string, // GetPreparer prepares the Get request. func (client RoutesClient) GetPreparer(resourceGroupName string, routeTableName string, routeName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeName": url.QueryEscape(routeName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeName": autorest.Encode("path", routeName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes/{routeName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -278,22 +275,21 @@ func (client RoutesClient) List(resourceGroupName string, routeTableName string) // ListPreparer prepares the List request. func (client RoutesClient) ListPreparer(resourceGroupName string, routeTableName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}/routes", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go index 9008d4e03..f3473b908 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // RouteTablesClient is the the Microsoft Azure Network management API @@ -76,23 +75,23 @@ func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTa // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client RouteTablesClient) CreateOrUpdatePreparer(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -145,22 +144,21 @@ func (client RouteTablesClient) Delete(resourceGroupName string, routeTableName // DeletePreparer prepares the Delete request. func (client RouteTablesClient) DeletePreparer(resourceGroupName string, routeTableName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -211,25 +209,24 @@ func (client RouteTablesClient) Get(resourceGroupName string, routeTableName str // GetPreparer prepares the Get request. func (client RouteTablesClient) GetPreparer(resourceGroupName string, routeTableName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "routeTableName": url.QueryEscape(routeTableName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "routeTableName": autorest.Encode("path", routeTableName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables/{routeTableName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -277,21 +274,20 @@ func (client RouteTablesClient) List(resourceGroupName string) (result RouteTabl // ListPreparer prepares the List request. func (client RouteTablesClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeTables", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -361,20 +357,19 @@ func (client RouteTablesClient) ListAll() (result RouteTableListResult, err erro // ListAllPreparer prepares the ListAll request. func (client RouteTablesClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/routeTables"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/routeTables", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go index 0b834af9e..e6ccc5814 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // SecurityGroupsClient is the the Microsoft Azure Network management API @@ -79,23 +78,23 @@ func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, netw // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client SecurityGroupsClient) CreateOrUpdatePreparer(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -148,22 +147,21 @@ func (client SecurityGroupsClient) Delete(resourceGroupName string, networkSecur // DeletePreparer prepares the Delete request. func (client SecurityGroupsClient) DeletePreparer(resourceGroupName string, networkSecurityGroupName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -215,25 +213,24 @@ func (client SecurityGroupsClient) Get(resourceGroupName string, networkSecurity // GetPreparer prepares the Get request. func (client SecurityGroupsClient) GetPreparer(resourceGroupName string, networkSecurityGroupName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -282,21 +279,20 @@ func (client SecurityGroupsClient) List(resourceGroupName string) (result Securi // ListPreparer prepares the List request. func (client SecurityGroupsClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -367,20 +363,19 @@ func (client SecurityGroupsClient) ListAll() (result SecurityGroupListResult, er // ListAllPreparer prepares the ListAll request. func (client SecurityGroupsClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityGroups"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkSecurityGroups", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go index 8cf5e3cc6..56d10a97a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // SecurityRulesClient is the the Microsoft Azure Network management API @@ -80,24 +79,24 @@ func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, netwo // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client SecurityRulesClient) CreateOrUpdatePreparer(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "securityRuleName": url.QueryEscape(securityRuleName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityRuleName": autorest.Encode("path", securityRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}", pathParameters), autorest.WithJSON(securityRuleParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -151,23 +150,22 @@ func (client SecurityRulesClient) Delete(resourceGroupName string, networkSecuri // DeletePreparer prepares the Delete request. func (client SecurityRulesClient) DeletePreparer(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "securityRuleName": url.QueryEscape(securityRuleName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityRuleName": autorest.Encode("path", securityRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -219,23 +217,22 @@ func (client SecurityRulesClient) Get(resourceGroupName string, networkSecurityG // GetPreparer prepares the Get request. func (client SecurityRulesClient) GetPreparer(resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "securityRuleName": url.QueryEscape(securityRuleName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "securityRuleName": autorest.Encode("path", securityRuleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules/{securityRuleName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -285,22 +282,21 @@ func (client SecurityRulesClient) List(resourceGroupName string, networkSecurity // ListPreparer prepares the List request. func (client SecurityRulesClient) ListPreparer(resourceGroupName string, networkSecurityGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "networkSecurityGroupName": url.QueryEscape(networkSecurityGroupName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "networkSecurityGroupName": autorest.Encode("path", networkSecurityGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}/securityRules", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go index 1c75a2760..583d5fe55 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // SubnetsClient is the the Microsoft Azure Network management API provides a @@ -76,24 +75,24 @@ func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetw // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client SubnetsClient) CreateOrUpdatePreparer(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subnetName": url.QueryEscape(subnetName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}/subnets/{subnetName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}", pathParameters), autorest.WithJSON(subnetParameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -146,23 +145,22 @@ func (client SubnetsClient) Delete(resourceGroupName string, virtualNetworkName // DeletePreparer prepares the Delete request. func (client SubnetsClient) DeletePreparer(resourceGroupName string, virtualNetworkName string, subnetName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subnetName": url.QueryEscape(subnetName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}/subnets/{subnetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -214,26 +212,25 @@ func (client SubnetsClient) Get(resourceGroupName string, virtualNetworkName str // GetPreparer prepares the Get request. func (client SubnetsClient) GetPreparer(resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subnetName": url.QueryEscape(subnetName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subnetName": autorest.Encode("path", subnetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}/subnets/{subnetName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -283,22 +280,21 @@ func (client SubnetsClient) List(resourceGroupName string, virtualNetworkName st // ListPreparer prepares the List request. func (client SubnetsClient) ListPreparer(resourceGroupName string, virtualNetworkName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}/subnets"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go index 3b2236caf..6c6953890 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // UsagesClient is the the Microsoft Azure Network management API provides a @@ -70,21 +69,20 @@ func (client UsagesClient) List(location string) (result UsagesListResult, err e // ListPreparer prepares the List request. func (client UsagesClient) ListPreparer(location string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "location": url.QueryEscape(location), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "location": autorest.Encode("path", location), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/usages"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/usages", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -105,27 +103,3 @@ func (client UsagesClient) ListResponder(resp *http.Response) (result UsagesList result.Response = autorest.Response{Response: resp} return } - -// ListNextResults retrieves the next set of results, if any. -func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result UsagesListResult, err error) { - req, err := lastResults.UsagesListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending next results request request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go index 16e3c74f0..57732cbdf 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,9 +23,9 @@ import ( ) const ( - major = "2" + major = "3" minor = "1" - patch = "1" + patch = "0" // Always begin a "tag" with a dash (as per http://semver.org) tag = "-beta" semVerFormat = "%s.%s.%s%s" @@ -34,7 +34,7 @@ const ( // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "network", "2015-06-15") + return fmt.Sprintf(userAgentFormat, Version(), "network", "2016-03-30") } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go index 2094cb2e0..9a9ef51bf 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgatewayconnections.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualNetworkGatewayConnectionsClient is the the Microsoft Azure Network @@ -81,23 +80,23 @@ func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(resourceGrou // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdatePreparer(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayConnectionName": url.QueryEscape(virtualNetworkGatewayConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -152,22 +151,21 @@ func (client VirtualNetworkGatewayConnectionsClient) Delete(resourceGroupName st // DeletePreparer prepares the Delete request. func (client VirtualNetworkGatewayConnectionsClient) DeletePreparer(resourceGroupName string, virtualNetworkGatewayConnectionName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayConnectionName": url.QueryEscape(virtualNetworkGatewayConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -220,22 +218,21 @@ func (client VirtualNetworkGatewayConnectionsClient) Get(resourceGroupName strin // GetPreparer prepares the Get request. func (client VirtualNetworkGatewayConnectionsClient) GetPreparer(resourceGroupName string, virtualNetworkGatewayConnectionName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayConnectionName": url.QueryEscape(virtualNetworkGatewayConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -287,22 +284,21 @@ func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(resourceGroupN // GetSharedKeyPreparer prepares the GetSharedKey request. func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyPreparer(resourceGroupName string, connectionSharedKeyName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "connectionSharedKeyName": url.QueryEscape(connectionSharedKeyName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "connectionSharedKeyName": autorest.Encode("path", connectionSharedKeyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{connectionSharedKeyName}/sharedkey"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{connectionSharedKeyName}/sharedkey", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSharedKeySender sends the GetSharedKey request. The method will close the @@ -351,21 +347,20 @@ func (client VirtualNetworkGatewayConnectionsClient) List(resourceGroupName stri // ListPreparer prepares the List request. func (client VirtualNetworkGatewayConnectionsClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -446,23 +441,23 @@ func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(resourceGrou // ResetSharedKeyPreparer prepares the ResetSharedKey request. func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyPreparer(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayConnectionName": url.QueryEscape(virtualNetworkGatewayConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey/reset"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey/reset", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // ResetSharedKeySender sends the ResetSharedKey request. The method will close the @@ -520,23 +515,23 @@ func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(resourceGroupN // SetSharedKeyPreparer prepares the SetSharedKey request. func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyPreparer(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayConnectionName": url.QueryEscape(virtualNetworkGatewayConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/connections/{virtualNetworkGatewayConnectionName}/sharedkey", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // SetSharedKeySender sends the SetSharedKey request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go index 2649c4eb2..d37d452f1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualNetworkGatewaysClient is the the Microsoft Azure Network management @@ -79,23 +78,23 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdate(resourceGroupName stri // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayName": url.QueryEscape(virtualNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -149,22 +148,21 @@ func (client VirtualNetworkGatewaysClient) Delete(resourceGroupName string, virt // DeletePreparer prepares the Delete request. func (client VirtualNetworkGatewaysClient) DeletePreparer(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayName": url.QueryEscape(virtualNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -218,23 +216,23 @@ func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(resourceGrou // GeneratevpnclientpackagePreparer prepares the Generatevpnclientpackage request. func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayName": url.QueryEscape(virtualNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}/generatevpnclientpackage"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/generatevpnclientpackage", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GeneratevpnclientpackageSender sends the Generatevpnclientpackage request. The method will close the @@ -284,22 +282,21 @@ func (client VirtualNetworkGatewaysClient) Get(resourceGroupName string, virtual // GetPreparer prepares the Get request. func (client VirtualNetworkGatewaysClient) GetPreparer(resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayName": url.QueryEscape(virtualNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -348,21 +345,20 @@ func (client VirtualNetworkGatewaysClient) List(resourceGroupName string) (resul // ListPreparer prepares the List request. func (client VirtualNetworkGatewaysClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -441,23 +437,23 @@ func (client VirtualNetworkGatewaysClient) Reset(resourceGroupName string, virtu // ResetPreparer prepares the Reset request. func (client VirtualNetworkGatewaysClient) ResetPreparer(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkGatewayName": url.QueryEscape(virtualNetworkGatewayName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}/reset"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/reset", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // ResetSender sends the Reset request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go index bb50a7f01..30a035a23 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go @@ -14,7 +14,7 @@ package network // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // VirtualNetworksClient is the the Microsoft Azure Network management API @@ -78,23 +77,23 @@ func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, vir // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client VirtualNetworksClient) CreateOrUpdatePreparer(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -147,22 +146,21 @@ func (client VirtualNetworksClient) Delete(resourceGroupName string, virtualNetw // DeletePreparer prepares the Delete request. func (client VirtualNetworksClient) DeletePreparer(resourceGroupName string, virtualNetworkName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -213,25 +211,24 @@ func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetwork // GetPreparer prepares the Get request. func (client VirtualNetworksClient) GetPreparer(resourceGroupName string, virtualNetworkName string, expand string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "virtualNetworkName": url.QueryEscape(virtualNetworkName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "virtualNetworkName": autorest.Encode("path", virtualNetworkName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(expand) > 0 { - queryParameters["$expand"] = expand + queryParameters["$expand"] = autorest.Encode("query", expand) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks/{virtualNetworkName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -280,21 +277,20 @@ func (client VirtualNetworksClient) List(resourceGroupName string) (result Virtu // ListPreparer prepares the List request. func (client VirtualNetworksClient) ListPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualnetworks"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -365,20 +361,19 @@ func (client VirtualNetworksClient) ListAll() (result VirtualNetworkListResult, // ListAllPreparer prepares the ListAll request. func (client VirtualNetworksClient) ListAllPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualnetworks"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/virtualNetworks", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListAllSender sends the ListAll request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go index 687c905ef..ecb5afbd0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/client.go @@ -1,5 +1,5 @@ // Package resources implements the Azure ARM Resources service API version -// 2015-11-01. +// 2016-02-01. // package resources @@ -17,7 +17,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,12 +25,11 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) const ( // APIVersion is the version of the Resources - APIVersion = "2015-11-01" + APIVersion = "2016-02-01" // DefaultBaseURI is the default URI used for the service Resources DefaultBaseURI = "https://management.azure.com" @@ -40,6 +39,7 @@ const ( type ManagementClient struct { autorest.Client BaseURI string + APIVersion string SubscriptionID string } @@ -53,6 +53,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, + APIVersion: APIVersion, SubscriptionID: subscriptionID, } } @@ -63,8 +64,8 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client ManagementClient) CheckExistence(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, err error) { - req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client ManagementClient) CheckExistence(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) { + req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.ManagementClient", "CheckExistence", nil, "Failure preparing request") } @@ -84,27 +85,26 @@ func (client ManagementClient) CheckExistence(resourceGroupName string, resource } // CheckExistencePreparer prepares the CheckExistence request. -func (client ManagementClient) CheckExistencePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client ManagementClient) CheckExistencePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsHead(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckExistenceSender sends the CheckExistence request. The method will close the @@ -132,8 +132,8 @@ func (client ManagementClient) CheckExistenceResponder(resp *http.Response) (res // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. parameters is create or // update resource parameters. -func (client ManagementClient) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource) (result GenericResource, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters) +func (client ManagementClient) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (result GenericResource, err error) { + req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, parameters) if err != nil { return result, autorest.NewErrorWithError(err, "resources.ManagementClient", "CreateOrUpdate", nil, "Failure preparing request") } @@ -153,28 +153,28 @@ func (client ManagementClient) CreateOrUpdate(resourceGroupName string, resource } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ManagementClient) CreateOrUpdatePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource) (*http.Request, error) { +func (client ManagementClient) CreateOrUpdatePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -202,8 +202,8 @@ func (client ManagementClient) CreateOrUpdateResponder(resp *http.Response) (res // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client ManagementClient) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client ManagementClient) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.ManagementClient", "Delete", nil, "Failure preparing request") } @@ -223,27 +223,26 @@ func (client ManagementClient) Delete(resourceGroupName string, resourceProvider } // DeletePreparer prepares the Delete request. -func (client ManagementClient) DeletePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client ManagementClient) DeletePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteSender sends the Delete request. The method will close the @@ -270,8 +269,8 @@ func (client ManagementClient) DeleteResponder(resp *http.Response) (result auto // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client ManagementClient) Get(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result GenericResource, err error) { - req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client ManagementClient) Get(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result GenericResource, err error) { + req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.ManagementClient", "Get", nil, "Failure preparing request") } @@ -291,27 +290,26 @@ func (client ManagementClient) Get(resourceGroupName string, resourceProviderNam } // GetPreparer prepares the Get request. -func (client ManagementClient) GetPreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client ManagementClient) GetPreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -326,7 +324,7 @@ func (client ManagementClient) GetResponder(resp *http.Response) (result Generic err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -360,26 +358,25 @@ func (client ManagementClient) List(filter string, top *int32) (result ResourceL // ListPreparer prepares the List request. func (client ManagementClient) ListPreparer(filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resources"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -425,8 +422,8 @@ func (client ManagementClient) ListNextResults(lastResults ResourceListResult) ( return } -// MoveResources begin moving resources.To determine whether the operation has -// finished processing the request, call GetLongRunningOperationStatus. This +// MoveResources move resources from one resource group to another. The +// resources being moved should all be in the same resource group. This // method may poll for completion. Polling can be canceled by passing the // cancel channel argument. The channel will be used to cancel polling and // any outstanding HTTP requests. @@ -456,22 +453,22 @@ func (client ManagementClient) MoveResources(sourceResourceGroupName string, par // MoveResourcesPreparer prepares the MoveResources request. func (client ManagementClient) MoveResourcesPreparer(sourceResourceGroupName string, parameters MoveInfo, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "sourceResourceGroupName": url.QueryEscape(sourceResourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // MoveResourcesSender sends the MoveResources request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go index abdcf3f20..8c66f0514 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deploymentoperations.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // DeploymentOperationsClient is the client for the DeploymentOperations @@ -71,23 +70,22 @@ func (client DeploymentOperationsClient) Get(resourceGroupName string, deploymen // GetPreparer prepares the Get request. func (client DeploymentOperationsClient) GetPreparer(resourceGroupName string, deploymentName string, operationID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "operationId": url.QueryEscape(operationID), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "operationId": autorest.Encode("path", operationID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -137,25 +135,24 @@ func (client DeploymentOperationsClient) List(resourceGroupName string, deployme // ListPreparer prepares the List request. func (client DeploymentOperationsClient) ListPreparer(resourceGroupName string, deploymentName string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go index 4f61041d2..97c4ab347 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/deployments.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // DeploymentsClient is the client for the Deployments methods of the @@ -69,22 +68,21 @@ func (client DeploymentsClient) Cancel(resourceGroupName string, deploymentName // CancelPreparer prepares the Cancel request. func (client DeploymentsClient) CancelPreparer(resourceGroupName string, deploymentName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CancelSender sends the Cancel request. The method will close the @@ -132,22 +130,21 @@ func (client DeploymentsClient) CheckExistence(resourceGroupName string, deploym // CheckExistencePreparer prepares the CheckExistence request. func (client DeploymentsClient) CheckExistencePreparer(resourceGroupName string, deploymentName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsHead(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckExistenceSender sends the CheckExistence request. The method will close the @@ -199,23 +196,23 @@ func (client DeploymentsClient) CreateOrUpdate(resourceGroupName string, deploym // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client DeploymentsClient) CreateOrUpdatePreparer(resourceGroupName string, deploymentName string, parameters Deployment, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -238,11 +235,9 @@ func (client DeploymentsClient) CreateOrUpdateResponder(resp *http.Response) (re return } -// Delete begin deleting deployment.To determine whether the operation has -// finished processing the request, call GetLongRunningOperationStatus. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// Delete delete deployment. This method may poll for completion. Polling can +// be canceled by passing the cancel channel argument. The channel will be +// used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group. The name is case // insensitive. deploymentName is the name of the deployment to be deleted. @@ -269,22 +264,21 @@ func (client DeploymentsClient) Delete(resourceGroupName string, deploymentName // DeletePreparer prepares the Delete request. func (client DeploymentsClient) DeletePreparer(resourceGroupName string, deploymentName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -307,6 +301,69 @@ func (client DeploymentsClient) DeleteResponder(resp *http.Response) (result aut return } +// ExportTemplate exports a deployment template. +// +// resourceGroupName is the name of the resource group. The name is case +// insensitive. deploymentName is the name of the deployment. +func (client DeploymentsClient) ExportTemplate(resourceGroupName string, deploymentName string) (result DeploymentExportResult, err error) { + req, err := client.ExportTemplatePreparer(resourceGroupName, deploymentName) + if err != nil { + return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", nil, "Failure preparing request") + } + + resp, err := client.ExportTemplateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure sending request") + } + + result, err = client.ExportTemplateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.DeploymentsClient", "ExportTemplate", resp, "Failure responding to request") + } + + return +} + +// ExportTemplatePreparer prepares the ExportTemplate request. +func (client DeploymentsClient) ExportTemplatePreparer(resourceGroupName string, deploymentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ExportTemplateSender sends the ExportTemplate request. The method will close the +// http.Response Body if it receives an error. +func (client DeploymentsClient) ExportTemplateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ExportTemplateResponder handles the response to the ExportTemplate request. The method always +// closes the http.Response Body. +func (client DeploymentsClient) ExportTemplateResponder(resp *http.Response) (result DeploymentExportResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Get get a deployment. // // resourceGroupName is the name of the resource group to get. The name is @@ -334,22 +391,21 @@ func (client DeploymentsClient) Get(resourceGroupName string, deploymentName str // GetPreparer prepares the Get request. func (client DeploymentsClient) GetPreparer(resourceGroupName string, deploymentName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -399,27 +455,26 @@ func (client DeploymentsClient) List(resourceGroupName string, filter string, to // ListPreparer prepares the List request. func (client DeploymentsClient) ListPreparer(resourceGroupName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -493,23 +548,23 @@ func (client DeploymentsClient) Validate(resourceGroupName string, deploymentNam // ValidatePreparer prepares the Validate request. func (client DeploymentsClient) ValidatePreparer(resourceGroupName string, deploymentName string, parameters Deployment) (*http.Request, error) { pathParameters := map[string]interface{}{ - "deploymentName": url.QueryEscape(deploymentName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "deploymentName": autorest.Encode("path", deploymentName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ValidateSender sends the Validate request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go index aa874d97a..2a4256ba4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/groups.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // GroupsClient is the client for the Groups methods of the Resources service. @@ -67,21 +66,20 @@ func (client GroupsClient) CheckExistence(resourceGroupName string) (result auto // CheckExistencePreparer prepares the CheckExistence request. func (client GroupsClient) CheckExistencePreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsHead(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckExistenceSender sends the CheckExistence request. The method will close the @@ -130,22 +128,22 @@ func (client GroupsClient) CreateOrUpdate(resourceGroupName string, parameters R // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client GroupsClient) CreateOrUpdatePreparer(resourceGroupName string, parameters ResourceGroup) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -167,11 +165,9 @@ func (client GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result return } -// Delete begin deleting resource group.To determine whether the operation has -// finished processing the request, call GetLongRunningOperationStatus. This -// method may poll for completion. Polling can be canceled by passing the -// cancel channel argument. The channel will be used to cancel polling and -// any outstanding HTTP requests. +// Delete delete resource group. This method may poll for completion. Polling +// can be canceled by passing the cancel channel argument. The channel will +// be used to cancel polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group to be deleted. The name // is case insensitive. @@ -198,21 +194,20 @@ func (client GroupsClient) Delete(resourceGroupName string, cancel <-chan struct // DeletePreparer prepares the Delete request. func (client GroupsClient) DeletePreparer(resourceGroupName string, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // DeleteSender sends the Delete request. The method will close the @@ -235,6 +230,71 @@ func (client GroupsClient) DeleteResponder(resp *http.Response) (result autorest return } +// ExportTemplate captures the specified resource group as a template. +// +// resourceGroupName is the name of the resource group to be created or +// updated. parameters is parameters supplied to the export template resource +// group operation. +func (client GroupsClient) ExportTemplate(resourceGroupName string, parameters ExportTemplateRequest) (result ResourceGroupExportResult, err error) { + req, err := client.ExportTemplatePreparer(resourceGroupName, parameters) + if err != nil { + return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", nil, "Failure preparing request") + } + + resp, err := client.ExportTemplateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure sending request") + } + + result, err = client.ExportTemplateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure responding to request") + } + + return +} + +// ExportTemplatePreparer prepares the ExportTemplate request. +func (client GroupsClient) ExportTemplatePreparer(resourceGroupName string, parameters ExportTemplateRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + queryParameters := map[string]interface{}{ + "api-version": client.APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsJSON(), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) +} + +// ExportTemplateSender sends the ExportTemplate request. The method will close the +// http.Response Body if it receives an error. +func (client GroupsClient) ExportTemplateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req) +} + +// ExportTemplateResponder handles the response to the ExportTemplate request. The method always +// closes the http.Response Body. +func (client GroupsClient) ExportTemplateResponder(resp *http.Response) (result ResourceGroupExportResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Get get a resource group. // // resourceGroupName is the name of the resource group to get. The name is @@ -262,21 +322,20 @@ func (client GroupsClient) Get(resourceGroupName string) (result ResourceGroup, // GetPreparer prepares the Get request. func (client GroupsClient) GetPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -325,26 +384,25 @@ func (client GroupsClient) List(filter string, top *int32) (result ResourceGroup // ListPreparer prepares the List request. func (client GroupsClient) ListPreparer(filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -418,27 +476,26 @@ func (client GroupsClient) ListResources(resourceGroupName string, filter string // ListResourcesPreparer prepares the ListResources request. func (client GroupsClient) ListResourcesPreparer(resourceGroupName string, filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListResourcesSender sends the ListResources request. The method will close the @@ -515,22 +572,22 @@ func (client GroupsClient) Patch(resourceGroupName string, parameters ResourceGr // PatchPreparer prepares the Patch request. func (client GroupsClient) PatchPreparer(resourceGroupName string, parameters ResourceGroup) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPatch(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // PatchSender sends the Patch request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go index dddb3adae..d89075425 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/models.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -35,6 +35,15 @@ const ( Incremental DeploymentMode = "Incremental" ) +// ResourceIdentityType enumerates the values for resource identity type. +type ResourceIdentityType string + +const ( + // SystemAssigned specifies the system assigned state for resource + // identity type. + SystemAssigned ResourceIdentityType = "SystemAssigned" +) + // BasicDependency is deployment dependency information. type BasicDependency struct { ID *string `json:"id,omitempty"` @@ -42,6 +51,11 @@ type BasicDependency struct { ResourceName *string `json:"resourceName,omitempty"` } +// DebugSetting is +type DebugSetting struct { + DetailLevel *string `json:"detailLevel,omitempty"` +} + // Dependency is deployment dependency information. type Dependency struct { DependsOn *[]BasicDependency `json:"dependsOn,omitempty"` @@ -55,6 +69,12 @@ type Deployment struct { Properties *DeploymentProperties `json:"properties,omitempty"` } +// DeploymentExportResult is +type DeploymentExportResult struct { + autorest.Response `json:"-"` + Template *map[string]interface{} `json:"template,omitempty"` +} + // DeploymentExtended is deployment information. type DeploymentExtended struct { autorest.Response `json:"-"` @@ -99,9 +119,12 @@ type DeploymentOperation struct { type DeploymentOperationProperties struct { ProvisioningState *string `json:"provisioningState,omitempty"` Timestamp *date.Time `json:"timestamp,omitempty"` + ServiceRequestID *string `json:"serviceRequestId,omitempty"` StatusCode *string `json:"statusCode,omitempty"` StatusMessage *map[string]interface{} `json:"statusMessage,omitempty"` TargetResource *TargetResource `json:"targetResource,omitempty"` + Request *HTTPMessage `json:"request,omitempty"` + Response *HTTPMessage `json:"response,omitempty"` } // DeploymentOperationsListResult is list of deployment operations. @@ -130,6 +153,7 @@ type DeploymentProperties struct { Parameters *map[string]interface{} `json:"parameters,omitempty"` ParametersLink *ParametersLink `json:"parametersLink,omitempty"` Mode DeploymentMode `json:"mode,omitempty"` + DebugSetting *DebugSetting `json:"debugSetting,omitempty"` } // DeploymentPropertiesExtended is deployment properties with additional @@ -146,6 +170,7 @@ type DeploymentPropertiesExtended struct { Parameters *map[string]interface{} `json:"parameters,omitempty"` ParametersLink *ParametersLink `json:"parametersLink,omitempty"` Mode DeploymentMode `json:"mode,omitempty"` + DebugSetting *DebugSetting `json:"debugSetting,omitempty"` } // DeploymentValidateResult is information from validate template deployment @@ -156,6 +181,12 @@ type DeploymentValidateResult struct { Properties *DeploymentPropertiesExtended `json:"properties,omitempty"` } +// ExportTemplateRequest is export resource group template request parameters. +type ExportTemplateRequest struct { + Resources *[]string `json:"resources,omitempty"` + Options *string `json:"options,omitempty"` +} + // GenericResource is resource information. type GenericResource struct { autorest.Response `json:"-"` @@ -166,6 +197,10 @@ type GenericResource struct { Tags *map[string]*string `json:"tags,omitempty"` Plan *Plan `json:"plan,omitempty"` Properties *map[string]interface{} `json:"properties,omitempty"` + Kind *string `json:"kind,omitempty"` + ManagedBy *string `json:"managedBy,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Identity *Identity `json:"identity,omitempty"` } // GenericResourceFilter is resource filter. @@ -173,6 +208,19 @@ type GenericResourceFilter struct { ResourceType *string `json:"resourceType,omitempty"` Tagname *string `json:"tagname,omitempty"` Tagvalue *string `json:"tagvalue,omitempty"` + Expand *string `json:"expand,omitempty"` +} + +// HTTPMessage is +type HTTPMessage struct { + Content *map[string]interface{} `json:"content,omitempty"` +} + +// Identity is identity for the resource. +type Identity struct { + PrincipalID *string `json:"principalId,omitempty"` + TenantID *string `json:"tenantId,omitempty"` + Type ResourceIdentityType `json:"type,omitempty"` } // MoveInfo is parameters of move resources. @@ -196,53 +244,6 @@ type Plan struct { PromotionCode *string `json:"promotionCode,omitempty"` } -// PolicyAssignment is policy assignment. -type PolicyAssignment struct { - autorest.Response `json:"-"` - Properties *PolicyAssignmentProperties `json:"properties,omitempty"` - Name *string `json:"name,omitempty"` -} - -// PolicyAssignmentListResult is policy assignment list operation result. -type PolicyAssignmentListResult struct { - autorest.Response `json:"-"` - Value *[]PolicyAssignment `json:"value,omitempty"` - NextLink *string `json:"nextLink,omitempty"` -} - -// PolicyAssignmentListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client PolicyAssignmentListResult) PolicyAssignmentListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) -} - -// PolicyAssignmentProperties is policy Assignment properties. -type PolicyAssignmentProperties struct { - Scope *string `json:"scope,omitempty"` - DisplayName *string `json:"displayName,omitempty"` - PolicyDefinitionID *string `json:"policyDefinitionId,omitempty"` -} - -// PolicyDefinition is policy definition. -type PolicyDefinition struct { - autorest.Response `json:"-"` - Properties *PolicyDefinitionProperties `json:"properties,omitempty"` - Name *string `json:"name,omitempty"` -} - -// PolicyDefinitionProperties is policy definition properties. -type PolicyDefinitionProperties struct { - Description *string `json:"description,omitempty"` - DisplayName *string `json:"displayName,omitempty"` - PolicyRule *map[string]interface{} `json:"policyRule,omitempty"` -} - // Provider is resource provider information. type Provider struct { autorest.Response `json:"-"` @@ -298,6 +299,13 @@ type ResourceGroup struct { Tags *map[string]*string `json:"tags,omitempty"` } +// ResourceGroupExportResult is +type ResourceGroupExportResult struct { + autorest.Response `json:"-"` + Template *map[string]interface{} `json:"template,omitempty"` + Error *ResourceManagementErrorWithDetails `json:"error,omitempty"` +} + // ResourceGroupFilter is resource group filter. type ResourceGroupFilter struct { TagName *string `json:"tagName,omitempty"` @@ -347,46 +355,12 @@ func (client ResourceListResult) ResourceListResultPreparer() (*http.Request, er autorest.WithBaseURL(to.String(client.NextLink))) } -// ResourceManagementError is -type ResourceManagementError struct { - Code *string `json:"code,omitempty"` - Message *string `json:"message,omitempty"` - Target *string `json:"target,omitempty"` -} - // ResourceManagementErrorWithDetails is type ResourceManagementErrorWithDetails struct { - Code *string `json:"code,omitempty"` - Message *string `json:"message,omitempty"` - Target *string `json:"target,omitempty"` - Details *[]ResourceManagementError `json:"details,omitempty"` -} - -// ResourceProviderOperationDefinition is resource provider operation -// information. -type ResourceProviderOperationDefinition struct { - Name *string `json:"name,omitempty"` - Display *ResourceProviderOperationDisplayProperties `json:"display,omitempty"` -} - -// ResourceProviderOperationDetailListResult is list of resource provider -// operations. -type ResourceProviderOperationDetailListResult struct { - autorest.Response `json:"-"` - Value *[]ResourceProviderOperationDefinition `json:"value,omitempty"` - NextLink *string `json:",omitempty"` -} - -// ResourceProviderOperationDetailListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client ResourceProviderOperationDetailListResult) ResourceProviderOperationDetailListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` + Details *[]ResourceManagementErrorWithDetails `json:"details,omitempty"` } // ResourceProviderOperationDisplayProperties is resource provider operation's @@ -399,6 +373,16 @@ type ResourceProviderOperationDisplayProperties struct { Description *string `json:"description,omitempty"` } +// Sku is sku for the resource. +type Sku struct { + Name *string `json:"name,omitempty"` + Tier *string `json:"tier,omitempty"` + Size *string `json:"size,omitempty"` + Family *string `json:"family,omitempty"` + Model *string `json:"model,omitempty"` + Capacity *int32 `json:"capacity,omitempty"` +} + // SubResource is type SubResource struct { ID *string `json:"id,omitempty"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policyassignments.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policyassignments.go deleted file mode 100644 index 7233c2bd3..000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policyassignments.go +++ /dev/null @@ -1,786 +0,0 @@ -package resources - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "net/url" -) - -// PolicyAssignmentsClient is the client for the PolicyAssignments methods of -// the Resources service. -type PolicyAssignmentsClient struct { - ManagementClient -} - -// NewPolicyAssignmentsClient creates an instance of the -// PolicyAssignmentsClient client. -func NewPolicyAssignmentsClient(subscriptionID string) PolicyAssignmentsClient { - return NewPolicyAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPolicyAssignmentsClientWithBaseURI creates an instance of the -// PolicyAssignmentsClient client. -func NewPolicyAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) PolicyAssignmentsClient { - return PolicyAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Create create policy assignment. -// -// scope is scope. policyAssignmentName is policy assignment name. parameters -// is policy assignment. -func (client PolicyAssignmentsClient) Create(scope string, policyAssignmentName string, parameters PolicyAssignment) (result PolicyAssignment, err error) { - req, err := client.CreatePreparer(scope, policyAssignmentName, parameters) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Create", nil, "Failure preparing request") - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Create", resp, "Failure sending request") - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client PolicyAssignmentsClient) CreatePreparer(scope string, policyAssignmentName string, parameters PolicyAssignment) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentName": url.QueryEscape(policyAssignmentName), - "scope": scope, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"), - autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) CreateResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateByID create policy assignment by Id. -// -// policyAssignmentID is policy assignment Id parameters is policy assignment. -func (client PolicyAssignmentsClient) CreateByID(policyAssignmentID string, parameters PolicyAssignment) (result PolicyAssignment, err error) { - req, err := client.CreateByIDPreparer(policyAssignmentID, parameters) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "CreateByID", nil, "Failure preparing request") - } - - resp, err := client.CreateByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "CreateByID", resp, "Failure sending request") - } - - result, err = client.CreateByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "CreateByID", resp, "Failure responding to request") - } - - return -} - -// CreateByIDPreparer prepares the CreateByID request. -func (client PolicyAssignmentsClient) CreateByIDPreparer(policyAssignmentID string, parameters PolicyAssignment) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentId": policyAssignmentID, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{policyAssignmentId}"), - autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// CreateByIDSender sends the CreateByID request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) CreateByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CreateByIDResponder handles the response to the CreateByID request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) CreateByIDResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete delete policy assignment. -// -// scope is scope. policyAssignmentName is policy assignment name. -func (client PolicyAssignmentsClient) Delete(scope string, policyAssignmentName string) (result PolicyAssignment, err error) { - req, err := client.DeletePreparer(scope, policyAssignmentName) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client PolicyAssignmentsClient) DeletePreparer(scope string, policyAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentName": url.QueryEscape(policyAssignmentName), - "scope": scope, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) DeleteResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// DeleteByID delete policy assignment. -// -// policyAssignmentID is policy assignment Id -func (client PolicyAssignmentsClient) DeleteByID(policyAssignmentID string) (result PolicyAssignment, err error) { - req, err := client.DeleteByIDPreparer(policyAssignmentID) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "DeleteByID", nil, "Failure preparing request") - } - - resp, err := client.DeleteByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "DeleteByID", resp, "Failure sending request") - } - - result, err = client.DeleteByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "DeleteByID", resp, "Failure responding to request") - } - - return -} - -// DeleteByIDPreparer prepares the DeleteByID request. -func (client PolicyAssignmentsClient) DeleteByIDPreparer(policyAssignmentID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentId": policyAssignmentID, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{policyAssignmentId}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// DeleteByIDSender sends the DeleteByID request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) DeleteByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DeleteByIDResponder handles the response to the DeleteByID request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) DeleteByIDResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Get get single policy assignment. -// -// scope is scope. policyAssignmentName is policy assignment name. -func (client PolicyAssignmentsClient) Get(scope string, policyAssignmentName string) (result PolicyAssignment, err error) { - req, err := client.GetPreparer(scope, policyAssignmentName) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Get", nil, "Failure preparing request") - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Get", resp, "Failure sending request") - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client PolicyAssignmentsClient) GetPreparer(scope string, policyAssignmentName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentName": url.QueryEscape(policyAssignmentName), - "scope": scope, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) GetResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByID get single policy assignment. -// -// policyAssignmentID is policy assignment Id -func (client PolicyAssignmentsClient) GetByID(policyAssignmentID string) (result PolicyAssignment, err error) { - req, err := client.GetByIDPreparer(policyAssignmentID) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "GetByID", nil, "Failure preparing request") - } - - resp, err := client.GetByIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "GetByID", resp, "Failure sending request") - } - - result, err = client.GetByIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "GetByID", resp, "Failure responding to request") - } - - return -} - -// GetByIDPreparer prepares the GetByID request. -func (client PolicyAssignmentsClient) GetByIDPreparer(policyAssignmentID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyAssignmentId": policyAssignmentID, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{policyAssignmentId}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// GetByIDSender sends the GetByID request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) GetByIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetByIDResponder handles the response to the GetByID request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) GetByIDResponder(resp *http.Response) (result PolicyAssignment, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List gets policy assignments of the subscription. -// -// filter is the filter to apply on the operation. -func (client PolicyAssignmentsClient) List(filter string) (result PolicyAssignmentListResult, err error) { - req, err := client.ListPreparer(filter) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client PolicyAssignmentsClient) ListPreparer(filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = filter - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyAssignments"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) ListResponder(resp *http.Response) (result PolicyAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client PolicyAssignmentsClient) ListNextResults(lastResults PolicyAssignmentListResult) (result PolicyAssignmentListResult, err error) { - req, err := lastResults.PolicyAssignmentListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", resp, "Failure sending next results request request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "List", resp, "Failure responding to next results request request") - } - - return -} - -// ListForResource gets policy assignments of the resource. -// -// resourceGroupName is the name of the resource group. -// resourceProviderNamespace is the name of the resource provider. -// parentResourcePath is the parent resource path. resourceType is the -// resource type. resourceName is the resource name. filter is the filter to -// apply on the operation. -func (client PolicyAssignmentsClient) ListForResource(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (result PolicyAssignmentListResult, err error) { - req, err := client.ListForResourcePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, filter) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", nil, "Failure preparing request") - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", resp, "Failure sending request") - } - - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", resp, "Failure responding to request") - } - - return -} - -// ListForResourcePreparer prepares the ListForResource request. -func (client PolicyAssignmentsClient) ListForResourcePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "parentResourcePath": url.QueryEscape(parentResourcePath), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), - "resourceType": url.QueryEscape(resourceType), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = filter - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}providers/Microsoft.Authorization/policyAssignments"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// ListForResourceSender sends the ListForResource request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) ListForResourceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListForResourceResponder handles the response to the ListForResource request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) ListForResourceResponder(resp *http.Response) (result PolicyAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListForResourceNextResults retrieves the next set of results, if any. -func (client PolicyAssignmentsClient) ListForResourceNextResults(lastResults PolicyAssignmentListResult) (result PolicyAssignmentListResult, err error) { - req, err := lastResults.PolicyAssignmentListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListForResourceSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", resp, "Failure sending next results request request") - } - - result, err = client.ListForResourceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResource", resp, "Failure responding to next results request request") - } - - return -} - -// ListForResourceGroup gets policy assignments of the resource group. -// -// resourceGroupName is resource group name. filter is the filter to apply on -// the operation. -func (client PolicyAssignmentsClient) ListForResourceGroup(resourceGroupName string, filter string) (result PolicyAssignmentListResult, err error) { - req, err := client.ListForResourceGroupPreparer(resourceGroupName, filter) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing request") - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", resp, "Failure sending request") - } - - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListForResourceGroupPreparer prepares the ListForResourceGroup request. -func (client PolicyAssignmentsClient) ListForResourceGroupPreparer(resourceGroupName string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = filter - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) ListForResourceGroupResponder(resp *http.Response) (result PolicyAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListForResourceGroupNextResults retrieves the next set of results, if any. -func (client PolicyAssignmentsClient) ListForResourceGroupNextResults(lastResults PolicyAssignmentListResult) (result PolicyAssignmentListResult, err error) { - req, err := lastResults.PolicyAssignmentListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListForResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", resp, "Failure sending next results request request") - } - - result, err = client.ListForResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForResourceGroup", resp, "Failure responding to next results request request") - } - - return -} - -// ListForScope gets policy assignments of the scope. -// -// scope is scope. filter is the filter to apply on the operation. -func (client PolicyAssignmentsClient) ListForScope(scope string, filter string) (result PolicyAssignmentListResult, err error) { - req, err := client.ListForScopePreparer(scope, filter) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", nil, "Failure preparing request") - } - - resp, err := client.ListForScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", resp, "Failure sending request") - } - - result, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", resp, "Failure responding to request") - } - - return -} - -// ListForScopePreparer prepares the ListForScope request. -func (client PolicyAssignmentsClient) ListForScopePreparer(scope string, filter string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "scope": scope, - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if len(filter) > 0 { - queryParameters["$filter"] = filter - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/{scope}/providers/Microsoft.Authorization/policyAssignments"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// ListForScopeSender sends the ListForScope request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyAssignmentsClient) ListForScopeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListForScopeResponder handles the response to the ListForScope request. The method always -// closes the http.Response Body. -func (client PolicyAssignmentsClient) ListForScopeResponder(resp *http.Response) (result PolicyAssignmentListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListForScopeNextResults retrieves the next set of results, if any. -func (client PolicyAssignmentsClient) ListForScopeNextResults(lastResults PolicyAssignmentListResult) (result PolicyAssignmentListResult, err error) { - req, err := lastResults.PolicyAssignmentListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListForScopeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", resp, "Failure sending next results request request") - } - - result, err = client.ListForScopeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyAssignmentsClient", "ListForScope", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policydefinitions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policydefinitions.go deleted file mode 100644 index 0251447ed..000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/policydefinitions.go +++ /dev/null @@ -1,231 +0,0 @@ -package resources - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "net/url" -) - -// PolicyDefinitionsClient is the client for the PolicyDefinitions methods of -// the Resources service. -type PolicyDefinitionsClient struct { - ManagementClient -} - -// NewPolicyDefinitionsClient creates an instance of the -// PolicyDefinitionsClient client. -func NewPolicyDefinitionsClient(subscriptionID string) PolicyDefinitionsClient { - return NewPolicyDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewPolicyDefinitionsClientWithBaseURI creates an instance of the -// PolicyDefinitionsClient client. -func NewPolicyDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) PolicyDefinitionsClient { - return PolicyDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate create or update policy definition. -// -// policyDefinitionName is the policy definition name. parameters is the -// policy definition properties -func (client PolicyDefinitionsClient) CreateOrUpdate(policyDefinitionName string, parameters PolicyDefinition) (result PolicyDefinition, err error) { - req, err := client.CreateOrUpdatePreparer(policyDefinitionName, parameters) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request") - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request") - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client PolicyDefinitionsClient) CreateOrUpdatePreparer(policyDefinitionName string, parameters PolicyDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyDefinitionName": url.QueryEscape(policyDefinitionName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"), - autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyDefinitionsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client PolicyDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result PolicyDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete deletes policy definition. -// -// policyDefinitionName is the policy definition name. -func (client PolicyDefinitionsClient) Delete(policyDefinitionName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(policyDefinitionName) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Delete", nil, "Failure preparing request") - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Delete", resp, "Failure sending request") - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client PolicyDefinitionsClient) DeletePreparer(policyDefinitionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyDefinitionName": url.QueryEscape(policyDefinitionName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyDefinitionsClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client PolicyDefinitionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets policy definition. -// -// policyDefinitionName is the policy definition name. -func (client PolicyDefinitionsClient) Get(policyDefinitionName string) (result PolicyDefinition, err error) { - req, err := client.GetPreparer(policyDefinitionName) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Get", nil, "Failure preparing request") - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Get", resp, "Failure sending request") - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.PolicyDefinitionsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client PolicyDefinitionsClient) GetPreparer(policyDefinitionName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "policyDefinitionName": url.QueryEscape(policyDefinitionName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client PolicyDefinitionsClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client PolicyDefinitionsClient) GetResponder(resp *http.Response) (result PolicyDefinition, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/provideroperationdetails.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/provideroperationdetails.go deleted file mode 100644 index 8b6f05a1f..000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/provideroperationdetails.go +++ /dev/null @@ -1,130 +0,0 @@ -package resources - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "net/url" -) - -// ProviderOperationDetailsClient is the client for the -// ProviderOperationDetails methods of the Resources service. -type ProviderOperationDetailsClient struct { - ManagementClient -} - -// NewProviderOperationDetailsClient creates an instance of the -// ProviderOperationDetailsClient client. -func NewProviderOperationDetailsClient(subscriptionID string) ProviderOperationDetailsClient { - return NewProviderOperationDetailsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewProviderOperationDetailsClientWithBaseURI creates an instance of the -// ProviderOperationDetailsClient client. -func NewProviderOperationDetailsClientWithBaseURI(baseURI string, subscriptionID string) ProviderOperationDetailsClient { - return ProviderOperationDetailsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List gets a list of resource providers. -// -// resourceProviderNamespace is resource identity. -func (client ProviderOperationDetailsClient) List(resourceProviderNamespace string, apiVersion string) (result ResourceProviderOperationDetailListResult, err error) { - req, err := client.ListPreparer(resourceProviderNamespace, apiVersion) - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", nil, "Failure preparing request") - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", resp, "Failure sending request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ProviderOperationDetailsClient) ListPreparer(resourceProviderNamespace string, apiVersion string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), - "subscriptionId": url.QueryEscape(client.SubscriptionID), - } - - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/{resourceProviderNamespace}/operations"), - autorest.WithPathParameters(pathParameters), - autorest.WithQueryParameters(queryParameters)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ProviderOperationDetailsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ProviderOperationDetailsClient) ListResponder(resp *http.Response) (result ResourceProviderOperationDetailListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListNextResults retrieves the next set of results, if any. -func (client ProviderOperationDetailsClient) ListNextResults(lastResults ResourceProviderOperationDetailListResult) (result ResourceProviderOperationDetailListResult, err error) { - req, err := lastResults.ResourceProviderOperationDetailListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", resp, "Failure sending next results request request") - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "resources.ProviderOperationDetailsClient", "List", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go index 0e870919a..404e96b67 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/providers.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // ProvidersClient is the client for the Providers methods of the Resources @@ -68,21 +67,20 @@ func (client ProvidersClient) Get(resourceProviderNamespace string) (result Prov // GetPreparer prepares the Get request. func (client ProvidersClient) GetPreparer(resourceProviderNamespace string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -130,23 +128,22 @@ func (client ProvidersClient) List(top *int32) (result ProviderListResult, err e // ListPreparer prepares the List request. func (client ProvidersClient) ListPreparer(top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -218,21 +215,20 @@ func (client ProvidersClient) Register(resourceProviderNamespace string) (result // RegisterPreparer prepares the Register request. func (client ProvidersClient) RegisterPreparer(resourceProviderNamespace string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/register", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // RegisterSender sends the Register request. The method will close the @@ -280,21 +276,20 @@ func (client ProvidersClient) Unregister(resourceProviderNamespace string) (resu // UnregisterPreparer prepares the Unregister request. func (client ProvidersClient) UnregisterPreparer(resourceProviderNamespace string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/unregister", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // UnregisterSender sends the Unregister request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resources.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resources.go index 3a1e2c019..d1f898d88 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resources.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/resources.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // Client is the client for the Resources methods of the Resources service. @@ -46,8 +45,8 @@ func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client Client) CheckExistence(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, err error) { - req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client Client) CheckExistence(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) { + req, err := client.CheckExistencePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", nil, "Failure preparing request") } @@ -67,27 +66,26 @@ func (client Client) CheckExistence(resourceGroupName string, resourceProviderNa } // CheckExistencePreparer prepares the CheckExistence request. -func (client Client) CheckExistencePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client Client) CheckExistencePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsHead(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckExistenceSender sends the CheckExistence request. The method will close the @@ -115,8 +113,8 @@ func (client Client) CheckExistenceResponder(resp *http.Response) (result autore // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. parameters is create or // update resource parameters. -func (client Client) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource) (result GenericResource, err error) { - req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters) +func (client Client) CreateOrUpdate(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (result GenericResource, err error) { + req, err := client.CreateOrUpdatePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, parameters) if err != nil { return result, autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", nil, "Failure preparing request") } @@ -136,28 +134,28 @@ func (client Client) CreateOrUpdate(resourceGroupName string, resourceProviderNa } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client Client) CreateOrUpdatePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string, parameters GenericResource) (*http.Request, error) { +func (client Client) CreateOrUpdatePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, parameters GenericResource) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -185,8 +183,8 @@ func (client Client) CreateOrUpdateResponder(resp *http.Response) (result Generi // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client Client) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client Client) Delete(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.Client", "Delete", nil, "Failure preparing request") } @@ -206,27 +204,26 @@ func (client Client) Delete(resourceGroupName string, resourceProviderNamespace } // DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client Client) DeletePreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteSender sends the Delete request. The method will close the @@ -253,8 +250,8 @@ func (client Client) DeleteResponder(resp *http.Response) (result autorest.Respo // insensitive. resourceProviderNamespace is resource identity. // parentResourcePath is resource identity. resourceType is resource // identity. resourceName is resource identity. -func (client Client) Get(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (result GenericResource, err error) { - req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion) +func (client Client) Get(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result GenericResource, err error) { + req, err := client.GetPreparer(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName) if err != nil { return result, autorest.NewErrorWithError(err, "resources.Client", "Get", nil, "Failure preparing request") } @@ -274,27 +271,26 @@ func (client Client) Get(resourceGroupName string, resourceProviderNamespace str } // GetPreparer prepares the Get request. -func (client Client) GetPreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, apiVersion string) (*http.Request, error) { +func (client Client) GetPreparer(resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) { pathParameters := map[string]interface{}{ "parentResourcePath": parentResourcePath, - "resourceGroupName": url.QueryEscape(resourceGroupName), - "resourceName": url.QueryEscape(resourceName), - "resourceProviderNamespace": url.QueryEscape(resourceProviderNamespace), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace), "resourceType": resourceType, - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -309,7 +305,7 @@ func (client Client) GetResponder(resp *http.Response) (result GenericResource, err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + azure.WithErrorUnlessStatusCode(http.StatusOK), autorest.ByUnmarshallingJSON(&result), autorest.ByClosing()) result.Response = autorest.Response{Response: resp} @@ -343,26 +339,25 @@ func (client Client) List(filter string, top *int32) (result ResourceListResult, // ListPreparer prepares the List request. func (client Client) ListPreparer(filter string, top *int32) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } if len(filter) > 0 { - queryParameters["$filter"] = filter + queryParameters["$filter"] = autorest.Encode("query", filter) } if top != nil { - queryParameters["$top"] = top + queryParameters["$top"] = autorest.Encode("query", *top) } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resources"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -408,8 +403,8 @@ func (client Client) ListNextResults(lastResults ResourceListResult) (result Res return } -// MoveResources begin moving resources.To determine whether the operation has -// finished processing the request, call GetLongRunningOperationStatus. This +// MoveResources move resources from one resource group to another. The +// resources being moved should all be in the same resource group. This // method may poll for completion. Polling can be canceled by passing the // cancel channel argument. The channel will be used to cancel polling and // any outstanding HTTP requests. @@ -439,22 +434,22 @@ func (client Client) MoveResources(sourceResourceGroupName string, parameters Mo // MoveResourcesPreparer prepares the MoveResources request. func (client Client) MoveResourcesPreparer(sourceResourceGroupName string, parameters MoveInfo, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "sourceResourceGroupName": url.QueryEscape(sourceResourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // MoveResourcesSender sends the MoveResources request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go index 7e5992805..ff4ad4485 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/tags.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // TagsClient is the client for the Tags methods of the Resources service. @@ -66,21 +65,20 @@ func (client TagsClient) CreateOrUpdate(tagName string) (result TagDetails, err // CreateOrUpdatePreparer prepares the CreateOrUpdate request. func (client TagsClient) CreateOrUpdatePreparer(tagName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "tagName": url.QueryEscape(tagName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagName": autorest.Encode("path", tagName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/tagNames/{tagName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the @@ -128,22 +126,21 @@ func (client TagsClient) CreateOrUpdateValue(tagName string, tagValue string) (r // CreateOrUpdateValuePreparer prepares the CreateOrUpdateValue request. func (client TagsClient) CreateOrUpdateValuePreparer(tagName string, tagValue string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "tagName": url.QueryEscape(tagName), - "tagValue": url.QueryEscape(tagValue), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagName": autorest.Encode("path", tagName), + "tagValue": autorest.Encode("path", tagValue), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CreateOrUpdateValueSender sends the CreateOrUpdateValue request. The method will close the @@ -191,21 +188,20 @@ func (client TagsClient) Delete(tagName string) (result autorest.Response, err e // DeletePreparer prepares the Delete request. func (client TagsClient) DeletePreparer(tagName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "tagName": url.QueryEscape(tagName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagName": autorest.Encode("path", tagName), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/tagNames/{tagName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteSender sends the Delete request. The method will close the @@ -252,22 +248,21 @@ func (client TagsClient) DeleteValue(tagName string, tagValue string) (result au // DeleteValuePreparer prepares the DeleteValue request. func (client TagsClient) DeleteValuePreparer(tagName string, tagValue string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), - "tagName": url.QueryEscape(tagName), - "tagValue": url.QueryEscape(tagValue), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "tagName": autorest.Encode("path", tagName), + "tagValue": autorest.Encode("path", tagValue), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteValueSender sends the DeleteValue request. The method will close the @@ -312,20 +307,19 @@ func (client TagsClient) List() (result TagsListResult, err error) { // ListPreparer prepares the List request. func (client TagsClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/tagNames"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/tagNames", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go index 9e7e9f1ea..b4f32148d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/resources/version.go @@ -14,7 +14,7 @@ package resources // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,9 +23,9 @@ import ( ) const ( - major = "2" + major = "3" minor = "1" - patch = "1" + patch = "0" // Always begin a "tag" with a dash (as per http://semver.org) tag = "-beta" semVerFormat = "%s.%s.%s%s" @@ -34,7 +34,7 @@ const ( // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "resources", "2015-11-01") + return fmt.Sprintf(userAgentFormat, Version(), "resources", "2016-02-01") } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go index 5952ed767..47e4737fd 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/client.go @@ -17,7 +17,7 @@ package subscriptions // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -25,7 +25,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) const ( @@ -39,21 +38,21 @@ const ( // ManagementClient is the base client for Subscriptions. type ManagementClient struct { autorest.Client - BaseURI string - SubscriptionID string + BaseURI string + APIVersion string } // New creates an instance of the ManagementClient client. -func New(subscriptionID string) ManagementClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) +func New() ManagementClient { + return NewWithBaseURI(DefaultBaseURI) } // NewWithBaseURI creates an instance of the ManagementClient client. -func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { +func NewWithBaseURI(baseURI string) ManagementClient { return ManagementClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + APIVersion: APIVersion, } } @@ -83,20 +82,19 @@ func (client ManagementClient) Get(subscriptionID string) (result Subscription, // GetPreparer prepares the Get request. func (client ManagementClient) GetPreparer(subscriptionID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(subscriptionID), + "subscriptionId": autorest.Encode("path", subscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -142,15 +140,15 @@ func (client ManagementClient) List() (result SubscriptionListResult, err error) // ListPreparer prepares the List request. func (client ManagementClient) ListPreparer() (*http.Request, error) { queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions"), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -222,20 +220,19 @@ func (client ManagementClient) ListLocations(subscriptionID string) (result Loca // ListLocationsPreparer prepares the ListLocations request. func (client ManagementClient) ListLocationsPreparer(subscriptionID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(subscriptionID), + "subscriptionId": autorest.Encode("path", subscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/locations"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/locations", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListLocationsSender sends the ListLocations request. The method will close the @@ -256,27 +253,3 @@ func (client ManagementClient) ListLocationsResponder(resp *http.Response) (resu result.Response = autorest.Response{Response: resp} return } - -// ListLocationsNextResults retrieves the next set of results, if any. -func (client ManagementClient) ListLocationsNextResults(lastResults LocationListResult) (result LocationListResult, err error) { - req, err := lastResults.LocationListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "subscriptions.ManagementClient", "ListLocations", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListLocationsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "subscriptions.ManagementClient", "ListLocations", resp, "Failure sending next results request request") - } - - result, err = client.ListLocationsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "subscriptions.ManagementClient", "ListLocations", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go index 31533da0f..9235a5732 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/models.go @@ -14,7 +14,7 @@ package subscriptions // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -38,28 +38,16 @@ type Location struct { type LocationListResult struct { autorest.Response `json:"-"` Value *[]Location `json:"value,omitempty"` - NextLink *string `json:",omitempty"` -} - -// LocationListResultPreparer prepares a request to retrieve the next set of results. It returns -// nil if no more results exist. -func (client LocationListResult) LocationListResultPreparer() (*http.Request, error) { - if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 { - return nil, nil - } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(client.NextLink))) } // Subscription is subscription information. type Subscription struct { - autorest.Response `json:"-"` - ID *string `json:"id,omitempty"` - SubscriptionID *string `json:"subscriptionId,omitempty"` - DisplayName *string `json:"displayName,omitempty"` - State *string `json:"state,omitempty"` + autorest.Response `json:"-"` + ID *string `json:"id,omitempty"` + SubscriptionID *string `json:"subscriptionId,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + State *string `json:"state,omitempty"` + SubscriptionPolicies *SubscriptionPolicies `json:"subscriptionPolicies,omitempty"` } // SubscriptionListResult is subscription list operation response. @@ -81,6 +69,12 @@ func (client SubscriptionListResult) SubscriptionListResultPreparer() (*http.Req autorest.WithBaseURL(to.String(client.NextLink))) } +// SubscriptionPolicies is subscription policies. +type SubscriptionPolicies struct { + LocationPlacementID *string `json:"locationPlacementId,omitempty"` + QuotaID *string `json:"quotaId,omitempty"` +} + // TenantIDDescription is tenant Id information type TenantIDDescription struct { ID *string `json:"id,omitempty"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptions.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptions.go index fe3c255fd..44a8c4980 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptions.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/subscriptions.go @@ -14,7 +14,7 @@ package subscriptions // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // Client is the client for the Subscriptions methods of the Subscriptions @@ -32,13 +31,13 @@ type Client struct { } // NewClient creates an instance of the Client client. -func NewClient(subscriptionID string) Client { - return NewClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewClient() Client { + return NewClientWithBaseURI(DefaultBaseURI) } // NewClientWithBaseURI creates an instance of the Client client. -func NewClientWithBaseURI(baseURI string, subscriptionID string) Client { - return Client{NewWithBaseURI(baseURI, subscriptionID)} +func NewClientWithBaseURI(baseURI string) Client { + return Client{NewWithBaseURI(baseURI)} } // Get gets details about particular subscription. @@ -67,20 +66,19 @@ func (client Client) Get(subscriptionID string) (result Subscription, err error) // GetPreparer prepares the Get request. func (client Client) GetPreparer(subscriptionID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(subscriptionID), + "subscriptionId": autorest.Encode("path", subscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetSender sends the Get request. The method will close the @@ -126,15 +124,15 @@ func (client Client) List() (result SubscriptionListResult, err error) { // ListPreparer prepares the List request. func (client Client) ListPreparer() (*http.Request, error) { queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/subscriptions"), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -206,20 +204,19 @@ func (client Client) ListLocations(subscriptionID string) (result LocationListRe // ListLocationsPreparer prepares the ListLocations request. func (client Client) ListLocationsPreparer(subscriptionID string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(subscriptionID), + "subscriptionId": autorest.Encode("path", subscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/locations"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/locations", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListLocationsSender sends the ListLocations request. The method will close the @@ -240,27 +237,3 @@ func (client Client) ListLocationsResponder(resp *http.Response) (result Locatio result.Response = autorest.Response{Response: resp} return } - -// ListLocationsNextResults retrieves the next set of results, if any. -func (client Client) ListLocationsNextResults(lastResults LocationListResult) (result LocationListResult, err error) { - req, err := lastResults.LocationListResultPreparer() - if err != nil { - return result, autorest.NewErrorWithError(err, "subscriptions.Client", "ListLocations", nil, "Failure preparing next results request request") - } - if req == nil { - return - } - - resp, err := client.ListLocationsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "subscriptions.Client", "ListLocations", resp, "Failure sending next results request request") - } - - result, err = client.ListLocationsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "subscriptions.Client", "ListLocations", resp, "Failure responding to next results request request") - } - - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go index 136133a11..3f417ab8f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/tenants.go @@ -14,7 +14,7 @@ package subscriptions // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -31,13 +31,13 @@ type TenantsClient struct { } // NewTenantsClient creates an instance of the TenantsClient client. -func NewTenantsClient(subscriptionID string) TenantsClient { - return NewTenantsClientWithBaseURI(DefaultBaseURI, subscriptionID) +func NewTenantsClient() TenantsClient { + return NewTenantsClientWithBaseURI(DefaultBaseURI) } // NewTenantsClientWithBaseURI creates an instance of the TenantsClient client. -func NewTenantsClientWithBaseURI(baseURI string, subscriptionID string) TenantsClient { - return TenantsClient{NewWithBaseURI(baseURI, subscriptionID)} +func NewTenantsClientWithBaseURI(baseURI string) TenantsClient { + return TenantsClient{NewWithBaseURI(baseURI)} } // List gets a list of the tenantIds. @@ -64,15 +64,15 @@ func (client TenantsClient) List() (result TenantListResult, err error) { // ListPreparer prepares the List request. func (client TenantsClient) ListPreparer() (*http.Request, error) { queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), autorest.WithPath("/tenants"), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go index 257916f8b..b5b07460f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions/version.go @@ -14,7 +14,7 @@ package subscriptions // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,9 +23,9 @@ import ( ) const ( - major = "2" + major = "3" minor = "1" - patch = "1" + patch = "0" // Always begin a "tag" with a dash (as per http://semver.org) tag = "-beta" semVerFormat = "%s.%s.%s%s" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go index 4aef6a56b..39e50fe0f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // AccountsClient is the the Storage Management Client. @@ -69,21 +68,21 @@ func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameA // CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. func (client AccountsClient) CheckNameAvailabilityPreparer(accountName AccountCheckNameAvailabilityParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability", pathParameters), autorest.WithJSON(accountName), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the @@ -106,13 +105,13 @@ func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) } // Create asynchronously creates a new storage account with the specified -// parameters. Existing accounts cannot be updated with this API and should -// instead use the Update Storage Account API. If an account is already -// created and subsequent PUT request is issued with exact same set of -// properties, then HTTP 200 would be returned. This method may poll for -// completion. Polling can be canceled by passing the cancel channel -// argument. The channel will be used to cancel polling and any outstanding -// HTTP requests. +// parameters. If an account is already created and subsequent create request +// is issued with different properties, the account properties will be +// updated. If an account is already created and subsequent create or update +// request is issued with exact same set of properties, the request will +// succeed. This method may poll for completion. Polling can be canceled by +// passing the cancel channel argument. The channel will be used to cancel +// polling and any outstanding HTTP requests. // // resourceGroupName is the name of the resource group within the user's // subscription. accountName is the name of the storage account within the @@ -142,23 +141,23 @@ func (client AccountsClient) Create(resourceGroupName string, accountName string // CreatePreparer prepares the Create request. func (client AccountsClient) CreatePreparer(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{Cancel: cancel}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPut(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{Cancel: cancel}) } // CreateSender sends the Create request. The method will close the @@ -175,7 +174,7 @@ func (client AccountsClient) CreateResponder(resp *http.Response) (result autore err = autorest.Respond( resp, client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), autorest.ByClosing()) result.Response = resp return @@ -210,22 +209,21 @@ func (client AccountsClient) Delete(resourceGroupName string, accountName string // DeletePreparer prepares the Delete request. func (client AccountsClient) DeletePreparer(resourceGroupName string, accountName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsDelete(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // DeleteSender sends the Delete request. The method will close the @@ -277,22 +275,21 @@ func (client AccountsClient) GetProperties(resourceGroupName string, accountName // GetPropertiesPreparer prepares the GetProperties request. func (client AccountsClient) GetPropertiesPreparer(resourceGroupName string, accountName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // GetPropertiesSender sends the GetProperties request. The method will close the @@ -339,20 +336,19 @@ func (client AccountsClient) List() (result AccountListResult, err error) { // ListPreparer prepares the List request. func (client AccountsClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the @@ -403,21 +399,20 @@ func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (resu // ListByResourceGroupPreparer prepares the ListByResourceGroup request. func (client AccountsClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the @@ -443,7 +438,7 @@ func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) ( // // resourceGroupName is the name of the resource group. accountName is the // name of the storage account. -func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountKeys, err error) { +func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountListKeysResult, err error) { req, err := client.ListKeysPreparer(resourceGroupName, accountName) if err != nil { return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") @@ -466,22 +461,21 @@ func (client AccountsClient) ListKeys(resourceGroupName string, accountName stri // ListKeysPreparer prepares the ListKeys request. func (client AccountsClient) ListKeysPreparer(resourceGroupName string, accountName string) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListKeysSender sends the ListKeys request. The method will close the @@ -492,7 +486,7 @@ func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, // ListKeysResponder handles the response to the ListKeys request. The method always // closes the http.Response Body. -func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) { +func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountListKeysResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -511,7 +505,7 @@ func (client AccountsClient) ListKeysResponder(resp *http.Response) (result Acco // characters in length and use numbers and lower-case letters only. // regenerateKey is specifies name of the key which should be regenerated. // key1 or key2 for the default keys -func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountKeys, err error) { +func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, err error) { req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, regenerateKey) if err != nil { return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") @@ -534,23 +528,23 @@ func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName // RegenerateKeyPreparer prepares the RegenerateKey request. func (client AccountsClient) RegenerateKeyPreparer(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", pathParameters), autorest.WithJSON(regenerateKey), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // RegenerateKeySender sends the RegenerateKey request. The method will close the @@ -561,7 +555,7 @@ func (client AccountsClient) RegenerateKeySender(req *http.Request) (*http.Respo // RegenerateKeyResponder handles the response to the RegenerateKey request. The method always // closes the http.Response Body. -func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountKeys, err error) { +func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result AccountListKeysResult, err error) { err = autorest.Respond( resp, client.ByInspecting(), @@ -572,25 +566,22 @@ func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result return } -// Update updates the account type or tags for a storage account. It can also -// be used to add a custom domain (note that custom domains cannot be added -// via the Create operation). Only one custom domain is supported per storage -// account. In order to replace a custom domain, the old value must be -// cleared before a new value may be set. To clear a custom domain, simply -// update the custom domain with empty string. Then call update again with -// the new cutsom domain name. The update API can only be used to update one -// of tags, accountType, or customDomain per call. To update multiple of -// these properties, call the API multiple times with one change per call. -// This call does not change the storage keys for the account. If you want to -// change storage account keys, use the RegenerateKey operation. The location -// and name of the storage account cannot be changed after creation. +// Update the update operation can be used to update the account type, +// encryption, or tags for a storage account. It can also be used to map the +// account to a custom domain. Only one custom domain is supported per +// storage account and. replacement/change of custom domain is not supported. +// In order to replace an old custom domain, the old value must be +// cleared/unregistered before a new value may be set. Update of multiple +// properties is supported. This call does not change the storage keys for +// the account. If you want to change storage account keys, use the +// regenerate keys operation. The location and name of the storage account +// cannot be changed after creation. // // resourceGroupName is the name of the resource group within the user's // subscription. accountName is the name of the storage account within the // specified resource group. Storage account names must be between 3 and 24 // characters in length and use numbers and lower-case letters only. -// parameters is the parameters to update on the account. Note that only one -// property can be changed at a time using this API. +// parameters is the parameters to provide for the updated account. func (client AccountsClient) Update(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters) if err != nil { @@ -614,23 +605,23 @@ func (client AccountsClient) Update(resourceGroupName string, accountName string // UpdatePreparer prepares the Update request. func (client AccountsClient) UpdatePreparer(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) { pathParameters := map[string]interface{}{ - "accountName": url.QueryEscape(accountName), - "resourceGroupName": url.QueryEscape(resourceGroupName), - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "accountName": autorest.Encode("path", accountName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, + preparer := autorest.CreatePreparer( autorest.AsJSON(), autorest.AsPatch(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", pathParameters), autorest.WithJSON(parameters), - autorest.WithPathParameters(pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // UpdateSender sends the Update request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go index f1de4c266..68708dbf2 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go @@ -1,5 +1,5 @@ // Package storage implements the Azure ARM Storage service API version -// 2015-06-15. +// 2016-01-01. // // The Storage Management Client. package storage @@ -18,7 +18,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -28,7 +28,7 @@ import ( const ( // APIVersion is the version of the Storage - APIVersion = "2015-06-15" + APIVersion = "2016-01-01" // DefaultBaseURI is the default URI used for the service Storage DefaultBaseURI = "https://management.azure.com" @@ -38,6 +38,7 @@ const ( type ManagementClient struct { autorest.Client BaseURI string + APIVersion string SubscriptionID string } @@ -51,6 +52,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { return ManagementClient{ Client: autorest.NewClientWithUserAgent(UserAgent()), BaseURI: baseURI, + APIVersion: APIVersion, SubscriptionID: subscriptionID, } } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go index 2b15a0547..a4a4d2be4 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,6 +23,16 @@ import ( "github.com/Azure/go-autorest/autorest/date" ) +// AccessTier enumerates the values for access tier. +type AccessTier string + +const ( + // Cool specifies the cool state for access tier. + Cool AccessTier = "Cool" + // Hot specifies the hot state for access tier. + Hot AccessTier = "Hot" +) + // AccountStatus enumerates the values for account status. type AccountStatus string @@ -33,20 +43,24 @@ const ( Unavailable AccountStatus = "Unavailable" ) -// AccountType enumerates the values for account type. -type AccountType string +// KeyPermission enumerates the values for key permission. +type KeyPermission string const ( - // PremiumLRS specifies the premium lrs state for account type. - PremiumLRS AccountType = "Premium_LRS" - // StandardGRS specifies the standard grs state for account type. - StandardGRS AccountType = "Standard_GRS" - // StandardLRS specifies the standard lrs state for account type. - StandardLRS AccountType = "Standard_LRS" - // StandardRAGRS specifies the standard ragrs state for account type. - StandardRAGRS AccountType = "Standard_RAGRS" - // StandardZRS specifies the standard zrs state for account type. - StandardZRS AccountType = "Standard_ZRS" + // FULL specifies the full state for key permission. + FULL KeyPermission = "FULL" + // READ specifies the read state for key permission. + READ KeyPermission = "READ" +) + +// Kind enumerates the values for kind. +type Kind string + +const ( + // BlobStorage specifies the blob storage state for kind. + BlobStorage Kind = "BlobStorage" + // Storage specifies the storage state for kind. + Storage Kind = "Storage" ) // ProvisioningState enumerates the values for provisioning state. @@ -71,6 +85,32 @@ const ( AlreadyExists Reason = "AlreadyExists" ) +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // PremiumLRS specifies the premium lrs state for sku name. + PremiumLRS SkuName = "Premium_LRS" + // StandardGRS specifies the standard grs state for sku name. + StandardGRS SkuName = "Standard_GRS" + // StandardLRS specifies the standard lrs state for sku name. + StandardLRS SkuName = "Standard_LRS" + // StandardRAGRS specifies the standard ragrs state for sku name. + StandardRAGRS SkuName = "Standard_RAGRS" + // StandardZRS specifies the standard zrs state for sku name. + StandardZRS SkuName = "Standard_ZRS" +) + +// SkuTier enumerates the values for sku tier. +type SkuTier string + +const ( + // Premium specifies the premium state for sku tier. + Premium SkuTier = "Premium" + // Standard specifies the standard state for sku tier. + Standard SkuTier = "Standard" +) + // UsageUnit enumerates the values for usage unit. type UsageUnit string @@ -97,6 +137,8 @@ type Account struct { Type *string `json:"type,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Kind Kind `json:"kind,omitempty"` Properties *AccountProperties `json:"properties,omitempty"` } @@ -108,16 +150,24 @@ type AccountCheckNameAvailabilityParameters struct { // AccountCreateParameters is the parameters to provide for the account. type AccountCreateParameters struct { + Sku *Sku `json:"sku,omitempty"` + Kind Kind `json:"kind,omitempty"` Location *string `json:"location,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` Properties *AccountPropertiesCreateParameters `json:"properties,omitempty"` } -// AccountKeys is the access keys for the storage account. -type AccountKeys struct { +// AccountKey is an access key for the storage account. +type AccountKey struct { + KeyName *string `json:"keyName,omitempty"` + Value *string `json:"value,omitempty"` + Permissions KeyPermission `json:"permissions,omitempty"` +} + +// AccountListKeysResult is the ListKeys operation response. +type AccountListKeysResult struct { autorest.Response `json:"-"` - Key1 *string `json:"key1,omitempty"` - Key2 *string `json:"key2,omitempty"` + Keys *[]AccountKey `json:"keys,omitempty"` } // AccountListResult is the list storage accounts operation response. @@ -129,7 +179,6 @@ type AccountListResult struct { // AccountProperties is type AccountProperties struct { ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - AccountType AccountType `json:"accountType,omitempty"` PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"` PrimaryLocation *string `json:"primaryLocation,omitempty"` StatusOfPrimary AccountStatus `json:"statusOfPrimary,omitempty"` @@ -139,17 +188,22 @@ type AccountProperties struct { CreationTime *date.Time `json:"creationTime,omitempty"` CustomDomain *CustomDomain `json:"customDomain,omitempty"` SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` } // AccountPropertiesCreateParameters is type AccountPropertiesCreateParameters struct { - AccountType AccountType `json:"accountType,omitempty"` + CustomDomain *CustomDomain `json:"customDomain,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` } // AccountPropertiesUpdateParameters is type AccountPropertiesUpdateParameters struct { - AccountType AccountType `json:"accountType,omitempty"` CustomDomain *CustomDomain `json:"customDomain,omitempty"` + Encryption *Encryption `json:"encryption,omitempty"` + AccessTier AccessTier `json:"accessTier,omitempty"` } // AccountRegenerateKeyParameters is @@ -157,8 +211,9 @@ type AccountRegenerateKeyParameters struct { KeyName *string `json:"keyName,omitempty"` } -// AccountUpdateParameters is the parameters to update on the account. +// AccountUpdateParameters is the parameters to provide for the account. type AccountUpdateParameters struct { + Sku *Sku `json:"sku,omitempty"` Tags *map[string]*string `json:"tags,omitempty"` Properties *AccountPropertiesUpdateParameters `json:"properties,omitempty"` } @@ -178,6 +233,23 @@ type CustomDomain struct { UseSubDomain *bool `json:"useSubDomain,omitempty"` } +// Encryption is the encryption settings on the account. +type Encryption struct { + Services *EncryptionServices `json:"services,omitempty"` + KeySource *string `json:"keySource,omitempty"` +} + +// EncryptionService is an encrypted service. +type EncryptionService struct { + Enabled *bool `json:"enabled,omitempty"` + LastEnabledTime *date.Time `json:"lastEnabledTime,omitempty"` +} + +// EncryptionServices is the encrypted services. +type EncryptionServices struct { + Blob *EncryptionService `json:"blob,omitempty"` +} + // Endpoints is the URIs that are used to perform a retrieval of a public // blob, queue or table object. type Endpoints struct { @@ -196,6 +268,12 @@ type Resource struct { Tags *map[string]*string `json:"tags,omitempty"` } +// Sku is the SKU of the storage account. +type Sku struct { + Name SkuName `json:"name,omitempty"` + Tier SkuTier `json:"tier,omitempty"` +} + // Usage is describes Storage Resource Usage. type Usage struct { Unit UsageUnit `json:"unit,omitempty"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go index 7b5bbe0b0..866efc9c3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/usageoperations.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -22,7 +22,6 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "net/http" - "net/url" ) // UsageOperationsClient is the the Storage Management Client. @@ -67,20 +66,19 @@ func (client UsageOperationsClient) List() (result UsageListResult, err error) { // ListPreparer prepares the List request. func (client UsageOperationsClient) ListPreparer() (*http.Request, error) { pathParameters := map[string]interface{}{ - "subscriptionId": url.QueryEscape(client.SubscriptionID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), } queryParameters := map[string]interface{}{ - "api-version": APIVersion, + "api-version": client.APIVersion, } - return autorest.Prepare(&http.Request{}, - autorest.AsJSON(), + preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"), - autorest.WithPathParameters(pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages", pathParameters), autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare(&http.Request{}) } // ListSender sends the List request. The method will close the diff --git a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go index 3432c57ee..f31159d01 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go @@ -14,7 +14,7 @@ package storage // See the License for the specific language governing permissions and // limitations under the License. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. @@ -23,9 +23,9 @@ import ( ) const ( - major = "2" + major = "3" minor = "1" - patch = "1" + patch = "0" // Always begin a "tag" with a dash (as per http://semver.org) tag = "-beta" semVerFormat = "%s.%s.%s%s" @@ -34,7 +34,7 @@ const ( // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return fmt.Sprintf(userAgentFormat, Version(), "storage", "2015-06-15") + return fmt.Sprintf(userAgentFormat, Version(), "storage", "2016-01-01") } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go index 47e8091c3..8b2b6f69f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go @@ -55,7 +55,51 @@ type ContainerListResponse struct { type Blob struct { Name string `xml:"Name"` Properties BlobProperties `xml:"Properties"` - // TODO (ahmetalpbalkan) Metadata + Metadata BlobMetadata `xml:"Metadata"` +} + +// BlobMetadata is a set of custom name/value pairs. +// +// See https://msdn.microsoft.com/en-us/library/azure/dd179404.aspx +type BlobMetadata map[string]string + +type blobMetadataEntries struct { + Entries []blobMetadataEntry `xml:",any"` +} +type blobMetadataEntry struct { + XMLName xml.Name + Value string `xml:",chardata"` +} + +// UnmarshalXML converts the xml:Metadata into Metadata map +func (bm *BlobMetadata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var entries blobMetadataEntries + if err := d.DecodeElement(&entries, &start); err != nil { + return err + } + for _, entry := range entries.Entries { + if *bm == nil { + *bm = make(BlobMetadata) + } + (*bm)[strings.ToLower(entry.XMLName.Local)] = entry.Value + } + return nil +} + +// MarshalXML implements the xml.Marshaler interface. It encodes +// metadata name/value pairs as they would appear in an Azure +// ListBlobs response. +func (bm BlobMetadata) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { + entries := make([]blobMetadataEntry, 0, len(bm)) + for k, v := range bm { + entries = append(entries, blobMetadataEntry{ + XMLName: xml.Name{Local: http.CanonicalHeaderKey(k)}, + Value: v, + }) + } + return enc.EncodeElement(blobMetadataEntries{ + Entries: entries, + }, start) } // BlobProperties contains various properties of a blob @@ -75,6 +119,7 @@ type BlobProperties struct { CopyProgress string `xml:"CopyProgress"` CopyCompletionTime string `xml:"CopyCompletionTime"` CopyStatusDescription string `xml:"CopyStatusDescription"` + LeaseStatus string `xml:"LeaseStatus"` } // BlobListResponse contains the response fields from ListBlobs call. @@ -457,7 +502,7 @@ func (b BlobStorageClient) GetBlobURL(container, name string) string { // // See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, "") + resp, err := b.getBlobRange(container, name, "", nil) if err != nil { return nil, err } @@ -472,8 +517,8 @@ func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error // string must be in a format like "0-", "10-100" as defined in HTTP 1.1 spec. // // See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx -func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, bytesRange) +func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (io.ReadCloser, error) { + resp, err := b.getBlobRange(container, name, bytesRange, extraHeaders) if err != nil { return nil, err } @@ -484,7 +529,7 @@ func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io. return resp.body, nil } -func (b BlobStorageClient) getBlobRange(container, name, bytesRange string) (*storageResponse, error) { +func (b BlobStorageClient) getBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (*storageResponse, error) { verb := "GET" uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) @@ -492,6 +537,11 @@ func (b BlobStorageClient) getBlobRange(container, name, bytesRange string) (*st if bytesRange != "" { headers["Range"] = fmt.Sprintf("bytes=%s", bytesRange) } + + for k, v := range extraHeaders { + headers[k] = v + } + resp, err := b.client.exec(verb, uri, headers, nil) if err != nil { return nil, err @@ -548,6 +598,7 @@ func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobPrope CopySource: resp.headers.Get("x-ms-copy-source"), CopyStatus: resp.headers.Get("x-ms-copy-status"), BlobType: BlobType(resp.headers.Get("x-ms-blob-type")), + LeaseStatus: resp.headers.Get("x-ms-lease-status"), }, nil } @@ -559,7 +610,7 @@ func (b BlobStorageClient) GetBlobProperties(container, name string) (*BlobPrope // applications either. // // See https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx -func (b BlobStorageClient) SetBlobMetadata(container, name string, metadata map[string]string) error { +func (b BlobStorageClient) SetBlobMetadata(container, name string, metadata map[string]string, extraHeaders map[string]string) error { params := url.Values{"comp": {"metadata"}} uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), params) headers := b.client.getStandardHeaders() @@ -567,6 +618,10 @@ func (b BlobStorageClient) SetBlobMetadata(container, name string, metadata map[ headers[userDefinedMetadataHeaderPrefix+k] = v } + for k, v := range extraHeaders { + headers[k] = v + } + resp, err := b.client.exec("PUT", uri, headers, nil) if err != nil { return err diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go index 4a0dc5b34..4cc7e1124 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go @@ -4,6 +4,7 @@ package storage import ( "bytes" "encoding/base64" + "encoding/json" "encoding/xml" "errors" "fmt" @@ -54,6 +55,11 @@ type storageResponse struct { body io.ReadCloser } +type odataResponse struct { + storageResponse + odata odataErrorMessage +} + // AzureStorageServiceError contains fields of the error response from // Azure Storage Service REST API. See https://msdn.microsoft.com/en-us/library/azure/dd179382.aspx // Some fields might be specific to certain calls. @@ -68,6 +74,20 @@ type AzureStorageServiceError struct { RequestID string } +type odataErrorMessageMessage struct { + Lang string `json:"lang"` + Value string `json:"value"` +} + +type odataErrorMessageInternal struct { + Code string `json:"code"` + Message odataErrorMessageMessage `json:"message"` +} + +type odataErrorMessage struct { + Err odataErrorMessageInternal `json:"odata.error"` +} + // UnexpectedStatusCodeError is returned when a storage service responds with neither an error // nor with an HTTP status code indicating success. type UnexpectedStatusCodeError struct { @@ -112,7 +132,7 @@ func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, u key, err := base64.StdEncoding.DecodeString(accountKey) if err != nil { - return c, err + return c, fmt.Errorf("azure: malformed storage account key: %v", err) } return Client{ @@ -166,6 +186,12 @@ func (c Client) GetQueueService() QueueServiceClient { return QueueServiceClient{c} } +// GetTableService returns a TableServiceClient which can operate on the table +// service of the storage account. +func (c Client) GetTableService() TableServiceClient { + return TableServiceClient{c} +} + // GetFileService returns a FileServiceClient which can operate on the file // service of the storage account. func (c Client) GetFileService() FileServiceClient { @@ -228,6 +254,22 @@ func (c Client) buildCanonicalizedHeader(headers map[string]string) string { return ch } +func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) { + errMsg := "buildCanonicalizedResourceTable error: %s" + u, err := url.Parse(uri) + if err != nil { + return "", fmt.Errorf(errMsg, err.Error()) + } + + cr := "/" + c.accountName + + if len(u.Path) > 0 { + cr += u.Path + } + + return cr, nil +} + func (c Client) buildCanonicalizedResource(uri string) (string, error) { errMsg := "buildCanonicalizedResource error: %s" u, err := url.Parse(uri) @@ -236,6 +278,7 @@ func (c Client) buildCanonicalizedResource(uri string) (string, error) { } cr := "/" + c.accountName + if len(u.Path) > 0 { cr += u.Path } @@ -266,6 +309,7 @@ func (c Client) buildCanonicalizedResource(uri string) (string, error) { } } } + return cr, nil } @@ -364,6 +408,70 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader body: resp.Body}, nil } +func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) { + req, err := http.NewRequest(verb, url, body) + for k, v := range headers { + req.Header.Add(k, v) + } + + httpClient := c.HTTPClient + if httpClient == nil { + httpClient = http.DefaultClient + } + + resp, err := httpClient.Do(req) + if err != nil { + return nil, err + } + + respToRet := &odataResponse{} + respToRet.body = resp.Body + respToRet.statusCode = resp.StatusCode + respToRet.headers = resp.Header + + statusCode := resp.StatusCode + if statusCode >= 400 && statusCode <= 505 { + var respBody []byte + respBody, err = readResponseBody(resp) + if err != nil { + return nil, err + } + + if len(respBody) == 0 { + // no error in response body + err = fmt.Errorf("storage: service returned without a response body (%d)", resp.StatusCode) + return respToRet, err + } + // try unmarshal as odata.error json + err = json.Unmarshal(respBody, &respToRet.odata) + return respToRet, err + } + + return respToRet, nil +} + +func (c Client) createSharedKeyLite(url string, headers map[string]string) (string, error) { + can, err := c.buildCanonicalizedResourceTable(url) + + if err != nil { + return "", err + } + strToSign := headers["x-ms-date"] + "\n" + can + + hmac := c.computeHmac256(strToSign) + return fmt.Sprintf("SharedKeyLite %s:%s", c.accountName, hmac), nil +} + +func (c Client) execTable(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) { + var err error + headers["Authorization"], err = c.createSharedKeyLite(url, headers) + if err != nil { + return nil, err + } + + return c.execInternalJSON(verb, url, headers, body) +} + func readResponseBody(resp *http.Response) ([]byte, error) { defer resp.Body.Close() out, err := ioutil.ReadAll(resp.Body) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go new file mode 100644 index 000000000..39e997503 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go @@ -0,0 +1,129 @@ +package storage + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// TableServiceClient contains operations for Microsoft Azure Table Storage +// Service. +type TableServiceClient struct { + client Client +} + +// AzureTable is the typedef of the Azure Table name +type AzureTable string + +const ( + tablesURIPath = "/Tables" +) + +type createTableRequest struct { + TableName string `json:"TableName"` +} + +func pathForTable(table AzureTable) string { return fmt.Sprintf("%s", table) } + +func (c *TableServiceClient) getStandardHeaders() map[string]string { + return map[string]string{ + "x-ms-version": "2015-02-21", + "x-ms-date": currentTimeRfc1123Formatted(), + "Accept": "application/json;odata=nometadata", + "Accept-Charset": "UTF-8", + "Content-Type": "application/json", + } +} + +// QueryTables returns the tables created in the +// *TableServiceClient storage account. +func (c *TableServiceClient) QueryTables() ([]AzureTable, error) { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + + headers := c.getStandardHeaders() + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("GET", uri, headers, nil) + if err != nil { + return nil, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, err + } + + buf := new(bytes.Buffer) + buf.ReadFrom(resp.body) + + var respArray queryTablesResponse + if err := json.Unmarshal(buf.Bytes(), &respArray); err != nil { + return nil, err + } + + s := make([]AzureTable, len(respArray.TableName)) + for i, elem := range respArray.TableName { + s[i] = AzureTable(elem.TableName) + } + + return s, nil +} + +// CreateTable creates the table given the specific +// name. This function fails if the name is not compliant +// with the specification or the tables already exists. +func (c *TableServiceClient) CreateTable(table AzureTable) error { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + + headers := c.getStandardHeaders() + + req := createTableRequest{TableName: string(table)} + buf := new(bytes.Buffer) + + if err := json.NewEncoder(buf).Encode(req); err != nil { + return err + } + + headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) + + resp, err := c.client.execTable("POST", uri, headers, buf) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { + return err + } + + return nil +} + +// DeleteTable deletes the table given the specific +// name. This function fails if the table is not present. +// Be advised: DeleteTable deletes all the entries +// that may be present. +func (c *TableServiceClient) DeleteTable(table AzureTable) error { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + uri += fmt.Sprintf("('%s')", string(table)) + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("DELETE", uri, headers, nil) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + + } + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go new file mode 100644 index 000000000..c81393e5f --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go @@ -0,0 +1,351 @@ +package storage + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "reflect" +) + +const ( + partitionKeyNode = "PartitionKey" + rowKeyNode = "RowKey" + tag = "table" + tagIgnore = "-" + continuationTokenPartitionKeyHeader = "X-Ms-Continuation-Nextpartitionkey" + continuationTokenRowHeader = "X-Ms-Continuation-Nextrowkey" + maxTopParameter = 1000 +) + +type queryTablesResponse struct { + TableName []struct { + TableName string `json:"TableName"` + } `json:"value"` +} + +const ( + tableOperationTypeInsert = iota + tableOperationTypeUpdate = iota + tableOperationTypeMerge = iota + tableOperationTypeInsertOrReplace = iota + tableOperationTypeInsertOrMerge = iota +) + +type tableOperation int + +// TableEntity interface specifies +// the functions needed to support +// marshaling and unmarshaling into +// Azure Tables. The struct must only contain +// simple types because Azure Tables do not +// support hierarchy. +type TableEntity interface { + PartitionKey() string + RowKey() string + SetPartitionKey(string) error + SetRowKey(string) error +} + +// ContinuationToken is an opaque (ie not useful to inspect) +// struct that Get... methods can return if there are more +// entries to be returned than the ones already +// returned. Just pass it to the same function to continue +// receiving the remaining entries. +type ContinuationToken struct { + NextPartitionKey string + NextRowKey string +} + +type getTableEntriesResponse struct { + Elements []map[string]interface{} `json:"value"` +} + +// QueryTableEntities queries the specified table and returns the unmarshaled +// entities of type retType. +// top parameter limits the returned entries up to top. Maximum top +// allowed by Azure API is 1000. In case there are more than top entries to be +// returned the function will return a non nil *ContinuationToken. You can call the +// same function again passing the received ContinuationToken as previousContToken +// parameter in order to get the following entries. The query parameter +// is the odata query. To retrieve all the entries pass the empty string. +// The function returns a pointer to a TableEntity slice, the *ContinuationToken +// if there are more entries to be returned and an error in case something went +// wrong. +// +// Example: +// entities, cToken, err = tSvc.QueryTableEntities("table", cToken, reflect.TypeOf(entity), 20, "") +func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousContToken *ContinuationToken, retType reflect.Type, top int, query string) ([]TableEntity, *ContinuationToken, error) { + if top > maxTopParameter { + return nil, nil, fmt.Errorf("top accepts at maximum %d elements. Requested %d instead", maxTopParameter, top) + } + + uri := c.client.getEndpoint(tableServiceName, pathForTable(tableName), url.Values{}) + uri += fmt.Sprintf("?$top=%d", top) + if query != "" { + uri += fmt.Sprintf("&$filter=%s", url.QueryEscape(query)) + } + + if previousContToken != nil { + uri += fmt.Sprintf("&NextPartitionKey=%s&NextRowKey=%s", previousContToken.NextPartitionKey, previousContToken.NextRowKey) + } + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("GET", uri, headers, nil) + + contToken := extractContinuationTokenFromHeaders(resp.headers) + + if err != nil { + return nil, contToken, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, contToken, err + } + + retEntries, err := deserializeEntity(retType, resp.body) + if err != nil { + return nil, contToken, err + } + + return retEntries, contToken, nil +} + +// InsertEntity inserts an entity in the specified table. +// The function fails if there is an entity with the same +// PartitionKey and RowKey in the table. +func (c *TableServiceClient) InsertEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, false, "POST"); err != nil { + return checkRespCode(sc, []int{http.StatusCreated}) + } + + return err +} + +func (c *TableServiceClient) execTable(table AzureTable, entity TableEntity, specifyKeysInURL bool, method string) (int, error) { + uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) + if specifyKeysInURL { + uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) + } + + headers := c.getStandardHeaders() + + var buf bytes.Buffer + + if err := injectPartitionAndRowKeys(entity, &buf); err != nil { + return 0, err + } + + headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) + + var err error + var resp *odataResponse + + resp, err = c.client.execTable(method, uri, headers, &buf) + + if err != nil { + return 0, err + } + + defer resp.body.Close() + + return resp.statusCode, nil +} + +// UpdateEntity updates the contents of an entity with the +// one passed as parameter. The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) UpdateEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "PUT"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// MergeEntity merges the contents of an entity with the +// one passed as parameter. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) MergeEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// DeleteEntityWithoutCheck deletes the entity matching by +// PartitionKey and RowKey. There is no check on IfMatch +// parameter so the entity is always deleted. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) DeleteEntityWithoutCheck(table AzureTable, entity TableEntity) error { + return c.DeleteEntity(table, entity, "*") +} + +// DeleteEntity deletes the entity matching by +// PartitionKey, RowKey and ifMatch field. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table or +// the ifMatch is different. +func (c *TableServiceClient) DeleteEntity(table AzureTable, entity TableEntity, ifMatch string) error { + uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) + uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + headers["If-Match"] = ifMatch + + resp, err := c.client.execTable("DELETE", uri, headers, nil) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + + return nil +} + +// InsertOrReplaceEntity inserts an entity in the specified table +// or replaced the existing one. +func (c *TableServiceClient) InsertOrReplaceEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "PUT"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// InsertOrMergeEntity inserts an entity in the specified table +// or merges the existing one. +func (c *TableServiceClient) InsertOrMergeEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +func injectPartitionAndRowKeys(entity TableEntity, buf *bytes.Buffer) error { + if err := json.NewEncoder(buf).Encode(entity); err != nil { + return err + } + + dec := make(map[string]interface{}) + if err := json.NewDecoder(buf).Decode(&dec); err != nil { + return err + } + + // Inject PartitionKey and RowKey + dec[partitionKeyNode] = entity.PartitionKey() + dec[rowKeyNode] = entity.RowKey() + + // Remove tagged fields + // The tag is defined in the const section + // This is useful to avoid storing the PartitionKey and RowKey twice. + numFields := reflect.ValueOf(entity).Elem().NumField() + for i := 0; i < numFields; i++ { + f := reflect.ValueOf(entity).Elem().Type().Field(i) + + if f.Tag.Get(tag) == tagIgnore { + // we must look for its JSON name in the dictionary + // as the user can rename it using a tag + jsonName := f.Name + if f.Tag.Get("json") != "" { + jsonName = f.Tag.Get("json") + } + delete(dec, jsonName) + } + } + + buf.Reset() + + if err := json.NewEncoder(buf).Encode(&dec); err != nil { + return err + } + + return nil +} + +func deserializeEntity(retType reflect.Type, reader io.Reader) ([]TableEntity, error) { + buf := new(bytes.Buffer) + + var ret getTableEntriesResponse + if err := json.NewDecoder(reader).Decode(&ret); err != nil { + return nil, err + } + + tEntries := make([]TableEntity, len(ret.Elements)) + + for i, entry := range ret.Elements { + + buf.Reset() + if err := json.NewEncoder(buf).Encode(entry); err != nil { + return nil, err + } + + dec := make(map[string]interface{}) + if err := json.NewDecoder(buf).Decode(&dec); err != nil { + return nil, err + } + + var pKey, rKey string + // strip pk and rk + for key, val := range dec { + switch key { + case partitionKeyNode: + pKey = val.(string) + case rowKeyNode: + rKey = val.(string) + } + } + + delete(dec, partitionKeyNode) + delete(dec, rowKeyNode) + + buf.Reset() + if err := json.NewEncoder(buf).Encode(dec); err != nil { + return nil, err + } + + // Create a empty retType instance + tEntries[i] = reflect.New(retType.Elem()).Interface().(TableEntity) + // Popolate it with the values + if err := json.NewDecoder(buf).Decode(&tEntries[i]); err != nil { + return nil, err + } + + // Reset PartitionKey and RowKey + tEntries[i].SetPartitionKey(pKey) + tEntries[i].SetRowKey(rKey) + } + + return tEntries, nil +} + +func extractContinuationTokenFromHeaders(h http.Header) *ContinuationToken { + ct := ContinuationToken{h.Get(continuationTokenPartitionKeyHeader), h.Get(continuationTokenRowHeader)} + + if ct.NextPartitionKey != "" && ct.NextRowKey != "" { + return &ct + } + return nil +} diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/async.go b/vendor/github.com/Azure/go-autorest/autorest/azure/async.go index 93fa25b99..280d32a61 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/async.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/async.go @@ -62,8 +62,9 @@ func DoPollForAsynchronous(delay time.Duration) autorest.SendDecorator { return resp, err } + delay = autorest.GetRetryAfter(resp, delay) resp, err = autorest.SendWithSender(s, r, - autorest.AfterDelay(autorest.GetRetryAfter(resp, delay))) + autorest.AfterDelay(delay)) } return resp, err diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/azure.go b/vendor/github.com/Azure/go-autorest/autorest/azure/azure.go index 75b3aac78..3f4d13421 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/azure.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/azure.go @@ -6,6 +6,7 @@ See the included examples for more detail. package azure import ( + "encoding/json" "fmt" "io/ioutil" "net/http" @@ -29,12 +30,20 @@ const ( // ServiceError encapsulates the error response from an Azure service. type ServiceError struct { - Code string `json:"code"` - Message string `json:"message"` + Code string `json:"code"` + Message string `json:"message"` + Details *[]interface{} `json:"details"` } func (se ServiceError) Error() string { - return fmt.Sprintf("Azure Error: Code=%q Message=%q", se.Code, se.Message) + if se.Details != nil { + d, err := json.Marshal(*(se.Details)) + if err != nil { + return fmt.Sprintf("Code=%q Message=%q Details=%v", se.Code, se.Message, *se.Details) + } + return fmt.Sprintf("Code=%q Message=%q Details=%v", se.Code, se.Message, string(d)) + } + return fmt.Sprintf("Code=%q Message=%q", se.Code, se.Message) } // RequestError describes an error response returned by Azure service. @@ -50,8 +59,8 @@ type RequestError struct { // Error returns a human-friendly error message from service error. func (e RequestError) Error() string { - return fmt.Sprintf("azure: Service returned an error. Code=%q Message=%q Status=%d", - e.ServiceError.Code, e.ServiceError.Message, e.StatusCode) + return fmt.Sprintf("autorest/azure: Service returned an error. Status=%v %v", + e.StatusCode, e.ServiceError) } // IsAzureError returns true if the passed error is an Azure Service error; false otherwise. @@ -149,14 +158,20 @@ func WithErrorUnlessStatusCode(codes ...int) autorest.RespondDecorator { var e RequestError defer resp.Body.Close() + // Copy and replace the Body in case it does not contain an error object. + // This will leave the Body available to the caller. b, decodeErr := autorest.CopyAndDecode(autorest.EncodedAsJSON, resp.Body, &e) - resp.Body = ioutil.NopCloser(&b) // replace body with in-memory reader - if decodeErr != nil || e.ServiceError == nil { - return fmt.Errorf("autorest/azure: error response cannot be parsed: %q error: %v", b.String(), err) + resp.Body = ioutil.NopCloser(&b) + if decodeErr != nil { + return fmt.Errorf("autorest/azure: error response cannot be parsed: %q error: %v", b.String(), decodeErr) + } else if e.ServiceError == nil { + e.ServiceError = &ServiceError{Code: "Unknown", Message: "Unknown service error"} } e.RequestID = ExtractRequestID(resp) - e.StatusCode = resp.StatusCode + if e.StatusCode == nil { + e.StatusCode = resp.StatusCode + } err = &e } return err diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go index 25e77a319..ebf754eab 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/environments.go @@ -3,28 +3,36 @@ package azure import ( "fmt" "net/url" + "strings" ) const ( activeDirectoryAPIVersion = "1.0" ) +var environments = map[string]Environment{ + "AZURECHINACLOUD": ChinaCloud, + "AZUREGERMANCLOUD": GermanCloud, + "AZUREPUBLICCLOUD": PublicCloud, + "AZUREUSGOVERNMENTCLOUD": USGovernmentCloud, +} + // Environment represents a set of endpoints for each of Azure's Clouds. type Environment struct { - Name string - ManagementPortalURL string - PublishSettingsURL string - ServiceManagementEndpoint string - ResourceManagerEndpoint string - ActiveDirectoryEndpoint string - GalleryEndpoint string - KeyVaultEndpoint string - GraphEndpoint string - StorageEndpointSuffix string - SQLDatabaseDNSSuffix string - TrafficManagerDNSSuffix string - KeyVaultDNSSuffix string - ServiceBusEndpointSuffix string + Name string `json:"name"` + ManagementPortalURL string `json:"managementPortalURL"` + PublishSettingsURL string `json:"publishSettingsURL"` + ServiceManagementEndpoint string `json:"serviceManagementEndpoint"` + ResourceManagerEndpoint string `json:"resourceManagerEndpoint"` + ActiveDirectoryEndpoint string `json:"activeDirectoryEndpoint"` + GalleryEndpoint string `json:"galleryEndpoint"` + KeyVaultEndpoint string `json:"keyVaultEndpoint"` + GraphEndpoint string `json:"graphEndpoint"` + StorageEndpointSuffix string `json:"storageEndpointSuffix"` + SQLDatabaseDNSSuffix string `json:"sqlDatabaseDNSSuffix"` + TrafficManagerDNSSuffix string `json:"trafficManagerDNSSuffix"` + KeyVaultDNSSuffix string `json:"keyVaultDNSSuffix"` + ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix"` } var ( @@ -52,15 +60,15 @@ var ( ManagementPortalURL: "https://manage.windowsazure.us/", PublishSettingsURL: "https://manage.windowsazure.us/publishsettings/index", ServiceManagementEndpoint: "https://management.core.usgovcloudapi.net/", - ResourceManagerEndpoint: "https://management.usgovcloudapi.net", + ResourceManagerEndpoint: "https://management.usgovcloudapi.net/", ActiveDirectoryEndpoint: "https://login.microsoftonline.com/", GalleryEndpoint: "https://gallery.usgovcloudapi.net/", - KeyVaultEndpoint: "https://vault.azure.net/", + KeyVaultEndpoint: "https://vault.usgovcloudapi.net/", GraphEndpoint: "https://graph.usgovcloudapi.net/", StorageEndpointSuffix: "core.usgovcloudapi.net", SQLDatabaseDNSSuffix: "database.usgovcloudapi.net", - TrafficManagerDNSSuffix: "trafficmanager.net", - KeyVaultDNSSuffix: "vault.azure.net", + TrafficManagerDNSSuffix: "usgovtrafficmanager.net", + KeyVaultDNSSuffix: "vault.usgovcloudapi.net", ServiceBusEndpointSuffix: "servicebus.usgovcloudapi.net", } @@ -73,16 +81,44 @@ var ( ResourceManagerEndpoint: "https://management.chinacloudapi.cn/", ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/?api-version=1.0", GalleryEndpoint: "https://gallery.chinacloudapi.cn/", - KeyVaultEndpoint: "https://vault.azure.net/", + KeyVaultEndpoint: "https://vault.azure.cn/", GraphEndpoint: "https://graph.chinacloudapi.cn/", StorageEndpointSuffix: "core.chinacloudapi.cn", SQLDatabaseDNSSuffix: "database.chinacloudapi.cn", TrafficManagerDNSSuffix: "trafficmanager.cn", - KeyVaultDNSSuffix: "vault.azure.net", + KeyVaultDNSSuffix: "vault.azure.cn", ServiceBusEndpointSuffix: "servicebus.chinacloudapi.net", } + + // GermanCloud is the cloud environment operated in Germany + GermanCloud = Environment{ + Name: "AzureGermanCloud", + ManagementPortalURL: "http://portal.microsoftazure.de/", + PublishSettingsURL: "https://manage.microsoftazure.de/publishsettings/index", + ServiceManagementEndpoint: "https://management.core.cloudapi.de/", + ResourceManagerEndpoint: "https://management.microsoftazure.de/", + ActiveDirectoryEndpoint: "https://login.microsoftonline.de/", + GalleryEndpoint: "https://gallery.cloudapi.de/", + KeyVaultEndpoint: "https://vault.microsoftazure.de/", + GraphEndpoint: "https://graph.cloudapi.de/", + StorageEndpointSuffix: "core.cloudapi.de", + SQLDatabaseDNSSuffix: "database.cloudapi.de", + TrafficManagerDNSSuffix: "azuretrafficmanager.de", + KeyVaultDNSSuffix: "vault.microsoftazure.de", + ServiceBusEndpointSuffix: "servicebus.cloudapi.de", + } ) +// EnvironmentFromName returns an Environment based on the common name specified +func EnvironmentFromName(name string) (Environment, error) { + name = strings.ToUpper(name) + env, ok := environments[name] + if !ok { + return env, fmt.Errorf("autorest/azure: There is no cloud environment matching the name %q", name) + } + return env, nil +} + // OAuthConfigForTenant returns an OAuthConfig with tenant specific urls func (env Environment) OAuthConfigForTenant(tenantID string) (*OAuthConfig, error) { template := "%s/oauth2/%s?api-version=%s" diff --git a/vendor/github.com/Azure/go-autorest/autorest/azure/token.go b/vendor/github.com/Azure/go-autorest/autorest/azure/token.go index 239fb36a6..db9a8fa02 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/azure/token.go +++ b/vendor/github.com/Azure/go-autorest/autorest/azure/token.go @@ -137,7 +137,7 @@ func (secret *ServicePrincipalCertificateSecret) SignJwt(spt *ServicePrincipalTo token := jwt.New(jwt.SigningMethodRS256) token.Header["x5t"] = thumbprint - token.Claims = map[string]interface{}{ + token.Claims = jwt.MapClaims{ "aud": spt.oauthConfig.TokenEndpoint, "iss": spt.clientID, "sub": spt.clientID, @@ -147,7 +147,7 @@ func (secret *ServicePrincipalCertificateSecret) SignJwt(spt *ServicePrincipalTo } signedString, err := token.SignedString(secret.PrivateKey) - return signedString, nil + return signedString, err } // SetAuthenticationValues is a method of the interface ServicePrincipalSecret. diff --git a/vendor/github.com/Azure/go-autorest/autorest/client.go b/vendor/github.com/Azure/go-autorest/autorest/client.go index ce156f74f..95e9a203d 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/client.go +++ b/vendor/github.com/Azure/go-autorest/autorest/client.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "log" "net/http" + "net/http/cookiejar" "time" ) @@ -16,8 +17,22 @@ const ( // DefaultPollingDuration is a reasonable total polling duration. DefaultPollingDuration = 15 * time.Minute + + // DefaultRetryAttempts is number of attempts for retry status codes (5xx). + DefaultRetryAttempts = 3 + + // DefaultRetryDuration is a resonable delay for retry. + defaultRetryInterval = 30 * time.Second ) +var statusCodesForRetry = []int{ + http.StatusRequestTimeout, // 408 + http.StatusInternalServerError, // 500 + http.StatusBadGateway, // 502 + http.StatusServiceUnavailable, // 503 + http.StatusGatewayTimeout, // 504 +} + const ( requestFormat = `HTTP Request Begin =================================================== %s @@ -75,9 +90,7 @@ func (li LoggingInspector) ByInspecting() RespondDecorator { return func(r Responder) Responder { return ResponderFunc(func(resp *http.Response) error { var body, b bytes.Buffer - defer resp.Body.Close() - resp.Body = ioutil.NopCloser(io.TeeReader(resp.Body, &body)) if err := resp.Write(&b); err != nil { return fmt.Errorf("Failed to write response: %v", err) @@ -114,17 +127,25 @@ type Client struct { // PollingDuration sets the maximum polling time after which an error is returned. PollingDuration time.Duration + // RetryAttempts sets the default number of retry attempts for client. + RetryAttempts int + // UserAgent, if not empty, will be set as the HTTP User-Agent header on all requests sent // through the Do method. UserAgent string + + Jar http.CookieJar } // NewClientWithUserAgent returns an instance of a Client with the UserAgent set to the passed // string. func NewClientWithUserAgent(ua string) Client { - c := Client{PollingDelay: DefaultPollingDelay, PollingDuration: DefaultPollingDuration} - c.UserAgent = ua - return c + return Client{ + PollingDelay: DefaultPollingDelay, + PollingDuration: DefaultPollingDuration, + RetryAttempts: DefaultRetryAttempts, + UserAgent: ua, + } } // Do implements the Sender interface by invoking the active Sender after applying authorization. @@ -141,18 +162,18 @@ func (c Client) Do(r *http.Request) (*http.Response, error) { if err != nil { return nil, NewErrorWithError(err, "autorest/Client", "Do", nil, "Preparing request failed") } - - resp, err := c.sender().Do(r) + resp, err := SendWithSender(c.sender(), r, + DoRetryForStatusCodes(c.RetryAttempts, defaultRetryInterval, statusCodesForRetry...)) Respond(resp, c.ByInspecting()) - return resp, err } // sender returns the Sender to which to send requests. func (c Client) sender() Sender { if c.Sender == nil { - return http.DefaultClient + j, _ := cookiejar.New(nil) + return &http.Client{Jar: j} } return c.Sender } diff --git a/vendor/github.com/Azure/go-autorest/autorest/error.go b/vendor/github.com/Azure/go-autorest/autorest/error.go index da49b12cb..2e4fc79c1 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/error.go +++ b/vendor/github.com/Azure/go-autorest/autorest/error.go @@ -24,7 +24,7 @@ type DetailedError struct { Method string // StatusCode is the HTTP Response StatusCode (if non-zero) that led to the error. - StatusCode int + StatusCode interface{} // Message is the error message. Message string diff --git a/vendor/github.com/Azure/go-autorest/autorest/preparer.go b/vendor/github.com/Azure/go-autorest/autorest/preparer.go index c0735f07f..0f18c2ace 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/preparer.go +++ b/vendor/github.com/Azure/go-autorest/autorest/preparer.go @@ -166,7 +166,9 @@ func WithBaseURL(baseURL string) PrepareDecorator { r, err := p.Prepare(r) if err == nil { var u *url.URL - u, err = url.Parse(baseURL) + if u, err = url.Parse(baseURL); err != nil { + return r, err + } if u.Scheme == "" { err = fmt.Errorf("autorest: No scheme detected in URL %s", baseURL) } @@ -268,12 +270,8 @@ func WithPath(path string) PrepareDecorator { if r.URL == nil { return r, NewError("autorest", "WithPath", "Invoked with a nil URL") } - u := r.URL - u.Path = strings.TrimRight(u.Path, "/") - if strings.HasPrefix(path, "/") { - u.Path = path - } else { - u.Path += "/" + path + if r.URL, err = parseURL(r.URL, path); err != nil { + return r, err } } return r, err @@ -284,7 +282,7 @@ func WithPath(path string) PrepareDecorator { // WithEscapedPathParameters returns a PrepareDecorator that replaces brace-enclosed keys within the // request path (i.e., http.Request.URL.Path) with the corresponding values from the passed map. The // values will be escaped (aka URL encoded) before insertion into the path. -func WithEscapedPathParameters(pathParameters map[string]interface{}) PrepareDecorator { +func WithEscapedPathParameters(path string, pathParameters map[string]interface{}) PrepareDecorator { parameters := escapeValueStrings(ensureValueStrings(pathParameters)) return func(p Preparer) Preparer { return PreparerFunc(func(r *http.Request) (*http.Request, error) { @@ -294,7 +292,10 @@ func WithEscapedPathParameters(pathParameters map[string]interface{}) PrepareDec return r, NewError("autorest", "WithEscapedPathParameters", "Invoked with a nil URL") } for key, value := range parameters { - r.URL.Path = strings.Replace(r.URL.Path, "{"+key+"}", value, -1) + path = strings.Replace(path, "{"+key+"}", value, -1) + } + if r.URL, err = parseURL(r.URL, path); err != nil { + return r, err } } return r, err @@ -304,7 +305,7 @@ func WithEscapedPathParameters(pathParameters map[string]interface{}) PrepareDec // WithPathParameters returns a PrepareDecorator that replaces brace-enclosed keys within the // request path (i.e., http.Request.URL.Path) with the corresponding values from the passed map. -func WithPathParameters(pathParameters map[string]interface{}) PrepareDecorator { +func WithPathParameters(path string, pathParameters map[string]interface{}) PrepareDecorator { parameters := ensureValueStrings(pathParameters) return func(p Preparer) Preparer { return PreparerFunc(func(r *http.Request) (*http.Request, error) { @@ -314,7 +315,11 @@ func WithPathParameters(pathParameters map[string]interface{}) PrepareDecorator return r, NewError("autorest", "WithPathParameters", "Invoked with a nil URL") } for key, value := range parameters { - r.URL.Path = strings.Replace(r.URL.Path, "{"+key+"}", value, -1) + path = strings.Replace(path, "{"+key+"}", value, -1) + } + + if r.URL, err = parseURL(r.URL, path); err != nil { + return r, err } } return r, err @@ -322,6 +327,14 @@ func WithPathParameters(pathParameters map[string]interface{}) PrepareDecorator } } +func parseURL(u *url.URL, path string) (*url.URL, error) { + p := strings.TrimRight(u.String(), "/") + if !strings.HasPrefix(path, "/") { + path = "/" + path + } + return url.Parse(p + path) +} + // WithQueryParameters returns a PrepareDecorators that encodes and applies the query parameters // given in the supplied map (i.e., key=value). func WithQueryParameters(queryParameters map[string]interface{}) PrepareDecorator { @@ -337,7 +350,7 @@ func WithQueryParameters(queryParameters map[string]interface{}) PrepareDecorato for key, value := range parameters { v.Add(key, value) } - r.URL.RawQuery = v.Encode() + r.URL.RawQuery = createQuery(v) } return r, err }) diff --git a/vendor/github.com/Azure/go-autorest/autorest/sender.go b/vendor/github.com/Azure/go-autorest/autorest/sender.go index b646a4832..93e6489e9 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/sender.go +++ b/vendor/github.com/Azure/go-autorest/autorest/sender.go @@ -1,7 +1,9 @@ package autorest import ( + "bytes" "fmt" + "io/ioutil" "log" "math" "net/http" @@ -184,6 +186,36 @@ func DoRetryForAttempts(attempts int, backoff time.Duration) SendDecorator { } } +// DoRetryForStatusCodes returns a SendDecorator that retries for specified statusCodes for up to the specified +// number of attempts, exponentially backing off between requests using the supplied backoff +// time.Duration (which may be zero). Retrying may be canceled by closing the optional channel on +// the http.Request. +func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) SendDecorator { + return func(s Sender) Sender { + return SenderFunc(func(r *http.Request) (resp *http.Response, err error) { + b := []byte{} + if r.Body != nil { + b, err = ioutil.ReadAll(r.Body) + if err != nil { + return resp, err + } + } + + // Increment to add the first call (attempts denotes number of retries) + attempts++ + for attempt := 0; attempt < attempts; attempt++ { + r.Body = ioutil.NopCloser(bytes.NewBuffer(b)) + resp, err = s.Do(r) + if err != nil || !ResponseHasStatusCode(resp, codes...) { + return resp, err + } + DelayForBackoff(backoff, attempt, r.Cancel) + } + return resp, err + }) + } +} + // DoRetryForDuration returns a SendDecorator that retries the request until the total time is equal // to or greater than the specified duration, exponentially backing off between requests using the // supplied backoff time.Duration (which may be zero). Retrying may be canceled by closing the @@ -222,11 +254,12 @@ func WithLogging(logger *log.Logger) SendDecorator { } // DelayForBackoff invokes time.After for the supplied backoff duration raised to the power of -// passed attempt (i.e., an exponential backoff delay). Backoff may be zero. The delay may be -// canceled by closing the passed channel. If terminated early, returns false. +// passed attempt (i.e., an exponential backoff delay). Backoff duration is in seconds and can set +// to zero for no delay. The delay may be canceled by closing the passed channel. If terminated early, +// returns false. func DelayForBackoff(backoff time.Duration, attempt int, cancel <-chan struct{}) bool { select { - case <-time.After(time.Duration(math.Pow(float64(backoff), float64(attempt)))): + case <-time.After(time.Duration(backoff.Seconds()*math.Pow(2, float64(attempt))) * time.Second): return true case <-cancel: return false diff --git a/vendor/github.com/Azure/go-autorest/autorest/utility.go b/vendor/github.com/Azure/go-autorest/autorest/utility.go index 96ac77973..b7f4a723b 100644 --- a/vendor/github.com/Azure/go-autorest/autorest/utility.go +++ b/vendor/github.com/Azure/go-autorest/autorest/utility.go @@ -7,6 +7,8 @@ import ( "fmt" "io" "net/url" + "sort" + "strings" ) // EncodedAs is a series of constants specifying various data encodings @@ -97,7 +99,63 @@ func ensureValueString(value interface{}) string { switch v := value.(type) { case string: return v + case []byte: + return string(v) default: return fmt.Sprintf("%v", v) } } + +// String method converts interface v to string. If interface is a list, it +// joins list elements using separator. +func String(v interface{}, sep ...string) string { + if len(sep) > 0 { + return ensureValueString(strings.Join(v.([]string), sep[0])) + } + return ensureValueString(v) +} + +// Encode method encodes url path and query parameters. +func Encode(location string, v interface{}, sep ...string) string { + s := String(v, sep...) + switch strings.ToLower(location) { + case "path": + return pathEscape(s) + case "query": + return queryEscape(s) + default: + return s + } +} + +func pathEscape(s string) string { + return strings.Replace(url.QueryEscape(s), "+", "%20", -1) +} + +func queryEscape(s string) string { + return url.QueryEscape(s) +} + +// This method is same as Encode() method of "net/url" go package, +// except it does not encode the query parameters because they +// already come encoded. It formats values map in query format (bar=foo&a=b). +func createQuery(v url.Values) string { + var buf bytes.Buffer + keys := make([]string, 0, len(v)) + for k := range v { + keys = append(keys, k) + } + sort.Strings(keys) + for _, k := range keys { + vs := v[k] + prefix := url.QueryEscape(k) + "=" + for _, v := range vs { + if buf.Len() > 0 { + buf.WriteByte('&') + } + buf.WriteString(prefix) + buf.WriteString(v) + } + } + return buf.String() +} diff --git a/vendor/github.com/dgrijalva/jwt-go/.travis.yml b/vendor/github.com/dgrijalva/jwt-go/.travis.yml index d6089146c..bde823d8a 100644 --- a/vendor/github.com/dgrijalva/jwt-go/.travis.yml +++ b/vendor/github.com/dgrijalva/jwt-go/.travis.yml @@ -1,7 +1,8 @@ language: go go: - - 1.3.3 - - 1.4.2 + - 1.3 + - 1.4 - 1.5 + - 1.6 - tip diff --git a/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md b/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md new file mode 100644 index 000000000..fd62e9490 --- /dev/null +++ b/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md @@ -0,0 +1,96 @@ +## Migration Guide from v2 -> v3 + +Version 3 adds several new, frequently requested features. To do so, it introduces a few breaking changes. We've worked to keep these as minimal as possible. This guide explains the breaking changes and how you can quickly update your code. + +### `Token.Claims` is now an interface type + +The most requested feature from the 2.0 verison of this library was the ability to provide a custom type to the JSON parser for claims. This was implemented by introducing a new interface, `Claims`, to replace `map[string]interface{}`. We also included two concrete implementations of `Claims`: `MapClaims` and `StandardClaims`. + +`MapClaims` is an alias for `map[string]interface{}` with built in validation behavior. It is the default claims type when using `Parse`. The usage is unchanged except you must type cast the claims property. + +The old example for parsing a token looked like this.. + +```go + if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil { + fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"]) + } +``` + +is now directly mapped to... + +```go + if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil { + claims := token.Claims.(jwt.MapClaims) + fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"]) + } +``` + +`StandardClaims` is designed to be embedded in your custom type. You can supply a custom claims type with the new `ParseWithClaims` function. Here's an example of using a custom claims type. + +```go + type MyCustomClaims struct { + User string + *StandardClaims + } + + if token, err := jwt.ParseWithClaims(tokenString, &MyCustomClaims{}, keyLookupFunc); err == nil { + claims := token.Claims.(*MyCustomClaims) + fmt.Printf("Token for user %v expires %v", claims.User, claims.StandardClaims.ExpiresAt) + } +``` + +### `ParseFromRequest` has been moved + +To keep this library focused on the tokens without becoming overburdened with complex request processing logic, `ParseFromRequest` and its new companion `ParseFromRequestWithClaims` have been moved to a subpackage, `request`. The method signatues have also been augmented to receive a new argument: `Extractor`. + +`Extractors` do the work of picking the token string out of a request. The interface is simple and composable. + +This simple parsing example: + +```go + if token, err := jwt.ParseFromRequest(tokenString, req, keyLookupFunc); err == nil { + fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"]) + } +``` + +is directly mapped to: + +```go + if token, err := request.ParseFromRequest(tokenString, request.OAuth2Extractor, req, keyLookupFunc); err == nil { + fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"]) + } +``` + +There are several concrete `Extractor` types provided for your convenience: + +* `HeaderExtractor` will search a list of headers until one contains content. +* `ArgumentExtractor` will search a list of keys in request query and form arguments until one contains content. +* `MultiExtractor` will try a list of `Extractors` in order until one returns content. +* `AuthorizationHeaderExtractor` will look in the `Authorization` header for a `Bearer` token. +* `OAuth2Extractor` searches the places an OAuth2 token would be specified (per the spec): `Authorization` header and `access_token` argument +* `PostExtractionFilter` wraps an `Extractor`, allowing you to process the content before it's parsed. A simple example is stripping the `Bearer ` text from a header + + +### RSA signing methods no longer accept `[]byte` keys + +Due to a [critical vulnerability](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/), we've decided the convenience of accepting `[]byte` instead of `rsa.PublicKey` or `rsa.PrivateKey` isn't worth the risk of misuse. + +To replace this behavior, we've added two helper methods: `ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)` and `ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)`. These are just simple helpers for unpacking PEM encoded PKCS1 and PKCS8 keys. If your keys are encoded any other way, all you need to do is convert them to the `crypto/rsa` package's types. + +```go + func keyLookupFunc(*Token) (interface{}, error) { + // Don't forget to validate the alg is what you expect: + if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { + return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) + } + + // Look up key + key, err := lookupPublicKey(token.Header["kid"]) + if err != nil { + return nil, err + } + + // Unpack key from PEM encoded PKCS8 + return jwt.ParseRSAPublicKeyFromPEM(key) + } +``` diff --git a/vendor/github.com/dgrijalva/jwt-go/README.md b/vendor/github.com/dgrijalva/jwt-go/README.md index bf0100f4d..00f613672 100644 --- a/vendor/github.com/dgrijalva/jwt-go/README.md +++ b/vendor/github.com/dgrijalva/jwt-go/README.md @@ -1,11 +1,16 @@ -A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-jones-json-web-token.html) +A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) [![Build Status](https://travis-ci.org/dgrijalva/jwt-go.svg?branch=master)](https://travis-ci.org/dgrijalva/jwt-go) +**BREAKING CHANGES:*** Version 3.0.0 is here. It includes _a lot_ of changes including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code. + **NOTICE:** A vulnerability in JWT was [recently published](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). As this library doesn't force users to validate the `alg` is what they expected, it's possible your usage is effected. There will be an update soon to remedy this, and it will likey require backwards-incompatible changes to the API. In the short term, please make sure your implementation verifies the `alg` is what you expect. + ## What the heck is a JWT? +JWT.io has [a great introduction](https://jwt.io/introduction) to JSON Web Tokens. + In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](http://tools.ietf.org/html/rfc4648) encoded. The last part is the signature, encoded the same way. The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used. @@ -16,37 +21,13 @@ The part in the middle is the interesting bit. It's called the Claims and conta This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own. -## Parse and Verify +## Examples -Parsing and verifying tokens is pretty straight forward. You pass in the token and a function for looking up the key. This is done as a callback since you may need to parse the token to find out what signing method and key was used. +See [the project documentation](https://godoc.org/github.com/dgrijalva/jwt-go) for examples of usage: -```go - token, err := jwt.Parse(myToken, func(token *jwt.Token) (interface{}, error) { - // Don't forget to validate the alg is what you expect: - if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { - return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) - } - return myLookupKey(token.Header["kid"]), nil - }) - - if err == nil && token.Valid { - deliverGoodness("!") - } else { - deliverUtterRejection(":(") - } -``` - -## Create a token - -```go - // Create the token - token := jwt.New(jwt.SigningMethodHS256) - // Set some claims - token.Claims["foo"] = "bar" - token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() - // Sign and get the complete encoded token as a string - tokenString, err := token.SignedString(mySigningKey) -``` +* [Simple example of parsing and validating a token](https://godoc.org/github.com/dgrijalva/jwt-go#example_Parse_hmac) +* [Simple example of building and signing a token](https://godoc.org/github.com/dgrijalva/jwt-go#example_New_hmac) +* [Directory of Examples](https://godoc.org/github.com/dgrijalva/jwt-go#pkg-examples) ## Extensions @@ -54,6 +35,12 @@ This library publishes all the necessary components for adding your own signing Here's an example of an extension that integrates with the Google App Engine signing tools: https://github.com/someone1/gcp-jwt-go +## Compliance + +This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences: + +* In order to protect against accidental use of [Unsecured JWTs](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#UnsecuredJWT), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key. + ## Project Status & Versioning This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason). @@ -95,4 +82,4 @@ Without going too far down the rabbit hole, here's a description of the interact Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go). -The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. For a more http centric example, see [this gist](https://gist.github.com/cryptix/45c33ecf0ae54828e63b). +The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in to documentation. diff --git a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md index 9eb7ff9ca..b605b4509 100644 --- a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md +++ b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md @@ -1,5 +1,43 @@ ## `jwt-go` Version History +#### 3.0.0 + +* **Compatibility Breaking Changes**: See MIGRATION_GUIDE.md for tips on updating your code + * Dropped support for `[]byte` keys when using RSA signing methods. This convenience feature could contribute to security vulnerabilities involving mismatched key types with signing methods. + * `ParseFromRequest` has been moved to `request` subpackage and usage has changed + * The `Claims` property on `Token` is now type `Claims` instead of `map[string]interface{}`. The default value is type `MapClaims`, which is an alias to `map[string]interface{}`. This makes it possible to use a custom type when decoding claims. +* Other Additions and Changes + * Added `Claims` interface type to allow users to decode the claims into a custom type + * Added `ParseWithClaims`, which takes a third argument of type `Claims`. Use this function instead of `Parse` if you have a custom type you'd like to decode into. + * Dramatically improved the functionality and flexibility of `ParseFromRequest`, which is now in the `request` subpackage + * Added `ParseFromRequestWithClaims` which is the `FromRequest` equivalent of `ParseWithClaims` + * Added new interface type `Extractor`, which is used for extracting JWT strings from http requests. Used with `ParseFromRequest` and `ParseFromRequestWithClaims`. + * Added several new, more specific, validation errors to error type bitmask + * Moved examples from README to executable example files + * Signing method registry is now thread safe + * Added new property to `ValidationError`, which contains the raw error returned by calls made by parse/verify (such as those returned by keyfunc or json parser) + +#### 2.7.0 + +This will likely be the last backwards compatible release before 3.0.0, excluding essential bug fixes. + +* Added new option `-show` to the `jwt` command that will just output the decoded token without verifying +* Error text for expired tokens includes how long it's been expired +* Fixed incorrect error returned from `ParseRSAPublicKeyFromPEM` +* Documentation updates + +#### 2.6.0 + +* Exposed inner error within ValidationError +* Fixed validation errors when using UseJSONNumber flag +* Added several unit tests + +#### 2.5.0 + +* Added support for signing method none. You shouldn't use this. The API tries to make this clear. +* Updated/fixed some documentation +* Added more helpful error message when trying to parse tokens that begin with `BEARER ` + #### 2.4.0 * Added new type, Parser, to allow for configuration of various parsing parameters diff --git a/vendor/github.com/dgrijalva/jwt-go/claims.go b/vendor/github.com/dgrijalva/jwt-go/claims.go new file mode 100644 index 000000000..f0228f02e --- /dev/null +++ b/vendor/github.com/dgrijalva/jwt-go/claims.go @@ -0,0 +1,134 @@ +package jwt + +import ( + "crypto/subtle" + "fmt" + "time" +) + +// For a type to be a Claims object, it must just have a Valid method that determines +// if the token is invalid for any supported reason +type Claims interface { + Valid() error +} + +// Structured version of Claims Section, as referenced at +// https://tools.ietf.org/html/rfc7519#section-4.1 +// See examples for how to use this with your own claim types +type StandardClaims struct { + Audience string `json:"aud,omitempty"` + ExpiresAt int64 `json:"exp,omitempty"` + Id string `json:"jti,omitempty"` + IssuedAt int64 `json:"iat,omitempty"` + Issuer string `json:"iss,omitempty"` + NotBefore int64 `json:"nbf,omitempty"` + Subject string `json:"sub,omitempty"` +} + +// Validates time based claims "exp, iat, nbf". +// There is no accounting for clock skew. +// As well, if any of the above claims are not in the token, it will still +// be considered a valid claim. +func (c StandardClaims) Valid() error { + vErr := new(ValidationError) + now := TimeFunc().Unix() + + // The claims below are optional, by default, so if they are set to the + // default value in Go, let's not fail the verification for them. + if c.VerifyExpiresAt(now, false) == false { + delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0)) + vErr.Inner = fmt.Errorf("token is expired by %v", delta) + vErr.Errors |= ValidationErrorExpired + } + + if c.VerifyIssuedAt(now, false) == false { + vErr.Inner = fmt.Errorf("Token used before issued") + vErr.Errors |= ValidationErrorIssuedAt + } + + if c.VerifyNotBefore(now, false) == false { + vErr.Inner = fmt.Errorf("token is not valid yet") + vErr.Errors |= ValidationErrorNotValidYet + } + + if vErr.valid() { + return nil + } + + return vErr +} + +// Compares the aud claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (c *StandardClaims) VerifyAudience(cmp string, req bool) bool { + return verifyAud(c.Audience, cmp, req) +} + +// Compares the exp claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (c *StandardClaims) VerifyExpiresAt(cmp int64, req bool) bool { + return verifyExp(c.ExpiresAt, cmp, req) +} + +// Compares the iat claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (c *StandardClaims) VerifyIssuedAt(cmp int64, req bool) bool { + return verifyIat(c.IssuedAt, cmp, req) +} + +// Compares the iss claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (c *StandardClaims) VerifyIssuer(cmp string, req bool) bool { + return verifyIss(c.Issuer, cmp, req) +} + +// Compares the nbf claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (c *StandardClaims) VerifyNotBefore(cmp int64, req bool) bool { + return verifyNbf(c.NotBefore, cmp, req) +} + +// ----- helpers + +func verifyAud(aud string, cmp string, required bool) bool { + if aud == "" { + return !required + } + if subtle.ConstantTimeCompare([]byte(aud), []byte(cmp)) != 0 { + return true + } else { + return false + } +} + +func verifyExp(exp int64, now int64, required bool) bool { + if exp == 0 { + return !required + } + return now <= exp +} + +func verifyIat(iat int64, now int64, required bool) bool { + if iat == 0 { + return !required + } + return now >= iat +} + +func verifyIss(iss string, cmp string, required bool) bool { + if iss == "" { + return !required + } + if subtle.ConstantTimeCompare([]byte(iss), []byte(cmp)) != 0 { + return true + } else { + return false + } +} + +func verifyNbf(nbf int64, now int64, required bool) bool { + if nbf == 0 { + return !required + } + return now >= nbf +} diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go index 0518ed106..2f59a2223 100644 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go @@ -69,7 +69,7 @@ func (m *SigningMethodECDSA) Verify(signingString, signature string, key interfa case *ecdsa.PublicKey: ecdsaKey = k default: - return ErrInvalidKey + return ErrInvalidKeyType } if len(sig) != 2*m.KeySize { @@ -103,7 +103,7 @@ func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string case *ecdsa.PrivateKey: ecdsaKey = k default: - return "", ErrInvalidKey + return "", ErrInvalidKeyType } // Create the hasher diff --git a/vendor/github.com/dgrijalva/jwt-go/errors.go b/vendor/github.com/dgrijalva/jwt-go/errors.go index e9e788ff9..662df19d4 100644 --- a/vendor/github.com/dgrijalva/jwt-go/errors.go +++ b/vendor/github.com/dgrijalva/jwt-go/errors.go @@ -6,9 +6,9 @@ import ( // Error constants var ( - ErrInvalidKey = errors.New("key is invalid or of invalid type") - ErrHashUnavailable = errors.New("the requested hash function is unavailable") - ErrNoTokenInRequest = errors.New("no token present in request") + ErrInvalidKey = errors.New("key is invalid") + ErrInvalidKeyType = errors.New("key is of invalid type") + ErrHashUnavailable = errors.New("the requested hash function is unavailable") ) // The errors that might occur when parsing and validating a token @@ -16,22 +16,42 @@ const ( ValidationErrorMalformed uint32 = 1 << iota // Token is malformed ValidationErrorUnverifiable // Token could not be verified because of signing problems ValidationErrorSignatureInvalid // Signature validation failed - ValidationErrorExpired // Exp validation failed - ValidationErrorNotValidYet // NBF validation failed + + // Standard Claim validation errors + ValidationErrorAudience // AUD validation failed + ValidationErrorExpired // EXP validation failed + ValidationErrorIssuedAt // IAT validation failed + ValidationErrorIssuer // ISS validation failed + ValidationErrorNotValidYet // NBF validation failed + ValidationErrorId // JTI validation failed + ValidationErrorClaimsInvalid // Generic claims validation error ) +// Helper for constructing a ValidationError with a string error message +func NewValidationError(errorText string, errorFlags uint32) *ValidationError { + return &ValidationError{ + text: errorText, + Errors: errorFlags, + } +} + // The error from Parse if token is not valid type ValidationError struct { - err string + Inner error // stores the error returned by external dependencies, i.e.: KeyFunc Errors uint32 // bitfield. see ValidationError... constants + text string // errors that do not have a valid error just have text } // Validation error is an error type func (e ValidationError) Error() string { - if e.err == "" { + if e.Inner != nil { + return e.Inner.Error() + } else if e.text != "" { + return e.text + } else { return "token is invalid" } - return e.err + return e.Inner.Error() } // No errors diff --git a/vendor/github.com/dgrijalva/jwt-go/hmac.go b/vendor/github.com/dgrijalva/jwt-go/hmac.go index 192e625fd..c22991925 100644 --- a/vendor/github.com/dgrijalva/jwt-go/hmac.go +++ b/vendor/github.com/dgrijalva/jwt-go/hmac.go @@ -49,7 +49,7 @@ func (m *SigningMethodHMAC) Verify(signingString, signature string, key interfac // Verify the key is the right type keyBytes, ok := key.([]byte) if !ok { - return ErrInvalidKey + return ErrInvalidKeyType } // Decode signature, for comparison diff --git a/vendor/github.com/dgrijalva/jwt-go/map_claims.go b/vendor/github.com/dgrijalva/jwt-go/map_claims.go new file mode 100644 index 000000000..291213c46 --- /dev/null +++ b/vendor/github.com/dgrijalva/jwt-go/map_claims.go @@ -0,0 +1,94 @@ +package jwt + +import ( + "encoding/json" + "errors" + // "fmt" +) + +// Claims type that uses the map[string]interface{} for JSON decoding +// This is the default claims type if you don't supply one +type MapClaims map[string]interface{} + +// Compares the aud claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (m MapClaims) VerifyAudience(cmp string, req bool) bool { + aud, _ := m["aud"].(string) + return verifyAud(aud, cmp, req) +} + +// Compares the exp claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool { + switch exp := m["exp"].(type) { + case float64: + return verifyExp(int64(exp), cmp, req) + case json.Number: + v, _ := exp.Int64() + return verifyExp(v, cmp, req) + } + return req == false +} + +// Compares the iat claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool { + switch iat := m["iat"].(type) { + case float64: + return verifyIat(int64(iat), cmp, req) + case json.Number: + v, _ := iat.Int64() + return verifyIat(v, cmp, req) + } + return req == false +} + +// Compares the iss claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (m MapClaims) VerifyIssuer(cmp string, req bool) bool { + iss, _ := m["iss"].(string) + return verifyIss(iss, cmp, req) +} + +// Compares the nbf claim against cmp. +// If required is false, this method will return true if the value matches or is unset +func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool { + switch nbf := m["nbf"].(type) { + case float64: + return verifyNbf(int64(nbf), cmp, req) + case json.Number: + v, _ := nbf.Int64() + return verifyNbf(v, cmp, req) + } + return req == false +} + +// Validates time based claims "exp, iat, nbf". +// There is no accounting for clock skew. +// As well, if any of the above claims are not in the token, it will still +// be considered a valid claim. +func (m MapClaims) Valid() error { + vErr := new(ValidationError) + now := TimeFunc().Unix() + + if m.VerifyExpiresAt(now, false) == false { + vErr.Inner = errors.New("Token is expired") + vErr.Errors |= ValidationErrorExpired + } + + if m.VerifyIssuedAt(now, false) == false { + vErr.Inner = errors.New("Token used before issued") + vErr.Errors |= ValidationErrorIssuedAt + } + + if m.VerifyNotBefore(now, false) == false { + vErr.Inner = errors.New("Token is not valid yet") + vErr.Errors |= ValidationErrorNotValidYet + } + + if vErr.valid() { + return nil + } + + return vErr +} diff --git a/vendor/github.com/dgrijalva/jwt-go/none.go b/vendor/github.com/dgrijalva/jwt-go/none.go new file mode 100644 index 000000000..f04d189d0 --- /dev/null +++ b/vendor/github.com/dgrijalva/jwt-go/none.go @@ -0,0 +1,52 @@ +package jwt + +// Implements the none signing method. This is required by the spec +// but you probably should never use it. +var SigningMethodNone *signingMethodNone + +const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed" + +var NoneSignatureTypeDisallowedError error + +type signingMethodNone struct{} +type unsafeNoneMagicConstant string + +func init() { + SigningMethodNone = &signingMethodNone{} + NoneSignatureTypeDisallowedError = NewValidationError("'none' signature type is not allowed", ValidationErrorSignatureInvalid) + + RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod { + return SigningMethodNone + }) +} + +func (m *signingMethodNone) Alg() string { + return "none" +} + +// Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key +func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) { + // Key must be UnsafeAllowNoneSignatureType to prevent accidentally + // accepting 'none' signing method + if _, ok := key.(unsafeNoneMagicConstant); !ok { + return NoneSignatureTypeDisallowedError + } + // If signing method is none, signature must be an empty string + if signature != "" { + return NewValidationError( + "'none' signing method with non-empty signature", + ValidationErrorSignatureInvalid, + ) + } + + // Accept 'none' signing method. + return nil +} + +// Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key +func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) { + if _, ok := key.(unsafeNoneMagicConstant); ok { + return "", nil + } + return "", NoneSignatureTypeDisallowedError +} diff --git a/vendor/github.com/dgrijalva/jwt-go/parser.go b/vendor/github.com/dgrijalva/jwt-go/parser.go index a078404ec..7020c52a1 100644 --- a/vendor/github.com/dgrijalva/jwt-go/parser.go +++ b/vendor/github.com/dgrijalva/jwt-go/parser.go @@ -16,45 +16,59 @@ type Parser struct { // keyFunc will receive the parsed token and should return the key for validating. // If everything is kosher, err will be nil func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { + return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc) +} + +func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) { parts := strings.Split(tokenString, ".") if len(parts) != 3 { - return nil, &ValidationError{err: "token contains an invalid number of segments", Errors: ValidationErrorMalformed} + return nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) } var err error token := &Token{Raw: tokenString} + // parse Header var headerBytes []byte if headerBytes, err = DecodeSegment(parts[0]); err != nil { if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") { - return token, &ValidationError{err: "tokenstring should not contain 'bearer '", Errors: ValidationErrorMalformed} + return token, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed) } - return token, &ValidationError{err: err.Error(), Errors: ValidationErrorMalformed} + return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} } if err = json.Unmarshal(headerBytes, &token.Header); err != nil { - return token, &ValidationError{err: err.Error(), Errors: ValidationErrorMalformed} + return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} } // parse Claims var claimBytes []byte + token.Claims = claims + if claimBytes, err = DecodeSegment(parts[1]); err != nil { - return token, &ValidationError{err: err.Error(), Errors: ValidationErrorMalformed} + return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} } dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) if p.UseJSONNumber { dec.UseNumber() } - if err = dec.Decode(&token.Claims); err != nil { - return token, &ValidationError{err: err.Error(), Errors: ValidationErrorMalformed} + // JSON Decode. Special case for map type to avoid weird pointer behavior + if c, ok := token.Claims.(MapClaims); ok { + err = dec.Decode(&c) + } else { + err = dec.Decode(&claims) + } + // Handle decode error + if err != nil { + return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} } // Lookup signature method if method, ok := token.Header["alg"].(string); ok { if token.Method = GetSigningMethod(method); token.Method == nil { - return token, &ValidationError{err: "signing method (alg) is unavailable.", Errors: ValidationErrorUnverifiable} + return token, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable) } } else { - return token, &ValidationError{err: "signing method (alg) is unspecified.", Errors: ValidationErrorUnverifiable} + return token, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable) } // Verify signing method is in the required set @@ -69,7 +83,7 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { } if !signingMethodValid { // signing method is not in the listed set - return token, &ValidationError{err: fmt.Sprintf("signing method %v is invalid", alg), Errors: ValidationErrorSignatureInvalid} + return token, NewValidationError(fmt.Sprintf("signing method %v is invalid", alg), ValidationErrorSignatureInvalid) } } @@ -77,33 +91,31 @@ func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { var key interface{} if keyFunc == nil { // keyFunc was not provided. short circuiting validation - return token, &ValidationError{err: "no Keyfunc was provided.", Errors: ValidationErrorUnverifiable} + return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable) } if key, err = keyFunc(token); err != nil { // keyFunc returned an error - return token, &ValidationError{err: err.Error(), Errors: ValidationErrorUnverifiable} + return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable} } - // Check expiration times vErr := &ValidationError{} - now := TimeFunc().Unix() - if exp, ok := token.Claims["exp"].(float64); ok { - if now > int64(exp) { - vErr.err = "token is expired" - vErr.Errors |= ValidationErrorExpired - } - } - if nbf, ok := token.Claims["nbf"].(float64); ok { - if now < int64(nbf) { - vErr.err = "token is not valid yet" - vErr.Errors |= ValidationErrorNotValidYet + + // Validate Claims + if err := token.Claims.Valid(); err != nil { + + // If the Claims Valid returned an error, check if it is a validation error, + // If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set + if e, ok := err.(*ValidationError); !ok { + vErr = &ValidationError{Inner: err, Errors: ValidationErrorClaimsInvalid} + } else { + vErr = e } } // Perform validation token.Signature = parts[2] if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { - vErr.err = err.Error() + vErr.Inner = err vErr.Errors |= ValidationErrorSignatureInvalid } diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa.go b/vendor/github.com/dgrijalva/jwt-go/rsa.go index cddffced5..0ae0b1984 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa.go @@ -44,8 +44,7 @@ func (m *SigningMethodRSA) Alg() string { } // Implements the Verify method from SigningMethod -// For this signing method, must be either a PEM encoded PKCS1 or PKCS8 RSA public key as -// []byte, or an rsa.PublicKey structure. +// For this signing method, must be an rsa.PublicKey structure. func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error { var err error @@ -56,16 +55,10 @@ func (m *SigningMethodRSA) Verify(signingString, signature string, key interface } var rsaKey *rsa.PublicKey + var ok bool - switch k := key.(type) { - case []byte: - if rsaKey, err = ParseRSAPublicKeyFromPEM(k); err != nil { - return err - } - case *rsa.PublicKey: - rsaKey = k - default: - return ErrInvalidKey + if rsaKey, ok = key.(*rsa.PublicKey); !ok { + return ErrInvalidKeyType } // Create hasher @@ -80,20 +73,13 @@ func (m *SigningMethodRSA) Verify(signingString, signature string, key interface } // Implements the Sign method from SigningMethod -// For this signing method, must be either a PEM encoded PKCS1 or PKCS8 RSA private key as -// []byte, or an rsa.PrivateKey structure. +// For this signing method, must be an rsa.PrivateKey structure. func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) { - var err error var rsaKey *rsa.PrivateKey + var ok bool - switch k := key.(type) { - case []byte: - if rsaKey, err = ParseRSAPrivateKeyFromPEM(k); err != nil { - return "", err - } - case *rsa.PrivateKey: - rsaKey = k - default: + // Validate type of key + if rsaKey, ok = key.(*rsa.PrivateKey); !ok { return "", ErrInvalidKey } diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go b/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go index b5b707350..10ee9db8a 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go @@ -106,7 +106,7 @@ func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (strin case *rsa.PrivateKey: rsaKey = k default: - return "", ErrInvalidKey + return "", ErrInvalidKeyType } // Create the hasher diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go index 6f3b6ff04..213a90dbb 100644 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go +++ b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go @@ -10,6 +10,7 @@ import ( var ( ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key") ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key") + ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key") ) // Parse PEM encoded PKCS1 or PKCS8 private key @@ -61,7 +62,7 @@ func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { var pkey *rsa.PublicKey var ok bool if pkey, ok = parsedKey.(*rsa.PublicKey); !ok { - return nil, ErrNotRSAPrivateKey + return nil, ErrNotRSAPublicKey } return pkey, nil diff --git a/vendor/github.com/dgrijalva/jwt-go/signing_method.go b/vendor/github.com/dgrijalva/jwt-go/signing_method.go index 12cf0f3d0..ed1f212b2 100644 --- a/vendor/github.com/dgrijalva/jwt-go/signing_method.go +++ b/vendor/github.com/dgrijalva/jwt-go/signing_method.go @@ -1,6 +1,11 @@ package jwt +import ( + "sync" +) + var signingMethods = map[string]func() SigningMethod{} +var signingMethodLock = new(sync.RWMutex) // Implement SigningMethod to add new methods for signing or verifying tokens. type SigningMethod interface { @@ -12,11 +17,17 @@ type SigningMethod interface { // Register the "alg" name and a factory function for signing method. // This is typically done during init() in the method's implementation func RegisterSigningMethod(alg string, f func() SigningMethod) { + signingMethodLock.Lock() + defer signingMethodLock.Unlock() + signingMethods[alg] = f } // Get a signing method from an "alg" string func GetSigningMethod(alg string) (method SigningMethod) { + signingMethodLock.RLock() + defer signingMethodLock.RUnlock() + if methodF, ok := signingMethods[alg]; ok { method = methodF() } diff --git a/vendor/github.com/dgrijalva/jwt-go/token.go b/vendor/github.com/dgrijalva/jwt-go/token.go index 1cf267d44..d637e0867 100644 --- a/vendor/github.com/dgrijalva/jwt-go/token.go +++ b/vendor/github.com/dgrijalva/jwt-go/token.go @@ -3,7 +3,6 @@ package jwt import ( "encoding/base64" "encoding/json" - "net/http" "strings" "time" ) @@ -15,7 +14,7 @@ var TimeFunc = time.Now // Parse methods use this callback function to supply // the key for verification. The function receives the parsed, -// but unverified Token. This allows you to use propries in the +// but unverified Token. This allows you to use properties in the // Header of the token (such as `kid`) to identify which key to use. type Keyfunc func(*Token) (interface{}, error) @@ -25,19 +24,23 @@ type Token struct { Raw string // The raw token. Populated when you Parse a token Method SigningMethod // The signing method used or to be used Header map[string]interface{} // The first segment of the token - Claims map[string]interface{} // The second segment of the token + Claims Claims // The second segment of the token Signature string // The third segment of the token. Populated when you Parse a token Valid bool // Is the token valid? Populated when you Parse/Verify a token } // Create a new Token. Takes a signing method func New(method SigningMethod) *Token { + return NewWithClaims(method, MapClaims{}) +} + +func NewWithClaims(method SigningMethod, claims Claims) *Token { return &Token{ Header: map[string]interface{}{ "typ": "JWT", "alg": method.Alg(), }, - Claims: make(map[string]interface{}), + Claims: claims, Method: method, } } @@ -63,16 +66,15 @@ func (t *Token) SigningString() (string, error) { var err error parts := make([]string, 2) for i, _ := range parts { - var source map[string]interface{} - if i == 0 { - source = t.Header - } else { - source = t.Claims - } - var jsonValue []byte - if jsonValue, err = json.Marshal(source); err != nil { - return "", err + if i == 0 { + if jsonValue, err = json.Marshal(t.Header); err != nil { + return "", err + } + } else { + if jsonValue, err = json.Marshal(t.Claims); err != nil { + return "", err + } } parts[i] = EncodeSegment(jsonValue) @@ -87,28 +89,8 @@ func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { return new(Parser).Parse(tokenString, keyFunc) } -// Try to find the token in an http.Request. -// This method will call ParseMultipartForm if there's no token in the header. -// Currently, it looks in the Authorization header as well as -// looking for an 'access_token' request parameter in req.Form. -func ParseFromRequest(req *http.Request, keyFunc Keyfunc) (token *Token, err error) { - - // Look for an Authorization header - if ah := req.Header.Get("Authorization"); ah != "" { - // Should be a bearer token - if len(ah) > 6 && strings.ToUpper(ah[0:7]) == "BEARER " { - return Parse(ah[7:], keyFunc) - } - } - - // Look for "access_token" parameter - req.ParseMultipartForm(10e6) - if tokStr := req.Form.Get("access_token"); tokStr != "" { - return Parse(tokStr, keyFunc) - } - - return nil, ErrNoTokenInRequest - +func ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) { + return new(Parser).ParseWithClaims(tokenString, claims, keyFunc) } // Encode JWT specific base64url encoding with padding stripped diff --git a/website/source/docs/builders/azure.html.md b/website/source/docs/builders/azure.html.md index 471cc9f24..c09768848 100644 --- a/website/source/docs/builders/azure.html.md +++ b/website/source/docs/builders/azure.html.md @@ -57,7 +57,7 @@ builder. ### Optional: -- `cloud_environment_name` (string) One of `Public`, `China`, or +- `cloud_environment_name` (string) One of `Public`, `China`, `German`, or `USGovernment`. Defaults to `Public`. Long forms such as `USGovernmentCloud` and `AzureUSGovernmentCloud` are also supported. From 6e9ef1c6eb24cdf8cd6358c53b94c266a757f428 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Wed, 20 Jul 2016 11:23:51 -0700 Subject: [PATCH 27/31] Use WithBaseURI --- builder/azure/arm/azure_client.go | 15 +++++---------- builder/azure/common/devicelogin.go | 9 +-------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/builder/azure/arm/azure_client.go b/builder/azure/arm/azure_client.go index 546bf9fb1..2f6e1e39a 100644 --- a/builder/azure/arm/azure_client.go +++ b/builder/azure/arm/azure_client.go @@ -110,40 +110,35 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string maxlen := getInspectorMaxLength() - azureClient.DeploymentsClient = resources.NewDeploymentsClient(subscriptionID) + azureClient.DeploymentsClient = resources.NewDeploymentsClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.DeploymentsClient.Authorizer = servicePrincipalToken azureClient.DeploymentsClient.RequestInspector = withInspection(maxlen) azureClient.DeploymentsClient.ResponseInspector = byInspecting(maxlen) azureClient.DeploymentsClient.UserAgent += packerUserAgent - azureClient.DeploymentsClient.BaseURI = cloud.ResourceManagerEndpoint - azureClient.GroupsClient = resources.NewGroupsClient(subscriptionID) + azureClient.GroupsClient = resources.NewGroupsClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.GroupsClient.Authorizer = servicePrincipalToken azureClient.GroupsClient.RequestInspector = withInspection(maxlen) azureClient.GroupsClient.ResponseInspector = byInspecting(maxlen) azureClient.GroupsClient.UserAgent += packerUserAgent - azureClient.GroupsClient.BaseURI = cloud.ResourceManagerEndpoint - azureClient.PublicIPAddressesClient = network.NewPublicIPAddressesClient(subscriptionID) + azureClient.PublicIPAddressesClient = network.NewPublicIPAddressesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.PublicIPAddressesClient.Authorizer = servicePrincipalToken azureClient.PublicIPAddressesClient.RequestInspector = withInspection(maxlen) azureClient.PublicIPAddressesClient.ResponseInspector = byInspecting(maxlen) azureClient.PublicIPAddressesClient.UserAgent += packerUserAgent - azureClient.PublicIPAddressesClient.BaseURI = cloud.ResourceManagerEndpoint - azureClient.VirtualMachinesClient = compute.NewVirtualMachinesClient(subscriptionID) + azureClient.VirtualMachinesClient = compute.NewVirtualMachinesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.VirtualMachinesClient.Authorizer = servicePrincipalToken azureClient.VirtualMachinesClient.RequestInspector = withInspection(maxlen) azureClient.VirtualMachinesClient.ResponseInspector = byConcatDecorators(byInspecting(maxlen), templateCapture(azureClient)) azureClient.VirtualMachinesClient.UserAgent += packerUserAgent - azureClient.VirtualMachinesClient.BaseURI = cloud.ResourceManagerEndpoint - azureClient.AccountsClient = armStorage.NewAccountsClient(subscriptionID) + azureClient.AccountsClient = armStorage.NewAccountsClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.AccountsClient.Authorizer = servicePrincipalToken azureClient.AccountsClient.RequestInspector = withInspection(maxlen) azureClient.AccountsClient.ResponseInspector = byInspecting(maxlen) azureClient.AccountsClient.UserAgent += packerUserAgent - azureClient.AccountsClient.BaseURI = cloud.ResourceManagerEndpoint keyVaultURL, err := url.Parse(cloud.KeyVaultEndpoint) if err != nil { diff --git a/builder/azure/common/devicelogin.go b/builder/azure/common/devicelogin.go index 700b2b4f8..d10eb9de5 100644 --- a/builder/azure/common/devicelogin.go +++ b/builder/azure/common/devicelogin.go @@ -231,13 +231,6 @@ func FindTenantID(env azure.Environment, subscriptionID string) (string, error) } func subscriptionsClient(baseURI string) subscriptions.Client { - client := subscriptions.Client{ - subscriptions.ManagementClient{ - Client: autorest.NewClientWithUserAgent(subscriptions.UserAgent() + userAgent), - BaseURI: baseURI, - APIVersion: subscriptions.APIVersion, - }, - } - + client := subscriptions.NewClientWithBaseURI(baseURI) return client } From 97b1915d51668b4d4d0167fc244126a3848aa395 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Wed, 20 Jul 2016 12:09:41 -0700 Subject: [PATCH 28/31] Update Azure dependencies * azure-sdk-for-go to 3.1.0-beta * go-autorest to 7.0.7 * import dgrijalva/jwt-go at 3.0.0 --- builder/azure/arm/config.go | 38 +++++++++++++++------- builder/azure/common/vault_test.go | 1 - website/source/docs/builders/azure.html.md | 2 +- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index cf3a731d0..355ee8e47 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -299,21 +299,37 @@ func setUserNamePassword(c *Config) { } func setCloudEnvironment(c *Config) error { + lookup := map[string]string{ + "CHINA": "AzureChinaCloud", + "CHINACLOUD": "AzureChinaCloud", + "AZURECHINACLOUD": "AzureChinaCloud", + + "GERMAN": "AzureGermanCloud", + "GERMANCLOUD": "AzureGermanCloud", + "AZUREGERMANCLOUD": "AzureGermanCloud", + + "GERMANY": "AzureGermanCloud", + "GERMANYCLOUD": "AzureGermanCloud", + "AZUREGERMANYCLOUD": "AzureGermanCloud", + + "PUBLIC": "AzurePublicCloud", + "PUBLICCLOUD": "AzurePublicCloud", + "AZUREPUBLICCLOUD": "AzurePublicCloud", + + "USGOVERNMENT": "AzureUSGovernmentCloud", + "USGOVERNMENTCLOUD": "AzureUSGovernmentCloud", + "AZUREUSGOVERNMENTCLOUD": "AzureUSGovernmentCloud", + } + name := strings.ToUpper(c.CloudEnvironmentName) - switch name { - case "CHINA", "CHINACLOUD", "AZURECHINACLOUD": - c.cloudEnvironment = &azure.ChinaCloud - case "GERMAN", "GERMANCLOUD", "AZUREGERMANCLOUD": - c.cloudEnvironment = &azure.GermanCloud - case "PUBLIC", "PUBLICCLOUD", "AZUREPUBLICCLOUD": - c.cloudEnvironment = &azure.PublicCloud - case "USGOVERNMENT", "USGOVERNMENTCLOUD", "AZUREUSGOVERNMENTCLOUD": - c.cloudEnvironment = &azure.USGovernmentCloud - default: + envName, ok := lookup[name] + if !ok { return fmt.Errorf("There is no cloud envionment matching the name '%s'!", c.CloudEnvironmentName) } - return nil + env, err := azure.EnvironmentFromName(envName) + c.cloudEnvironment = &env + return err } func provideDefaultValues(c *Config) { diff --git a/builder/azure/common/vault_test.go b/builder/azure/common/vault_test.go index cf7dc65cd..d1c94d76c 100644 --- a/builder/azure/common/vault_test.go +++ b/builder/azure/common/vault_test.go @@ -24,4 +24,3 @@ func TestVaultClientKeyVaultEndpointPreserveScheme(t *testing.T) { t.Errorf("expected \"http://my.vault.azure.net/\", got %q", vaultUrl) } } - diff --git a/website/source/docs/builders/azure.html.md b/website/source/docs/builders/azure.html.md index c09768848..adc5655b8 100644 --- a/website/source/docs/builders/azure.html.md +++ b/website/source/docs/builders/azure.html.md @@ -57,7 +57,7 @@ builder. ### Optional: -- `cloud_environment_name` (string) One of `Public`, `China`, `German`, or +- `cloud_environment_name` (string) One of `Public`, `China`, `Germany`, or `USGovernment`. Defaults to `Public`. Long forms such as `USGovernmentCloud` and `AzureUSGovernmentCloud` are also supported. From 7190fbeed8a13f07ca8f008576a0c5d994158c6d Mon Sep 17 00:00:00 2001 From: Scott Crunkleton Date: Tue, 24 May 2016 17:13:36 -0700 Subject: [PATCH 29/31] Adding support for googlecompute startup scripts. - Startup scripts can be provided through the instance creation metadata field 'startup-script'. - Script log can be copied to a GCS location by setting the metadata field 'startup-script-log-dest'. Added Retry method to googlecompute package. Added GetSerialPortOutput to googlecompute Drivers. Added StepWaitInstanceStartup (and associated test) which waits for an instance startup-script to finish. Changed the instance service account to use the same service account as the one provided in the Packer config template. It was the project default service account. Tested googlecompute package with 'go test' and also performed builds with a startup script and without a startup script. --- builder/googlecompute/artifact.go | 10 +-- builder/googlecompute/builder.go | 9 +-- builder/googlecompute/common.go | 44 +++++++++++++ builder/googlecompute/common_test.go | 64 ++++++++++++++++++ builder/googlecompute/config.go | 9 +-- builder/googlecompute/driver.go | 41 +++++++----- builder/googlecompute/driver_gce.go | 65 +++++++++++++------ builder/googlecompute/driver_mock.go | 52 ++++++++++++--- builder/googlecompute/startup.go | 53 +++++++++++++++ builder/googlecompute/step_create_image.go | 5 +- .../googlecompute/step_create_image_test.go | 34 ++++++---- builder/googlecompute/step_create_instance.go | 55 ++++++++++------ builder/googlecompute/step_create_ssh_key.go | 2 + builder/googlecompute/step_instance_info.go | 1 + .../googlecompute/step_teardown_instance.go | 3 +- .../step_wait_instance_startup.go | 50 ++++++++++++++ .../step_wait_instance_startup_test.go | 38 +++++++++++ .../docs/builders/googlecompute.html.md | 43 +++++++++--- 18 files changed, 474 insertions(+), 104 deletions(-) create mode 100644 builder/googlecompute/common.go create mode 100644 builder/googlecompute/common_test.go create mode 100644 builder/googlecompute/startup.go create mode 100644 builder/googlecompute/step_wait_instance_startup.go create mode 100644 builder/googlecompute/step_wait_instance_startup_test.go diff --git a/builder/googlecompute/artifact.go b/builder/googlecompute/artifact.go index cb2ad88bb..128db103b 100644 --- a/builder/googlecompute/artifact.go +++ b/builder/googlecompute/artifact.go @@ -7,7 +7,7 @@ import ( // Artifact represents a GCE image as the result of a Packer build. type Artifact struct { - imageName string + image Image driver Driver } @@ -18,8 +18,8 @@ func (*Artifact) BuilderId() string { // Destroy destroys the GCE image represented by the artifact. func (a *Artifact) Destroy() error { - log.Printf("Destroying image: %s", a.imageName) - errCh := a.driver.DeleteImage(a.imageName) + log.Printf("Destroying image: %s", a.image.Name) + errCh := a.driver.DeleteImage(a.image.Name) return <-errCh } @@ -30,12 +30,12 @@ func (*Artifact) Files() []string { // Id returns the GCE image name. func (a *Artifact) Id() string { - return a.imageName + return a.image.Name } // String returns the string representation of the artifact. func (a *Artifact) String() string { - return fmt.Sprintf("A disk image was created: %v", a.imageName) + return fmt.Sprintf("A disk image was created: %v", a.image.Name) } func (a *Artifact) State(name string) interface{} { diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 0f6e4bd2f..987672a90 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -67,6 +67,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe SSHConfig: sshConfig, }, new(common.StepProvision), + new(StepWaitInstanceStartup), new(StepTeardownInstance), new(StepCreateImage), } @@ -86,14 +87,14 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe if rawErr, ok := state.GetOk("error"); ok { return nil, rawErr.(error) } - if _, ok := state.GetOk("image_name"); !ok { - log.Println("Failed to find image_name in state. Bug?") + if _, ok := state.GetOk("image"); !ok { + log.Println("Failed to find image in state. Bug?") return nil, nil } artifact := &Artifact{ - imageName: state.Get("image_name").(string), - driver: driver, + image: state.Get("image").(Image), + driver: driver, } return artifact, nil } diff --git a/builder/googlecompute/common.go b/builder/googlecompute/common.go new file mode 100644 index 000000000..8f5520c16 --- /dev/null +++ b/builder/googlecompute/common.go @@ -0,0 +1,44 @@ +package googlecompute + +import ( + "fmt" + "math" + "time" +) + +var RetryExhaustedError error = fmt.Errorf("Function never succeeded in Retry") + +// Retry retries a function up to numTries times with exponential backoff. +// If numTries == 0, retry indefinitely. If interval == 0, Retry will not delay retrying and there will be +// no exponential backoff. If maxInterval == 0, maxInterval is set to +Infinity. +// Intervals are in seconds. +// Returns an error if initial > max intervals, if retries are exhausted, or if the passed function returns +// an error. +func Retry(initialInterval float64, maxInterval float64, numTries uint, function func() (bool, error)) error { + if maxInterval == 0 { + maxInterval = math.Inf(1) + } else if initialInterval < 0 || initialInterval > maxInterval { + return fmt.Errorf("Invalid retry intervals (negative or initial < max). Initial: %f, Max: %f.", initialInterval, maxInterval) + } + + var err error + done := false + interval := initialInterval + for i := uint(0); !done && (numTries == 0 || i < numTries); i++ { + done, err = function() + if err != nil { + return err + } + + if !done { + // Retry after delay. Calculate next delay. + time.Sleep(time.Duration(interval) * time.Second) + interval = math.Min(interval * 2, maxInterval) + } + } + + if !done { + return RetryExhaustedError + } + return nil +} diff --git a/builder/googlecompute/common_test.go b/builder/googlecompute/common_test.go new file mode 100644 index 000000000..caf9c2436 --- /dev/null +++ b/builder/googlecompute/common_test.go @@ -0,0 +1,64 @@ +package googlecompute + +import ( + "fmt" + "testing" +) + +func TestRetry(t *testing.T) { + numTries := uint(0) + // Test that a passing function only gets called once. + err := Retry(0, 0, 0, func() (bool, error) { + numTries++ + return true, nil + }) + if numTries != 1 { + t.Fatal("Passing function should not have been retried.") + } + if err != nil { + t.Fatalf("Passing function should not have returned a retry error. Error: %s", err) + } + + // Test that a failing function gets retried (once in this example). + numTries = 0 + results := []bool{false, true} + err = Retry(0, 0, 0, func() (bool, error) { + result := results[numTries] + numTries++ + return result, nil + }) + if numTries != 2 { + t.Fatalf("Retried function should have been tried twice. Tried %d times.", numTries) + } + if err != nil { + t.Fatalf("Successful retried function should not have returned a retry error. Error: %s", err) + } + + // Test that a function error gets returned, and the function does not get called again. + numTries = 0 + funcErr := fmt.Errorf("This function had an error!") + err = Retry(0, 0, 0, func() (bool, error) { + numTries++ + return false, funcErr + }) + if numTries != 1 { + t.Fatal("Errant function should not have been retried.") + } + if err != funcErr { + t.Fatalf("Errant function did not return the right error %s. Error: %s", funcErr, err) + } + + // Test when a function exhausts its retries. + numTries = 0 + expectedTries := uint(3) + err = Retry(0, 0, expectedTries, func() (bool, error) { + numTries++ + return false, nil + }) + if numTries != expectedTries { + t.Fatalf("Unsuccessul retry function should have been called %d times. Only called %d times.", expectedTries, numTries) + } + if err != RetryExhaustedError { + t.Fatalf("Unsuccessful retry function should have returned a retry exhausted error. Actual error: %s", err) + } +} \ No newline at end of file diff --git a/builder/googlecompute/config.go b/builder/googlecompute/config.go index e93347087..2072bd112 100644 --- a/builder/googlecompute/config.go +++ b/builder/googlecompute/config.go @@ -26,6 +26,7 @@ type Config struct { AccountFile string `mapstructure:"account_file"` ProjectId string `mapstructure:"project_id"` + Address string `mapstructure:"address"` DiskName string `mapstructure:"disk_name"` DiskSizeGb int64 `mapstructure:"disk_size"` DiskType string `mapstructure:"disk_type"` @@ -36,15 +37,15 @@ type Config struct { MachineType string `mapstructure:"machine_type"` Metadata map[string]string `mapstructure:"metadata"` Network string `mapstructure:"network"` - Subnetwork string `mapstructure:"subnetwork"` - Address string `mapstructure:"address"` Preemptible bool `mapstructure:"preemptible"` + RawStateTimeout string `mapstructure:"state_timeout"` + Region string `mapstructure:"region"` SourceImage string `mapstructure:"source_image"` SourceImageProjectId string `mapstructure:"source_image_project_id"` - RawStateTimeout string `mapstructure:"state_timeout"` + StartupScriptFile string `mapstructure:"startup_script_file"` + Subnetwork string `mapstructure:"subnetwork"` Tags []string `mapstructure:"tags"` UseInternalIP bool `mapstructure:"use_internal_ip"` - Region string `mapstructure:"region"` Zone string `mapstructure:"zone"` account accountFile diff --git a/builder/googlecompute/driver.go b/builder/googlecompute/driver.go index 13cd2809e..f1c6c931e 100644 --- a/builder/googlecompute/driver.go +++ b/builder/googlecompute/driver.go @@ -10,7 +10,7 @@ type Driver interface { // CreateImage creates an image from the given disk in Google Compute // Engine. - CreateImage(name, description, family, zone, disk string) <-chan error + CreateImage(name, description, family, zone, disk string) (<-chan Image, <-chan error) // DeleteImage deletes the image with the given name. DeleteImage(name string) <-chan error @@ -21,12 +21,15 @@ type Driver interface { // DeleteDisk deletes the disk with the given name. DeleteDisk(zone, name string) (<-chan error, error) - // GetNatIP gets the NAT IP address for the instance. - GetNatIP(zone, name string) (string, error) - // GetInternalIP gets the GCE-internal IP address for the instance. GetInternalIP(zone, name string) (string, error) + // GetNatIP gets the NAT IP address for the instance. + GetNatIP(zone, name string) (string, error) + + // GetSerialPortOutput gets the Serial Port contents for the instance. + GetSerialPortOutput(zone, name string) (string, error) + // RunInstance takes the given config and launches an instance. RunInstance(*InstanceConfig) (<-chan error, error) @@ -37,21 +40,23 @@ type Driver interface { type Image struct { Name string ProjectId string + SizeGb int64 } type InstanceConfig struct { - Description string - DiskSizeGb int64 - DiskType string - Image Image - MachineType string - Metadata map[string]string - Name string - Network string - Subnetwork string - Address string - Preemptible bool - Tags []string - Region string - Zone string + Address string + Description string + DiskSizeGb int64 + DiskType string + Image Image + MachineType string + Metadata map[string]string + Name string + Network string + Preemptible bool + Region string + ServiceAccountEmail string + Subnetwork string + Tags []string + Zone string } diff --git a/builder/googlecompute/driver_gce.go b/builder/googlecompute/driver_gce.go index 306ab1756..3b262d59e 100644 --- a/builder/googlecompute/driver_gce.go +++ b/builder/googlecompute/driver_gce.go @@ -5,7 +5,6 @@ import ( "log" "net/http" "runtime" - "time" "github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/version" @@ -91,7 +90,7 @@ func (d *driverGCE) ImageExists(name string) bool { return err == nil } -func (d *driverGCE) CreateImage(name, description, family, zone, disk string) <-chan error { +func (d *driverGCE) CreateImage(name, description, family, zone, disk string) (<-chan Image, <-chan error) { image := &compute.Image{ Description: description, Name: name, @@ -100,15 +99,32 @@ func (d *driverGCE) CreateImage(name, description, family, zone, disk string) <- SourceType: "RAW", } + imageCh := make(chan Image, 1) errCh := make(chan error, 1) op, err := d.service.Images.Insert(d.projectId, image).Do() if err != nil { errCh <- err } else { - go waitForState(errCh, "DONE", d.refreshGlobalOp(op)) + go func() { + err = waitForState(errCh, "DONE", d.refreshGlobalOp(op)) + if err != nil { + close(imageCh) + } + image, err = d.getImage(name, d.projectId) + if err != nil { + close(imageCh) + errCh <- err + } + imageCh <- Image{ + Name: name, + ProjectId: d.projectId, + SizeGb: image.DiskSizeGb, + } + close(imageCh) + }() } - return errCh + return imageCh, errCh } func (d *driverGCE) DeleteImage(name string) <-chan error { @@ -181,6 +197,15 @@ func (d *driverGCE) GetInternalIP(zone, name string) (string, error) { return "", nil } +func (d *driverGCE) GetSerialPortOutput(zone, name string) (string, error) { + output, err := d.service.Instances.GetSerialPortOutput(d.projectId, zone, name).Do() + if err != nil { + return "", err + } + + return output.Contents, nil +} + func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) { // Get the zone d.ui.Message(fmt.Sprintf("Loading zone: %s", c.Zone)) @@ -191,7 +216,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) { // Get the image d.ui.Message(fmt.Sprintf("Loading image: %s in project %s", c.Image.Name, c.Image.ProjectId)) - image, err := d.getImage(c.Image) + image, err := d.getImage(c.Image.Name, c.Image.ProjectId) if err != nil { return nil, err } @@ -294,7 +319,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) { }, ServiceAccounts: []*compute.ServiceAccount{ &compute.ServiceAccount{ - Email: "default", + Email: c.ServiceAccountEmail, Scopes: []string{ "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/compute", @@ -324,17 +349,17 @@ func (d *driverGCE) WaitForInstance(state, zone, name string) <-chan error { return errCh } -func (d *driverGCE) getImage(img Image) (image *compute.Image, err error) { - projects := []string{img.ProjectId, "centos-cloud", "coreos-cloud", "debian-cloud", "google-containers", "opensuse-cloud", "rhel-cloud", "suse-cloud", "ubuntu-os-cloud", "windows-cloud"} +func (d *driverGCE) getImage(name, projectId string) (image *compute.Image, err error) { + projects := []string{projectId, "centos-cloud", "coreos-cloud", "debian-cloud", "google-containers", "opensuse-cloud", "rhel-cloud", "suse-cloud", "ubuntu-os-cloud", "windows-cloud"} for _, project := range projects { - image, err = d.service.Images.Get(project, img.Name).Do() + image, err = d.service.Images.Get(project, name).Do() if err == nil && image != nil && image.SelfLink != "" { return } image = nil } - err = fmt.Errorf("Image %s could not be found in any of these projects: %s", img.Name, projects) + err = fmt.Errorf("Image %s could not be found in any of these projects: %s", name, projects) return } @@ -396,18 +421,16 @@ type stateRefreshFunc func() (string, error) // waitForState will spin in a loop forever waiting for state to // reach a certain target. -func waitForState(errCh chan<- error, target string, refresh stateRefreshFunc) { - for { +func waitForState(errCh chan<- error, target string, refresh stateRefreshFunc) error { + err := Retry(2, 2, 0, func() (bool, error) { state, err := refresh() if err != nil { - errCh <- err - return + return false, err + } else if state == target { + return true, nil } - if state == target { - errCh <- nil - return - } - - time.Sleep(2 * time.Second) - } + return false, nil + }) + errCh <- err + return err } diff --git a/builder/googlecompute/driver_mock.go b/builder/googlecompute/driver_mock.go index 551671a91..90ab726c5 100644 --- a/builder/googlecompute/driver_mock.go +++ b/builder/googlecompute/driver_mock.go @@ -6,12 +6,15 @@ type DriverMock struct { ImageExistsName string ImageExistsResult bool - CreateImageName string - CreateImageDesc string - CreateImageFamily string - CreateImageZone string - CreateImageDisk string - CreateImageErrCh <-chan error + CreateImageName string + CreateImageDesc string + CreateImageFamily string + CreateImageZone string + CreateImageDisk string + CreateImageProjectId string + CreateImageSizeGb int64 + CreateImageErrCh <-chan error + CreateImageResultCh <-chan Image DeleteImageName string DeleteImageErrCh <-chan error @@ -35,6 +38,11 @@ type DriverMock struct { GetInternalIPName string GetInternalIPResult string GetInternalIPErr error + + GetSerialPortOutputZone string + GetSerialPortOutputName string + GetSerialPortOutputResult string + GetSerialPortOutputErr error RunInstanceConfig *InstanceConfig RunInstanceErrCh <-chan error @@ -51,21 +59,39 @@ func (d *DriverMock) ImageExists(name string) bool { return d.ImageExistsResult } -func (d *DriverMock) CreateImage(name, description, family, zone, disk string) <-chan error { +func (d *DriverMock) CreateImage(name, description, family, zone, disk string) (<-chan Image, <-chan error) { d.CreateImageName = name d.CreateImageDesc = description d.CreateImageFamily = family d.CreateImageZone = zone d.CreateImageDisk = disk + if d.CreateImageSizeGb == 0 { + d.CreateImageSizeGb = 10 + } + if d.CreateImageProjectId == "" { + d.CreateImageProjectId = "test" + } - resultCh := d.CreateImageErrCh + resultCh := d.CreateImageResultCh if resultCh == nil { - ch := make(chan error) + ch := make(chan Image, 1) + ch <- Image{ + Name: name, + ProjectId: d.CreateImageProjectId, + SizeGb: d.CreateImageSizeGb, + } close(ch) resultCh = ch } - return resultCh + errCh := d.CreateImageErrCh + if errCh == nil { + ch := make(chan error) + close(ch) + errCh = ch + } + + return resultCh, errCh } func (d *DriverMock) DeleteImage(name string) <-chan error { @@ -121,6 +147,12 @@ func (d *DriverMock) GetInternalIP(zone, name string) (string, error) { return d.GetInternalIPResult, d.GetInternalIPErr } +func (d *DriverMock) GetSerialPortOutput(zone, name string) (string, error) { + d.GetSerialPortOutputZone = zone + d.GetSerialPortOutputName = name + return d.GetSerialPortOutputResult, d.GetSerialPortOutputErr +} + func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error) { d.RunInstanceConfig = c diff --git a/builder/googlecompute/startup.go b/builder/googlecompute/startup.go new file mode 100644 index 000000000..308e33e18 --- /dev/null +++ b/builder/googlecompute/startup.go @@ -0,0 +1,53 @@ +package googlecompute + +import ( + "encoding/base64" + "fmt" +) + +const StartupScriptStartLog string = "Packer startup script starting." +const StartupScriptDoneLog string = "Packer startup script done." +const StartupScriptKey string = "startup-script" +const StartupWrappedScriptKey string = "packer-wrapped-startup-script" + +// We have to encode StartupScriptDoneLog because we use it as a sentinel value to indicate +// that the user-provided startup script is done. If we pass StartupScriptDoneLog as-is, it +// will be printed early in the instance console log (before the startup script even runs; +// we print out instance creation metadata which contains this wrapper script). +var StartupScriptDoneLogBase64 string = base64.StdEncoding.EncodeToString([]byte(StartupScriptDoneLog)) + +var StartupScript string = fmt.Sprintf(`#!/bin/bash +echo %s +RETVAL=0 + +GetMetadata () { + echo "$(curl -f -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/attributes/$1 2> /dev/null)" +} + +STARTUPSCRIPT=$(GetMetadata %s) +STARTUPSCRIPTPATH=/packer-wrapped-startup-script +if [ -f "/var/log/startupscript.log" ]; then + STARTUPSCRIPTLOGPATH=/var/log/startupscript.log +else + STARTUPSCRIPTLOGPATH=/var/log/daemon.log +fi +STARTUPSCRIPTLOGDEST=$(GetMetadata startup-script-log-dest) + +if [[ ! -z $STARTUPSCRIPT ]]; then + echo "Executing user-provided startup script..." + echo "${STARTUPSCRIPT}" > ${STARTUPSCRIPTPATH} + chmod +x ${STARTUPSCRIPTPATH} + ${STARTUPSCRIPTPATH} + RETVAL=$? + + if [[ ! -z $STARTUPSCRIPTLOGDEST ]]; then + echo "Uploading user-provided startup script log to ${STARTUPSCRIPTLOGDEST}..." + gsutil -h "Content-Type:text/plain" cp ${STARTUPSCRIPTLOGPATH} ${STARTUPSCRIPTLOGDEST} + fi + + rm ${STARTUPSCRIPTPATH} +fi + +echo $(echo %s | base64 --decode) +exit $RETVAL +`, StartupScriptStartLog, StartupWrappedScriptKey, StartupScriptDoneLogBase64) diff --git a/builder/googlecompute/step_create_image.go b/builder/googlecompute/step_create_image.go index dbb690dd3..f7e531d43 100644 --- a/builder/googlecompute/step_create_image.go +++ b/builder/googlecompute/step_create_image.go @@ -23,7 +23,8 @@ func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Creating image...") - errCh := driver.CreateImage(config.ImageName, config.ImageDescription, config.ImageFamily, config.Zone, config.DiskName) + + imageCh, errCh := driver.CreateImage(config.ImageName, config.ImageDescription, config.ImageFamily, config.Zone, config.DiskName) var err error select { case err = <-errCh: @@ -38,7 +39,7 @@ func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - state.Put("image_name", config.ImageName) + state.Put("image", <-imageCh) return multistep.ActionContinue } diff --git a/builder/googlecompute/step_create_image_test.go b/builder/googlecompute/step_create_image_test.go index 4358f10de..c956ec5e3 100644 --- a/builder/googlecompute/step_create_image_test.go +++ b/builder/googlecompute/step_create_image_test.go @@ -18,13 +18,35 @@ func TestStepCreateImage(t *testing.T) { config := state.Get("config").(*Config) driver := state.Get("driver").(*DriverMock) + driver.CreateImageProjectId = "createimage-project" + driver.CreateImageSizeGb = 100 // run the step if action := step.Run(state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } + + uncastImage, ok := state.GetOk("image") + if !ok { + t.Fatal("should have image") + } + image, ok := uncastImage.(Image) + if !ok { + t.Fatal("image is not an Image") + } + + // Verify created Image results. + if image.Name != config.ImageName { + t.Fatalf("Created image name, %s, does not match config name, %s.", image.Name, config.ImageName) + } + if driver.CreateImageProjectId != image.ProjectId { + t.Fatalf("Created image project ID, %s, does not match driver project ID, %s.", image.ProjectId, driver.CreateImageProjectId) + } + if driver.CreateImageSizeGb != image.SizeGb { + t.Fatalf("Created image size, %d, does not match the expected test value, %d.", image.SizeGb, driver.CreateImageSizeGb) + } - // Verify state + // Verify proper args passed to driver.CreateImage. if driver.CreateImageName != config.ImageName { t.Fatalf("bad: %#v", driver.CreateImageName) } @@ -40,16 +62,6 @@ func TestStepCreateImage(t *testing.T) { if driver.CreateImageDisk != config.DiskName { t.Fatalf("bad: %#v", driver.CreateImageDisk) } - - nameRaw, ok := state.GetOk("image_name") - if !ok { - t.Fatal("should have name") - } - if name, ok := nameRaw.(string); !ok { - t.Fatal("name is not a string") - } else if name != config.ImageName { - t.Fatalf("bad name: %s", name) - } } func TestStepCreateImage_errorOnChannel(t *testing.T) { diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index 45320d158..cf997a920 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -3,6 +3,7 @@ package googlecompute import ( "errors" "fmt" + "io/ioutil" "time" "github.com/mitchellh/multistep" @@ -22,23 +23,34 @@ func (config *Config) getImage() Image { return Image{Name: config.SourceImage, ProjectId: project} } -func (config *Config) getInstanceMetadata(sshPublicKey string) map[string]string { +func (config *Config) getInstanceMetadata(sshPublicKey string) (map[string]string, error) { instanceMetadata := make(map[string]string) + var err error - // Copy metadata from config + // Copy metadata from config. for k, v := range config.Metadata { instanceMetadata[k] = v } - // Merge any existing ssh keys with our public key + // Merge any existing ssh keys with our public key. sshMetaKey := "sshKeys" sshKeys := fmt.Sprintf("%s:%s", config.Comm.SSHUsername, sshPublicKey) if confSshKeys, exists := instanceMetadata[sshMetaKey]; exists { sshKeys = fmt.Sprintf("%s\n%s", sshKeys, confSshKeys) } instanceMetadata[sshMetaKey] = sshKeys + + // Wrap any startup script with our own startup script. + if config.StartupScriptFile != "" { + var content []byte + content, err = ioutil.ReadFile(config.StartupScriptFile) + instanceMetadata[StartupWrappedScriptKey] = string(content) + } else if wrappedStartupScript, exists := instanceMetadata[StartupScriptKey]; exists { + instanceMetadata[StartupWrappedScriptKey] = wrappedStartupScript + } + instanceMetadata[StartupScriptKey] = StartupScript - return instanceMetadata + return instanceMetadata, err } // Run executes the Packer build step that creates a GCE instance. @@ -51,21 +63,26 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction ui.Say("Creating instance...") name := config.InstanceName - errCh, err := driver.RunInstance(&InstanceConfig{ - Description: "New instance created by Packer", - DiskSizeGb: config.DiskSizeGb, - DiskType: config.DiskType, - Image: config.getImage(), - MachineType: config.MachineType, - Metadata: config.getInstanceMetadata(sshPublicKey), - Name: name, - Network: config.Network, - Subnetwork: config.Subnetwork, - Address: config.Address, - Preemptible: config.Preemptible, - Tags: config.Tags, - Region: config.Region, - Zone: config.Zone, + var errCh <-chan error + var err error + var metadata map[string]string + metadata, err = config.getInstanceMetadata(sshPublicKey) + errCh, err = driver.RunInstance(&InstanceConfig{ + Address: config.Address, + Description: "New instance created by Packer", + DiskSizeGb: config.DiskSizeGb, + DiskType: config.DiskType, + Image: config.getImage(), + MachineType: config.MachineType, + Metadata: metadata, + Name: name, + Network: config.Network, + Preemptible: config.Preemptible, + Region: config.Region, + ServiceAccountEmail: config.account.ClientEmail, + Subnetwork: config.Subnetwork, + Tags: config.Tags, + Zone: config.Zone, }) if err == nil { diff --git a/builder/googlecompute/step_create_ssh_key.go b/builder/googlecompute/step_create_ssh_key.go index 521e6c3d6..4c4894fba 100644 --- a/builder/googlecompute/step_create_ssh_key.go +++ b/builder/googlecompute/step_create_ssh_key.go @@ -20,6 +20,8 @@ type StepCreateSSHKey struct { } // Run executes the Packer build step that generates SSH key pairs. +// The key pairs are added to the multistep state as "ssh_private_key" and +// "ssh_public_key". func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_instance_info.go b/builder/googlecompute/step_instance_info.go index 92f382f06..511906206 100644 --- a/builder/googlecompute/step_instance_info.go +++ b/builder/googlecompute/step_instance_info.go @@ -17,6 +17,7 @@ type StepInstanceInfo struct { } // Run executes the Packer build step that gathers GCE instance info. +// This adds "instance_ip" to the multistep state. func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) diff --git a/builder/googlecompute/step_teardown_instance.go b/builder/googlecompute/step_teardown_instance.go index b623d24fd..42ad83a5d 100644 --- a/builder/googlecompute/step_teardown_instance.go +++ b/builder/googlecompute/step_teardown_instance.go @@ -27,6 +27,8 @@ func (s *StepTeardownInstance) Run(state multistep.StateBag) multistep.StepActio } ui.Say("Deleting instance...") + instanceLog, _ := driver.GetSerialPortOutput(config.Zone, name) + state.Put("instance_log", instanceLog) errCh, err := driver.DeleteInstance(config.Zone, name) if err == nil { select { @@ -43,7 +45,6 @@ func (s *StepTeardownInstance) Run(state multistep.StateBag) multistep.StepActio "Error: %s", name, err)) return multistep.ActionHalt } - ui.Message("Instance has been deleted!") state.Put("instance_name", "") diff --git a/builder/googlecompute/step_wait_instance_startup.go b/builder/googlecompute/step_wait_instance_startup.go new file mode 100644 index 000000000..3fa162732 --- /dev/null +++ b/builder/googlecompute/step_wait_instance_startup.go @@ -0,0 +1,50 @@ +package googlecompute + +import( + "fmt" + "strings" + + "github.com/mitchellh/multistep" + "github.com/mitchellh/packer/packer" +) + +type StepWaitInstanceStartup int + +// Run reads the instance serial port output and looks for the log entry indicating the startup script finished. +func (s *StepWaitInstanceStartup) Run(state multistep.StateBag) multistep.StepAction { + config := state.Get("config").(*Config) + driver := state.Get("driver").(Driver) + ui := state.Get("ui").(packer.Ui) + instanceName := state.Get("instance_name").(string) + + ui.Say("Waiting for any running startup script to finish...") + + // Keep checking the serial port output to see if the startup script is done. + err := Retry(10, 60, 0, func() (bool, error) { + output, err := driver.GetSerialPortOutput(config.Zone, instanceName) + + if err != nil { + err := fmt.Errorf("Error getting serial port output: %s", err) + return false, err + } + + done := strings.Contains(output, StartupScriptDoneLog) + if !done { + ui.Say("Startup script not finished yet. Waiting...") + } + + return done, nil + }) + + if err != nil { + err := fmt.Errorf("Error waiting for startup script to finish: %s", err) + state.Put("error", err) + ui.Error(err.Error()) + return multistep.ActionHalt + } + ui.Say("Startup script, if any, has finished running.") + return multistep.ActionContinue +} + +// Cleanup. +func (s *StepWaitInstanceStartup) Cleanup(state multistep.StateBag) {} diff --git a/builder/googlecompute/step_wait_instance_startup_test.go b/builder/googlecompute/step_wait_instance_startup_test.go new file mode 100644 index 000000000..da6d896d3 --- /dev/null +++ b/builder/googlecompute/step_wait_instance_startup_test.go @@ -0,0 +1,38 @@ +package googlecompute + +import ( + "github.com/mitchellh/multistep" + "testing" +) + +func TestStepWaitInstanceStartup(t *testing.T) { + state := testState(t) + step := new(StepWaitInstanceStartup) + config := state.Get("config").(*Config) + driver := state.Get("driver").(*DriverMock) + + testZone := "test-zone" + testInstanceName := "test-instance-name" + + config.Zone = testZone + state.Put("instance_name", testInstanceName) + // The done log triggers step completion. + driver.GetSerialPortOutputResult = StartupScriptDoneLog + + // Run the step. + if action := step.Run(state); action != multistep.ActionContinue { + t.Fatalf("StepWaitInstanceStartup did not return a Continue action: %#v", action) + } + + // Check that GetSerialPortOutput was called properly. + if driver.GetSerialPortOutputZone != testZone { + t.Fatalf( + "GetSerialPortOutput wrong zone. Expected: %s, Actual: %s", driver.GetSerialPortOutputZone, + testZone) + } + if driver.GetSerialPortOutputName != testInstanceName { + t.Fatalf( + "GetSerialPortOutput wrong instance name. Expected: %s, Actual: %s", driver.GetSerialPortOutputName, + testInstanceName) + } +} \ No newline at end of file diff --git a/website/source/docs/builders/googlecompute.html.md b/website/source/docs/builders/googlecompute.html.md index c4842b976..c944e9d4c 100644 --- a/website/source/docs/builders/googlecompute.html.md +++ b/website/source/docs/builders/googlecompute.html.md @@ -1,8 +1,9 @@ --- description: | The `googlecompute` Packer builder is able to create images for use with Google - Compute Engine (GCE) based on existing images. Google Compute Engine doesn't - allow the creation of images from scratch. + Compute Engine (GCE) based on existing images. Building GCE images from scratch + is not possible from Packer at this time. For building images from scratch, please see + [Building GCE Images from Scratch](https://cloud.google.com/compute/docs/tutorials/building-images). layout: docs page_title: Google Compute Builder ... @@ -14,9 +15,9 @@ Type: `googlecompute` The `googlecompute` Packer builder is able to create [images](https://developers.google.com/compute/docs/images) for use with [Google Compute Engine](https://cloud.google.com/products/compute-engine)(GCE) based on -existing images. Google Compute Engine doesn't allow the creation of images from -scratch. - +existing images. Building GCE images from scratch is not possible from Packer at +this time. For building images from scratch, please see +[Building GCE Images from Scratch](https://cloud.google.com/compute/docs/tutorials/building-images). ## Authentication Authenticating with Google Cloud services requires at most one JSON file, called @@ -76,10 +77,10 @@ straightforwarded, it is documented here. ## Basic Example Below is a fully functioning example. It doesn't do anything useful, since no -provisioners are defined, but it will effectively repackage an existing GCE -image. The account_file is obtained in the previous section. If it parses as -JSON it is assumed to be the file itself, otherwise it is assumed to be -the path to the file containing the JSON. +provisioners or startup-script metadata are defined, but it will effectively +repackage an existing GCE image. The account_file is obtained in the previous +section. If it parses as JSON it is assumed to be the file itself, otherwise it +is assumed to be the path to the file containing the JSON. ``` {.javascript} { @@ -150,6 +151,9 @@ builder. - `region` (string) - The region in which to launch the instance. Defaults to to the region hosting the specified `zone`. +- `startup_script_file` (string) - The filepath to a startup script to run on + the VM from which the image will be made. + - `state_timeout` (string) - The time to wait for instance state changes. Defaults to `"5m"`. @@ -163,6 +167,27 @@ builder. - `use_internal_ip` (boolean) - If true, use the instance's internal IP instead of its external IP during building. + +## Startup Scripts + +Startup scripts can be a powerful tool for configuring the instance from which the image is made. +The builder will wait for a startup script to terminate. A startup script can be provided via the +`startup_script_file` or 'startup-script' instance creation `metadata` field. Therefore, the build +time will vary depending on the duration of the startup script. If `startup_script_file` is set, +the 'startup-script' `metadata` field will be overwritten. In other words,`startup_script_file` +takes precedence. + +The builder does not check for a pass/fail/error signal from the startup script, at this time. Until +such support is implemented, startup scripts should be robust, as an image will still be built even +when a startup script fails. + +### Windows +Startup scripts do not work on Windows builds, at this time. + +### Logging +Startup script logs can be copied to a Google Cloud Storage (GCS) location specified via the +'startup-script-log-dest' instance creation `metadata` field. The GCS location must be writeable by +the credentials provided in the builder config's `account_file`. ## Gotchas From 871ca8c3d91208e7d764cbf779e5dcbf931ba2cf Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Thu, 30 Jun 2016 16:51:52 -0700 Subject: [PATCH 30/31] azure: Support for a user define VNET. Two new configuration options have been exposed to allow users to specify an existing virtual network: virtual_network_name and virtual_network_resource_group_name. * virtual_network_name: name of the virtual network to attach a Packer VM to. * virtual_network_resource_group_name: name of the resource group that contains the virtual network. This value is optional. If the value is not specified, the builder queries Azure for the appropriate value. If the builder cannot disambiguate the value, a value must be provided for this setting. * virtual_network_subnet_name: name of the subnet attached to the virtual network. This value is optional. If the value is not specified, the builder queries Azure for the appropriate value. If the builder cannot disambiguate the value, a value must be provided for this setting. --- .gitignore | 1 + ...estVirtualMachineDeployment05.approved.txt | 120 ++++++++++++++++++ builder/azure/arm/azure_client.go | 21 +++ builder/azure/arm/builder.go | 22 +++- builder/azure/arm/builder_test.go | 1 + builder/azure/arm/config.go | 19 ++- builder/azure/arm/config_retriever.go | 12 +- builder/azure/arm/config_test.go | 72 +++++++++++ builder/azure/arm/resource_resolver.go | 101 +++++++++++++++ builder/azure/arm/resource_resolver_test.go | 76 +++++++++++ builder/azure/arm/step_get_ip_address.go | 66 +++++++--- builder/azure/arm/step_get_ip_address_test.go | 29 +++-- builder/azure/arm/template_factory.go | 7 + ...stVirtualMachineDeployment03.approved.json | 7 +- ...stVirtualMachineDeployment04.approved.json | 7 +- ...stVirtualMachineDeployment05.approved.json | 120 ++++++++++++++++++ builder/azure/arm/template_factory_test.go | 32 +++++ builder/azure/common/constants/stateBag.go | 1 + .../template/TestBuildLinux02.approved.txt | 120 ++++++++++++++++++ .../azure/common/template/template_builder.go | 61 ++++++++- ...uilder_test.TestBuildLinux00.approved.json | 7 +- ...uilder_test.TestBuildLinux01.approved.json | 7 +- ...uilder_test.TestBuildLinux02.approved.json | 120 ++++++++++++++++++ ...lder_test.TestBuildWindows00.approved.json | 7 +- .../common/template/template_builder_test.go | 26 ++++ website/source/docs/builders/azure.html.md | 13 ++ 26 files changed, 1023 insertions(+), 52 deletions(-) create mode 100644 builder/azure/arm/TestVirtualMachineDeployment05.approved.txt create mode 100644 builder/azure/arm/resource_resolver.go create mode 100644 builder/azure/arm/resource_resolver_test.go create mode 100644 builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json create mode 100644 builder/azure/common/template/TestBuildLinux02.approved.txt create mode 100644 builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json diff --git a/.gitignore b/.gitignore index 8dd382f2a..3999641cd 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ .idea test/.env *~ +*.received.* website/.bundle website/vendor diff --git a/builder/azure/arm/TestVirtualMachineDeployment05.approved.txt b/builder/azure/arm/TestVirtualMachineDeployment05.approved.txt new file mode 100644 index 000000000..906820f27 --- /dev/null +++ b/builder/azure/arm/TestVirtualMachineDeployment05.approved.txt @@ -0,0 +1,120 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "image": { + "uri": "https://localhost/custom.vhd" + }, + "name": "osdisk", + "osType": "Linux", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "ignore", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "ignore", + "virtualNetworkResourceGroup": "ignore", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } +} \ No newline at end of file diff --git a/builder/azure/arm/azure_client.go b/builder/azure/arm/azure_client.go index 2f6e1e39a..096979b04 100644 --- a/builder/azure/arm/azure_client.go +++ b/builder/azure/arm/azure_client.go @@ -36,6 +36,9 @@ type AzureClient struct { resources.DeploymentsClient resources.GroupsClient network.PublicIPAddressesClient + network.InterfacesClient + network.SubnetsClient + network.VirtualNetworksClient compute.VirtualMachinesClient common.VaultClient armStorage.AccountsClient @@ -122,6 +125,24 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string azureClient.GroupsClient.ResponseInspector = byInspecting(maxlen) azureClient.GroupsClient.UserAgent += packerUserAgent + azureClient.InterfacesClient = network.NewInterfacesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) + azureClient.InterfacesClient.Authorizer = servicePrincipalToken + azureClient.InterfacesClient.RequestInspector = withInspection(maxlen) + azureClient.InterfacesClient.ResponseInspector = byInspecting(maxlen) + azureClient.InterfacesClient.UserAgent += packerUserAgent + + azureClient.SubnetsClient = network.NewSubnetsClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) + azureClient.SubnetsClient.Authorizer = servicePrincipalToken + azureClient.SubnetsClient.RequestInspector = withInspection(maxlen) + azureClient.SubnetsClient.ResponseInspector = byInspecting(maxlen) + azureClient.SubnetsClient.UserAgent += packerUserAgent + + azureClient.VirtualNetworksClient = network.NewVirtualNetworksClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) + azureClient.VirtualNetworksClient.Authorizer = servicePrincipalToken + azureClient.VirtualNetworksClient.RequestInspector = withInspection(maxlen) + azureClient.VirtualNetworksClient.ResponseInspector = byInspecting(maxlen) + azureClient.VirtualNetworksClient.UserAgent += packerUserAgent + azureClient.PublicIPAddressesClient = network.NewPublicIPAddressesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.PublicIPAddressesClient.Authorizer = servicePrincipalToken azureClient.PublicIPAddressesClient.RequestInspector = withInspection(maxlen) diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 6785e3a63..0d85d3fc8 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "strings" "time" packerAzureCommon "github.com/mitchellh/packer/builder/azure/common" @@ -20,7 +21,6 @@ import ( packerCommon "github.com/mitchellh/packer/common" "github.com/mitchellh/packer/helper/communicator" "github.com/mitchellh/packer/packer" - "strings" ) type Builder struct { @@ -30,6 +30,7 @@ type Builder struct { } const ( + DefaultNicName = "packerNic" DefaultPublicIPAddressName = "packerPublicIP" DefaultSasBlobContainer = "system/Microsoft.Compute" DefaultSasBlobPermission = "r" @@ -82,11 +83,21 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return nil, err } + resolver := newResourceResolver(azureClient) + if err := resolver.Resolve(b.config); err != nil { + return nil, err + } + b.config.storageAccountBlobEndpoint, err = b.getBlobEndpoint(azureClient, b.config.ResourceGroupName, b.config.StorageAccount) if err != nil { return nil, err } + endpointConnectType := PublicEndpoint + if b.isPrivateNetworkCommunication() { + endpointConnectType = PrivateEndpoint + } + b.setTemplateParameters(b.stateBag) var steps []multistep.Step @@ -95,7 +106,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe NewStepCreateResourceGroup(azureClient, ui), NewStepValidateTemplate(azureClient, ui, b.config, GetVirtualMachineDeployment), NewStepDeployTemplate(azureClient, ui, b.config, GetVirtualMachineDeployment), - NewStepGetIPAddress(azureClient, ui), + NewStepGetIPAddress(azureClient, ui, endpointConnectType), &communicator.StepConnectSSH{ Config: &b.config.Comm, Host: lin.SSHHost, @@ -117,7 +128,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe NewStepSetCertificate(b.config, ui), NewStepValidateTemplate(azureClient, ui, b.config, GetVirtualMachineDeployment), NewStepDeployTemplate(azureClient, ui, b.config, GetVirtualMachineDeployment), - NewStepGetIPAddress(azureClient, ui), + NewStepGetIPAddress(azureClient, ui, endpointConnectType), &communicator.StepConnectWinRM{ Config: &b.config.Comm, Host: func(stateBag multistep.StateBag) (string, error) { @@ -176,6 +187,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe return &Artifact{}, nil } +func (b *Builder) isPrivateNetworkCommunication() bool { + return b.config.VirtualNetworkName != "" +} + func (b *Builder) Cancel() { if b.runner != nil { log.Println("Cancelling the step runner...") @@ -213,6 +228,7 @@ func (b *Builder) configureStateBag(stateBag multistep.StateBag) { stateBag.Put(constants.ArmDeploymentName, b.config.tmpDeploymentName) stateBag.Put(constants.ArmKeyVaultName, b.config.tmpKeyVaultName) stateBag.Put(constants.ArmLocation, b.config.Location) + stateBag.Put(constants.ArmNicName, DefaultNicName) stateBag.Put(constants.ArmPublicIPAddressName, DefaultPublicIPAddressName) stateBag.Put(constants.ArmResourceGroupName, b.config.tmpResourceGroupName) stateBag.Put(constants.ArmStorageAccountName, b.config.StorageAccount) diff --git a/builder/azure/arm/builder_test.go b/builder/azure/arm/builder_test.go index ecb2ea75f..9f0d26670 100644 --- a/builder/azure/arm/builder_test.go +++ b/builder/azure/arm/builder_test.go @@ -22,6 +22,7 @@ func TestStateBagShouldBePopulatedExpectedValues(t *testing.T) { constants.ArmComputeName, constants.ArmDeploymentName, constants.ArmLocation, + constants.ArmNicName, constants.ArmResourceGroupName, constants.ArmStorageAccountName, constants.ArmVirtualMachineCaptureParameters, diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index 355ee8e47..93b7f7b59 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -70,11 +70,14 @@ type Config struct { VMSize string `mapstructure:"vm_size"` // Deployment - ResourceGroupName string `mapstructure:"resource_group_name"` - StorageAccount string `mapstructure:"storage_account"` - storageAccountBlobEndpoint string - CloudEnvironmentName string `mapstructure:"cloud_environment_name"` - cloudEnvironment *azure.Environment + ResourceGroupName string `mapstructure:"resource_group_name"` + StorageAccount string `mapstructure:"storage_account"` + storageAccountBlobEndpoint string + CloudEnvironmentName string `mapstructure:"cloud_environment_name"` + cloudEnvironment *azure.Environment + VirtualNetworkName string `mapstructure:"virtual_network_name"` + VirtualNetworkSubnetName string `mapstructure:"virtual_network_subnet_name"` + VirtualNetworkResourceGroupName string `mapstructure:"virtual_network_resource_group_name"` // OS OSType string `mapstructure:"os_type"` @@ -447,6 +450,12 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { if c.ResourceGroupName == "" { errs = packer.MultiErrorAppend(errs, fmt.Errorf("A resource_group_name must be specified")) } + if c.VirtualNetworkName == "" && c.VirtualNetworkResourceGroupName != "" { + errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_resource_group_name is specified, so must virtual_network_name")) + } + if c.VirtualNetworkName == "" && c.VirtualNetworkSubnetName != "" { + errs = packer.MultiErrorAppend(errs, fmt.Errorf("If virtual_network_subnet_name is specified, so must virtual_network_name")) + } ///////////////////////////////////////////// // OS diff --git a/builder/azure/arm/config_retriever.go b/builder/azure/arm/config_retriever.go index 428b159ea..b31340f46 100644 --- a/builder/azure/arm/config_retriever.go +++ b/builder/azure/arm/config_retriever.go @@ -1,5 +1,12 @@ package arm +// Method to resolve information about the user so that a client can be +// constructed to communicated with Azure. +// +// The following data are resolved. +// +// 1. TenantID + import ( "github.com/Azure/go-autorest/autorest/azure" "github.com/mitchellh/packer/builder/azure/common" @@ -11,7 +18,9 @@ type configRetriever struct { } func newConfigRetriever() configRetriever { - return configRetriever{common.FindTenantID} + return configRetriever{ + common.FindTenantID, + } } func (cr configRetriever) FillParameters(c *Config) error { @@ -22,5 +31,6 @@ func (cr configRetriever) FillParameters(c *Config) error { } c.TenantID = tenantID } + return nil } diff --git a/builder/azure/arm/config_test.go b/builder/azure/arm/config_test.go index ae66cc09b..9e5a89245 100644 --- a/builder/azure/arm/config_test.go +++ b/builder/azure/arm/config_test.go @@ -142,6 +142,78 @@ func TestConfigShouldRejectCustomImageAndMarketPlace(t *testing.T) { } } +func TestConfigVirtualNetworkNameIsOptional(t *testing.T) { + config := map[string]string{ + "capture_name_prefix": "ignore", + "capture_container_name": "ignore", + "location": "ignore", + "image_url": "ignore", + "storage_account": "ignore", + "resource_group_name": "ignore", + "subscription_id": "ignore", + "os_type": constants.Target_Linux, + "communicator": "none", + "virtual_network_name": "MyVirtualNetwork", + } + + c, _, _ := newConfig(config, getPackerConfiguration()) + if c.VirtualNetworkName != "MyVirtualNetwork" { + t.Errorf("Expected Config to set virtual_network_name to MyVirtualNetwork, but got %q", c.VirtualNetworkName) + } + if c.VirtualNetworkResourceGroupName != "" { + t.Errorf("Expected Config to leave virtual_network_resource_group_name to '', but got %q", c.VirtualNetworkResourceGroupName) + } + if c.VirtualNetworkSubnetName != "" { + t.Errorf("Expected Config to leave virtual_network_subnet_name to '', but got %q", c.VirtualNetworkSubnetName) + } +} + +// The user can pass the value virtual_network_resource_group_name to avoid the lookup of +// a virtual network's resource group, or to help with disambiguation. The value should +// only be set if virtual_network_name was set. +func TestConfigVirtualNetworkResourceGroupNameMustBeSetWithVirtualNetworkName(t *testing.T) { + config := map[string]string{ + "capture_name_prefix": "ignore", + "capture_container_name": "ignore", + "location": "ignore", + "image_url": "ignore", + "storage_account": "ignore", + "resource_group_name": "ignore", + "subscription_id": "ignore", + "os_type": constants.Target_Linux, + "communicator": "none", + "virtual_network_resource_group_name": "MyVirtualNetworkRG", + } + + _, _, err := newConfig(config, getPackerConfiguration()) + if err == nil { + t.Error("Expected Config to reject virtual_network_resource_group_name, if virtual_network_name is not set.") + } +} + +// The user can pass the value virtual_network_subnet_name to avoid the lookup of +// a virtual network subnet's name, or to help with disambiguation. The value should +// only be set if virtual_network_name was set. +func TestConfigVirtualNetworkSubnetNameMustBeSetWithVirtualNetworkName(t *testing.T) { + config := map[string]string{ + "capture_name_prefix": "ignore", + "capture_container_name": "ignore", + "location": "ignore", + "image_url": "ignore", + "storage_account": "ignore", + "resource_group_name": "ignore", + "subscription_id": "ignore", + "os_type": constants.Target_Linux, + "communicator": "none", + "virtual_network_subnet_name": "MyVirtualNetworkRG", + } + + _, _, err := newConfig(config, getPackerConfiguration()) + if err == nil { + t.Error("Expected Config to reject virtual_network_subnet_name, if virtual_network_name is not set.") + } +} + func TestConfigShouldDefaultToPublicCloud(t *testing.T) { c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration()) diff --git a/builder/azure/arm/resource_resolver.go b/builder/azure/arm/resource_resolver.go new file mode 100644 index 000000000..0dc278b25 --- /dev/null +++ b/builder/azure/arm/resource_resolver.go @@ -0,0 +1,101 @@ +package arm + +// Code to resolve resources that are required by the API. These resources +// can most likely be resolved without asking the user, thereby reducing the +// amount of configuration they need to provide. +// +// Resource resolver differs from config retriever because resource resolver +// requires a client to communicate with the Azure API. A config retriever is +// used to determine values without use of a client. + +import ( + "fmt" + "strings" +) + +type resourceResolver struct { + client *AzureClient + findVirtualNetworkResourceGroup func(*AzureClient, string) (string, error) + findVirtualNetworkSubnet func(*AzureClient, string, string) (string, error) +} + +func newResourceResolver(client *AzureClient) *resourceResolver { + return &resourceResolver{ + client: client, + findVirtualNetworkResourceGroup: findVirtualNetworkResourceGroup, + findVirtualNetworkSubnet: findVirtualNetworkSubnet, + } +} + +func (s *resourceResolver) Resolve(c *Config) error { + if s.shouldResolveResourceGroup(c) { + resourceGroupName, err := s.findVirtualNetworkResourceGroup(s.client, c.VirtualNetworkName) + if err != nil { + return err + } + + subnetName, err := s.findVirtualNetworkSubnet(s.client, resourceGroupName, c.VirtualNetworkName) + if err != nil { + return err + } + + c.VirtualNetworkResourceGroupName = resourceGroupName + c.VirtualNetworkSubnetName = subnetName + } + + return nil +} + +func (s *resourceResolver) shouldResolveResourceGroup(c *Config) bool { + return c.VirtualNetworkName != "" && c.VirtualNetworkResourceGroupName == "" +} + +func getResourceGroupNameFromId(id string) string { + // "/subscriptions/3f499422-dd76-4114-8859-86d526c9deb6/resourceGroups/packer-Resource-Group-yylnwsl30j/providers/... + xs := strings.Split(id, "/") + return xs[4] +} + +func findVirtualNetworkResourceGroup(client *AzureClient, name string) (string, error) { + virtualNetworks, err := client.VirtualNetworksClient.ListAll() + if err != nil { + return "", err + } + + resourceGroupNames := make([]string, 0) + + for _, virtualNetwork := range *virtualNetworks.Value { + if strings.EqualFold(name, *virtualNetwork.Name) { + rgn := getResourceGroupNameFromId(*virtualNetwork.ID) + resourceGroupNames = append(resourceGroupNames, rgn) + } + } + + if len(resourceGroupNames) == 0 { + return "", fmt.Errorf("Cannot find a resource group with a virtual network called %q", name) + } + + if len(resourceGroupNames) > 1 { + return "", fmt.Errorf("Found multiple resource groups with a virtual network called %q, please use virtual_network_resource_group_name to disambiguate", name) + } + + return resourceGroupNames[0], nil +} + +func findVirtualNetworkSubnet(client *AzureClient, resourceGroupName string, name string) (string, error) { + subnets, err := client.SubnetsClient.List(resourceGroupName, name) + if err != nil { + return "", err + } + + if len(*subnets.Value) == 0 { + return "", fmt.Errorf("Cannot find a subnet in the resource group %q associated with the virtual network called %q", resourceGroupName, name) + } + + if len(*subnets.Value) > 1 { + return "", fmt.Errorf("Found multiple subnets in the resource group %q associated with the virtual network called %q, please use virtual_network_subnet_name to disambiguate", resourceGroupName, name) + } + + subnet := (*subnets.Value)[0] + return *subnet.Name, nil +} diff --git a/builder/azure/arm/resource_resolver_test.go b/builder/azure/arm/resource_resolver_test.go new file mode 100644 index 000000000..f8e339687 --- /dev/null +++ b/builder/azure/arm/resource_resolver_test.go @@ -0,0 +1,76 @@ +package arm + +import ( + "testing" +) + +func TestResourceResolverIgnoresEmptyVirtualNetworkName(t *testing.T) { + c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration()) + if c.VirtualNetworkName != "" { + t.Fatalf("Expected VirtualNetworkName to be empty by default") + } + + sut := newTestResourceResolver() + sut.findVirtualNetworkResourceGroup = nil // assert that this is not even called + sut.Resolve(c) + + if c.VirtualNetworkName != "" { + t.Fatalf("Expected VirtualNetworkName to be empty") + } + if c.VirtualNetworkResourceGroupName != "" { + t.Fatalf("Expected VirtualNetworkResourceGroupName to be empty") + } +} + +// If the user fully specified the virtual network name and resource group then +// there is no need to do a lookup. +func TestResourceResolverIgnoresSetVirtualNetwork(t *testing.T) { + c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration()) + c.VirtualNetworkName = "--virtual-network-name--" + c.VirtualNetworkResourceGroupName = "--virtual-network-resource-group-name--" + c.VirtualNetworkSubnetName = "--virtual-network-subnet-name--" + + sut := newTestResourceResolver() + sut.findVirtualNetworkResourceGroup = nil // assert that this is not even called + sut.findVirtualNetworkSubnet = nil // assert that this is not even called + sut.Resolve(c) + + if c.VirtualNetworkName != "--virtual-network-name--" { + t.Fatalf("Expected VirtualNetworkName to be --virtual-network-name--") + } + if c.VirtualNetworkResourceGroupName != "--virtual-network-resource-group-name--" { + t.Fatalf("Expected VirtualNetworkResourceGroupName to be --virtual-network-resource-group-name--") + } + if c.VirtualNetworkSubnetName != "--virtual-network-subnet-name--" { + t.Fatalf("Expected VirtualNetworkSubnetName to be --virtual-network-subnet-name--") + } +} + +// If the user set virtual network name then the code should resolve virtual network +// resource group name. +func TestResourceResolverSetVirtualNetworkResourceGroupName(t *testing.T) { + c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration()) + c.VirtualNetworkName = "--virtual-network-name--" + + sut := newTestResourceResolver() + sut.Resolve(c) + + if c.VirtualNetworkResourceGroupName != "findVirtualNetworkResourceGroup is mocked" { + t.Fatalf("Expected VirtualNetworkResourceGroupName to be 'findVirtualNetworkResourceGroup is mocked'") + } + if c.VirtualNetworkSubnetName != "findVirtualNetworkSubnet is mocked" { + t.Fatalf("Expected findVirtualNetworkSubnet to be 'findVirtualNetworkSubnet is mocked'") + } +} + +func newTestResourceResolver() resourceResolver { + return resourceResolver{ + client: nil, + findVirtualNetworkResourceGroup: func(*AzureClient, string) (string, error) { + return "findVirtualNetworkResourceGroup is mocked", nil + }, + findVirtualNetworkSubnet: func(*AzureClient, string, string) (string, error) { + return "findVirtualNetworkSubnet is mocked", nil + }, + } +} diff --git a/builder/azure/arm/step_get_ip_address.go b/builder/azure/arm/step_get_ip_address.go index 4b664c4ed..d0b24e82c 100644 --- a/builder/azure/arm/step_get_ip_address.go +++ b/builder/azure/arm/step_get_ip_address.go @@ -11,43 +11,77 @@ import ( "github.com/mitchellh/packer/packer" ) +type EndpointType int + +const ( + PublicEndpoint EndpointType = iota + PrivateEndpoint +) + +var ( + EndpointCommunicationText = map[EndpointType]string{ + PublicEndpoint: "PublicEndpoint", + PrivateEndpoint: "PrivateEndpoint", + } +) + type StepGetIPAddress struct { - client *AzureClient - get func(resourceGroupName string, ipAddressName string) (string, error) - say func(message string) - error func(e error) + client *AzureClient + endpoint EndpointType + get func(resourceGroupName string, ipAddressName string, interfaceName string) (string, error) + say func(message string) + error func(e error) } -func NewStepGetIPAddress(client *AzureClient, ui packer.Ui) *StepGetIPAddress { +func NewStepGetIPAddress(client *AzureClient, ui packer.Ui, endpoint EndpointType) *StepGetIPAddress { var step = &StepGetIPAddress{ - client: client, - say: func(message string) { ui.Say(message) }, - error: func(e error) { ui.Error(e.Error()) }, + client: client, + endpoint: endpoint, + say: func(message string) { ui.Say(message) }, + error: func(e error) { ui.Error(e.Error()) }, + } + + switch endpoint { + case PrivateEndpoint: + step.get = step.getPrivateIP + case PublicEndpoint: + step.get = step.getPublicIP } - step.get = step.getIPAddress return step } -func (s *StepGetIPAddress) getIPAddress(resourceGroupName string, ipAddressName string) (string, error) { - res, err := s.client.PublicIPAddressesClient.Get(resourceGroupName, ipAddressName, "") +func (s *StepGetIPAddress) getPrivateIP(resourceGroupName string, ipAddressName string, interfaceName string) (string, error) { + resp, err := s.client.InterfacesClient.Get(resourceGroupName, interfaceName, "") if err != nil { - return "", nil + return "", err } - return *res.Properties.IPAddress, nil + return *(*resp.Properties.IPConfigurations)[0].Properties.PrivateIPAddress, nil +} + +func (s *StepGetIPAddress) getPublicIP(resourceGroupName string, ipAddressName string, interfaceName string) (string, error) { + resp, err := s.client.PublicIPAddressesClient.Get(resourceGroupName, ipAddressName, "") + if err != nil { + return "", err + } + + return *resp.Properties.IPAddress, nil } func (s *StepGetIPAddress) Run(state multistep.StateBag) multistep.StepAction { - s.say("Getting the public IP address ...") + s.say("Getting the VM's IP address ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) var ipAddressName = state.Get(constants.ArmPublicIPAddressName).(string) + var nicName = state.Get(constants.ArmNicName).(string) s.say(fmt.Sprintf(" -> ResourceGroupName : '%s'", resourceGroupName)) s.say(fmt.Sprintf(" -> PublicIPAddressName : '%s'", ipAddressName)) + s.say(fmt.Sprintf(" -> NicName : '%s'", nicName)) + s.say(fmt.Sprintf(" -> Network Connection : '%s'", EndpointCommunicationText[s.endpoint])) - address, err := s.get(resourceGroupName, ipAddressName) + address, err := s.get(resourceGroupName, ipAddressName, nicName) if err != nil { state.Put(constants.Error, err) s.error(err) @@ -55,8 +89,8 @@ func (s *StepGetIPAddress) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - s.say(fmt.Sprintf(" -> Public IP : '%s'", address)) state.Put(constants.SSHHost, address) + s.say(fmt.Sprintf(" -> IP Address : '%s'", address)) return multistep.ActionContinue } diff --git a/builder/azure/arm/step_get_ip_address_test.go b/builder/azure/arm/step_get_ip_address_test.go index 8f35ad8da..d6e29a2d7 100644 --- a/builder/azure/arm/step_get_ip_address_test.go +++ b/builder/azure/arm/step_get_ip_address_test.go @@ -13,9 +13,10 @@ import ( func TestStepGetIPAddressShouldFailIfGetFails(t *testing.T) { var testSubject = &StepGetIPAddress{ - get: func(string, string) (string, error) { return "", fmt.Errorf("!! Unit Test FAIL !!") }, - say: func(message string) {}, - error: func(e error) {}, + get: func(string, string, string) (string, error) { return "", fmt.Errorf("!! Unit Test FAIL !!") }, + endpoint: PublicEndpoint, + say: func(message string) {}, + error: func(e error) {}, } stateBag := createTestStateBagStepGetIPAddress() @@ -32,9 +33,10 @@ func TestStepGetIPAddressShouldFailIfGetFails(t *testing.T) { func TestStepGetIPAddressShouldPassIfGetPasses(t *testing.T) { var testSubject = &StepGetIPAddress{ - get: func(string, string) (string, error) { return "", nil }, - say: func(message string) {}, - error: func(e error) {}, + get: func(string, string, string) (string, error) { return "", nil }, + endpoint: PublicEndpoint, + say: func(message string) {}, + error: func(e error) {}, } stateBag := createTestStateBagStepGetIPAddress() @@ -52,16 +54,19 @@ func TestStepGetIPAddressShouldPassIfGetPasses(t *testing.T) { func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { var actualResourceGroupName string var actualIPAddressName string + var actualNicName string var testSubject = &StepGetIPAddress{ - get: func(resourceGroupName string, ipAddressName string) (string, error) { + get: func(resourceGroupName string, ipAddressName string, nicName string) (string, error) { actualResourceGroupName = resourceGroupName actualIPAddressName = ipAddressName + actualNicName = nicName return "127.0.0.1", nil }, - say: func(message string) {}, - error: func(e error) {}, + endpoint: PublicEndpoint, + say: func(message string) {}, + error: func(e error) {}, } stateBag := createTestStateBagStepGetIPAddress() @@ -73,6 +78,7 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { var expectedResourceGroupName = stateBag.Get(constants.ArmResourceGroupName).(string) var expectedIPAddressName = stateBag.Get(constants.ArmPublicIPAddressName).(string) + var expectedNicName = stateBag.Get(constants.ArmNicName).(string) if actualIPAddressName != expectedIPAddressName { t.Fatal("Expected StepGetIPAddress to source 'constants.ArmIPAddressName' from the state bag, but it did not.") @@ -82,6 +88,10 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { t.Fatal("Expected StepGetIPAddress to source 'constants.ArmResourceGroupName' from the state bag, but it did not.") } + if actualNicName != expectedNicName { + t.Fatalf("Expected StepGetIPAddress to source 'constants.ArmNetworkInterfaceName' from the state bag, but it did not.") + } + expectedIPAddress, ok := stateBag.GetOk(constants.SSHHost) if !ok { t.Fatalf("Expected the state bag to have a value for '%s', but it did not.", constants.SSHHost) @@ -96,6 +106,7 @@ func createTestStateBagStepGetIPAddress() multistep.StateBag { stateBag := new(multistep.BasicStateBag) stateBag.Put(constants.ArmPublicIPAddressName, "Unit Test: PublicIPAddressName") + stateBag.Put(constants.ArmNicName, "Unit Test: NicName") stateBag.Put(constants.ArmResourceGroupName, "Unit Test: ResourceGroupName") return stateBag diff --git a/builder/azure/arm/template_factory.go b/builder/azure/arm/template_factory.go index ca0f95fb2..31faa797f 100644 --- a/builder/azure/arm/template_factory.go +++ b/builder/azure/arm/template_factory.go @@ -51,6 +51,13 @@ func GetVirtualMachineDeployment(config *Config) (*resources.Deployment, error) builder.SetMarketPlaceImage(config.ImagePublisher, config.ImageOffer, config.ImageSku, config.ImageVersion) } + if config.VirtualNetworkName != "" { + builder.SetVirtualNetwork( + config.VirtualNetworkResourceGroupName, + config.VirtualNetworkName, + config.VirtualNetworkSubnetName) + } + doc, _ := builder.ToJSON() return createDeploymentParameters(*doc, params) } diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json index a6fce9d67..e0d7b10bb 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment03.approved.json @@ -154,7 +154,8 @@ "subnetName": "packerSubnet", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } + "virtualNetworkResourceGroup": "[resourceGroup().name]", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json index 74a4b767f..faa51be82 100644 --- a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment04.approved.json @@ -152,7 +152,8 @@ "subnetName": "packerSubnet", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } + "virtualNetworkResourceGroup": "[resourceGroup().name]", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json new file mode 100644 index 000000000..ae13afab1 --- /dev/null +++ b/builder/azure/arm/template_factory_test.TestVirtualMachineDeployment05.approved.json @@ -0,0 +1,120 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "image": { + "uri": "https://localhost/custom.vhd" + }, + "name": "osdisk", + "osType": "Linux", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "virtualNetworkSubnetName", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "virtualNetworkName", + "virtualNetworkResourceGroup": "virtualNetworkResourceGroupName", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } +} \ No newline at end of file diff --git a/builder/azure/arm/template_factory_test.go b/builder/azure/arm/template_factory_test.go index 4ab976f9c..708d7f379 100644 --- a/builder/azure/arm/template_factory_test.go +++ b/builder/azure/arm/template_factory_test.go @@ -145,6 +145,38 @@ func TestVirtualMachineDeployment04(t *testing.T) { } } +func TestVirtualMachineDeployment05(t *testing.T) { + config := map[string]string{ + "capture_name_prefix": "ignore", + "capture_container_name": "ignore", + "location": "ignore", + "image_url": "https://localhost/custom.vhd", + "resource_group_name": "ignore", + "storage_account": "ignore", + "subscription_id": "ignore", + "os_type": constants.Target_Linux, + "communicator": "none", + "virtual_network_name": "virtualNetworkName", + "virtual_network_resource_group_name": "virtualNetworkResourceGroupName", + "virtual_network_subnet_name": "virtualNetworkSubnetName", + } + + c, _, err := newConfig(config, getPackerConfiguration()) + if err != nil { + t.Fatal(err) + } + + deployment, err := GetVirtualMachineDeployment(c) + if err != nil { + t.Fatal(err) + } + + err = approvaltests.VerifyJSONStruct(t, deployment.Properties.Template) + if err != nil { + t.Fatal(err) + } +} + // Ensure the link values are not set, and the concrete values are set. func TestKeyVaultDeployment00(t *testing.T) { c, _, _ := newConfig(getArmBuilderConfiguration(), getPackerConfiguration()) diff --git a/builder/azure/common/constants/stateBag.go b/builder/azure/common/constants/stateBag.go index 25451967d..0955994e6 100644 --- a/builder/azure/common/constants/stateBag.go +++ b/builder/azure/common/constants/stateBag.go @@ -18,6 +18,7 @@ const ( ArmComputeName string = "arm.ComputeName" ArmCertificateUrl string = "arm.CertificateUrl" ArmDeploymentName string = "arm.DeploymentName" + ArmNicName string = "arm.NicName" ArmKeyVaultName string = "arm.KeyVaultName" ArmLocation string = "arm.Location" ArmOSDiskVhd string = "arm.OSDiskVhd" diff --git a/builder/azure/common/template/TestBuildLinux02.approved.txt b/builder/azure/common/template/TestBuildLinux02.approved.txt new file mode 100644 index 000000000..c2533dd2d --- /dev/null +++ b/builder/azure/common/template/TestBuildLinux02.approved.txt @@ -0,0 +1,120 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "--subnet-name--", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "--virtual-network--", + "virtualNetworkResourceGroup": "--virtual-network-resource-group--", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "name": "[variables('nicName')]", + "type": "Microsoft.Network/networkInterfaces", + "location": "[variables('location')]", + "dependsOn": [], + "properties": { + "ipConfigurations": [ + { + "properties": { + "privateIPAllocationMethod": "Dynamic", + "subnet": { + "id": "[variables('subnetRef')]" + } + }, + "name": "ipconfig" + } + ] + } + }, + { + "apiVersion": "[variables('apiVersion')]", + "name": "[parameters('vmName')]", + "type": "Microsoft.Compute/virtualMachines", + "location": "[variables('location')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "computerName": "[parameters('vmName')]", + "adminUsername": "[parameters('adminUsername')]", + "adminPassword": "[parameters('adminPassword')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "path": "[variables('sshKeyPath')]", + "keyData": "--test-ssh-authorized-key--" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "osType": "Linux", + "name": "osdisk", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + }, + "image": { + "uri": "http://azure/custom.vhd" + }, + "caching": "ReadWrite", + "createOption": "FromImage" + } + } + } + } + ] +} \ No newline at end of file diff --git a/builder/azure/common/template/template_builder.go b/builder/azure/common/template/template_builder.go index d69d782e7..c8cecfcab 100644 --- a/builder/azure/common/template/template_builder.go +++ b/builder/azure/common/template/template_builder.go @@ -13,8 +13,11 @@ const ( jsonPrefix = "" jsonIndent = " " - resourceVirtualMachine = "Microsoft.Compute/virtualMachines" - resourceKeyVaults = "Microsoft.KeyVault/vaults" + resourceKeyVaults = "Microsoft.KeyVault/vaults" + resourceNetworkInterfaces = "Microsoft.Network/networkInterfaces" + resourcePublicIPAddresses = "Microsoft.Network/publicIPAddresses" + resourceVirtualMachine = "Microsoft.Compute/virtualMachines" + resourceVirtualNetworks = "Microsoft.Network/virtualNetworks" variableSshKeyPath = "sshKeyPath" ) @@ -125,6 +128,28 @@ func (s *TemplateBuilder) SetImageUrl(imageUrl string, osType compute.OperatingS return nil } +func (s *TemplateBuilder) SetVirtualNetwork(virtualNetworkResourceGroup, virtualNetworkName, subnetName string) error { + s.setVariable("virtualNetworkResourceGroup", virtualNetworkResourceGroup) + s.setVariable("virtualNetworkName", virtualNetworkName) + s.setVariable("subnetName", subnetName) + + s.deleteResourceByType(resourceVirtualNetworks) + s.deleteResourceByType(resourcePublicIPAddresses) + resource, err := s.getResourceByType(resourceNetworkInterfaces) + if err != nil { + return err + } + + s.deleteResourceDependency(resource, func(s string) bool { + return strings.Contains(s, "Microsoft.Network/virtualNetworks") || + strings.Contains(s, "Microsoft.Network/publicIPAddresses") + }) + + (*resource.Properties.IPConfigurations)[0].Properties.PublicIPAddress = nil + + return nil +} + func (s *TemplateBuilder) ToJSON() (*string, error) { bs, err := json.MarshalIndent(s.template, jsonPrefix, jsonIndent) @@ -144,6 +169,10 @@ func (s *TemplateBuilder) getResourceByType(t string) (*Resource, error) { return nil, fmt.Errorf("template: could not find a resource of type %s", t) } +func (s *TemplateBuilder) setVariable(name string, value string) { + (*s.template.Variables)[name] = value +} + func (s *TemplateBuilder) toKeyVaultID(name string) string { return s.toResourceID(resourceKeyVaults, name) } @@ -156,6 +185,31 @@ func (s *TemplateBuilder) toVariable(name string) string { return fmt.Sprintf("[variables('%s')]", name) } +func (s *TemplateBuilder) deleteResourceByType(resourceType string) { + resources := make([]Resource, 0) + + for _, resource := range *s.template.Resources { + if *resource.Type == resourceType { + continue + } + resources = append(resources, resource) + } + + s.template.Resources = &resources +} + +func (s *TemplateBuilder) deleteResourceDependency(resource *Resource, predicate func(string) bool) { + deps := make([]string, 0) + + for _, dep := range *resource.DependsOn { + if !predicate(dep) { + deps = append(deps, dep) + } + } + + *resource.DependsOn = deps +} + const basicTemplate = `{ "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", "contentVersion": "1.0.0.0", @@ -194,8 +248,9 @@ const basicTemplate = `{ "subnetAddressPrefix": "10.0.0.0/24", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", + "virtualNetworkResourceGroup": "[resourceGroup().name]", "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" }, "resources": [ { diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json index a8ecfc0be..59b5da643 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux00.approved.json @@ -154,7 +154,8 @@ "subnetName": "packerSubnet", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } + "virtualNetworkResourceGroup": "[resourceGroup().name]", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json index 45bf5b271..f26c3f1c2 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux01.approved.json @@ -152,7 +152,8 @@ "subnetName": "packerSubnet", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } + "virtualNetworkResourceGroup": "[resourceGroup().name]", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json b/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json new file mode 100644 index 000000000..217c1f415 --- /dev/null +++ b/builder/azure/common/template/template_builder_test.TestBuildLinux02.approved.json @@ -0,0 +1,120 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json", + "contentVersion": "1.0.0.0", + "parameters": { + "adminPassword": { + "type": "string" + }, + "adminUsername": { + "type": "string" + }, + "dnsNameForPublicIP": { + "type": "string" + }, + "osDiskName": { + "type": "string" + }, + "storageAccountBlobEndpoint": { + "type": "string" + }, + "vmName": { + "type": "string" + }, + "vmSize": { + "type": "string" + } + }, + "resources": [ + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [], + "location": "[variables('location')]", + "name": "[variables('nicName')]", + "properties": { + "ipConfigurations": [ + { + "name": "ipconfig", + "properties": { + "privateIPAllocationMethod": "Dynamic", + "subnet": { + "id": "[variables('subnetRef')]" + } + } + } + ] + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "apiVersion": "[variables('apiVersion')]", + "dependsOn": [ + "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" + ], + "location": "[variables('location')]", + "name": "[parameters('vmName')]", + "properties": { + "diagnosticsProfile": { + "bootDiagnostics": { + "enabled": false + } + }, + "hardwareProfile": { + "vmSize": "[parameters('vmSize')]" + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" + } + ] + }, + "osProfile": { + "adminPassword": "[parameters('adminPassword')]", + "adminUsername": "[parameters('adminUsername')]", + "computerName": "[parameters('vmName')]", + "linuxConfiguration": { + "ssh": { + "publicKeys": [ + { + "keyData": "--test-ssh-authorized-key--", + "path": "[variables('sshKeyPath')]" + } + ] + } + } + }, + "storageProfile": { + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "image": { + "uri": "http://azure/custom.vhd" + }, + "name": "osdisk", + "osType": "Linux", + "vhd": { + "uri": "[concat(parameters('storageAccountBlobEndpoint'),variables('vmStorageAccountContainerName'),'/', parameters('osDiskName'),'.vhd')]" + } + } + } + }, + "type": "Microsoft.Compute/virtualMachines" + } + ], + "variables": { + "addressPrefix": "10.0.0.0/16", + "apiVersion": "2015-06-15", + "location": "[resourceGroup().location]", + "nicName": "packerNic", + "publicIPAddressName": "packerPublicIP", + "publicIPAddressType": "Dynamic", + "sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", + "subnetAddressPrefix": "10.0.0.0/24", + "subnetName": "--subnet-name--", + "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", + "virtualNetworkName": "--virtual-network--", + "virtualNetworkResourceGroup": "--virtual-network-resource-group--", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } +} \ No newline at end of file diff --git a/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json index d2460d7b4..67dec1b2d 100644 --- a/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json +++ b/builder/azure/common/template/template_builder_test.TestBuildWindows00.approved.json @@ -168,7 +168,8 @@ "subnetName": "packerSubnet", "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", "virtualNetworkName": "packerNetwork", - "vmStorageAccountContainerName": "images", - "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" - } + "virtualNetworkResourceGroup": "[resourceGroup().name]", + "vmStorageAccountContainerName": "images", + "vnetID": "[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" + } } \ No newline at end of file diff --git a/builder/azure/common/template/template_builder_test.go b/builder/azure/common/template/template_builder_test.go index f203acace..1097eab8b 100644 --- a/builder/azure/common/template/template_builder_test.go +++ b/builder/azure/common/template/template_builder_test.go @@ -64,6 +64,32 @@ func TestBuildLinux01(t *testing.T) { } } +// Ensure that a user can specify an existing Virtual Network +func TestBuildLinux02(t *testing.T) { + testSubject, err := NewTemplateBuilder() + if err != nil { + t.Fatal(err) + } + + testSubject.BuildLinux("--test-ssh-authorized-key--") + testSubject.SetImageUrl("http://azure/custom.vhd", compute.Linux) + + err = testSubject.SetVirtualNetwork("--virtual-network-resource-group--", "--virtual-network--", "--subnet-name--") + if err != nil { + t.Fatal(err) + } + + doc, err := testSubject.ToJSON() + if err != nil { + t.Fatal(err) + } + + err = approvaltests.VerifyJSONBytes(t, []byte(*doc)) + if err != nil { + t.Fatal(err) + } +} + // Ensure that a Windows template is configured as expected. // * Include WinRM configuration. // * Include KeyVault configuration, which is needed for WinRM. diff --git a/website/source/docs/builders/azure.html.md b/website/source/docs/builders/azure.html.md index adc5655b8..71b6006db 100644 --- a/website/source/docs/builders/azure.html.md +++ b/website/source/docs/builders/azure.html.md @@ -83,6 +83,19 @@ builder. configures your Tenant ID, Object ID, Key Vault Name, Key Vault Secret, and WinRM certificate URL. +- `virtual_network_name` (string) Use a pre-existing virtual network for the VM. This option enables private + communication with the VM, no public IP address is **used** or **provisioned**. This value should only be set if + Packer is executed from a host on the same subnet / virtual network. + +- `virtual_network_resource_group_name` (string) If virtual_network_name is set, this value **may** also be set. If + virtual_network_name is set, and this value is not set the builder attempts to determine the resource group + containing the virtual network. If the resource group cannot be found, or it cannot be disambiguated, this value + should be set. + +- `virtual_network_subnet_name` (string) If virtual_network_name is set, this value **may** also be set. If + virtual_network_name is set, and this value is not set the builder attempts to determine the subnet to use with + the virtual network. If the subnet cannot be found, or it cannot be disambiguated, this value should be set. + - `vm_size` (string) Size of the VM used for building. This can be changed when you deploy a VM from your VHD. See [pricing](https://azure.microsoft.com/en-us/pricing/details/virtual-machines/) information. Defaults to `Standard_A1`. From 644b11805df9131248f1752b34ee3104b8bfdac5 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Sat, 30 Jul 2016 17:10:16 -0700 Subject: [PATCH 31/31] Fix go vet casing issue --- post-processor/vagrant-cloud/post-processor_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/post-processor/vagrant-cloud/post-processor_test.go b/post-processor/vagrant-cloud/post-processor_test.go index ff99314c4..985df88cc 100644 --- a/post-processor/vagrant-cloud/post-processor_test.go +++ b/post-processor/vagrant-cloud/post-processor_test.go @@ -2,8 +2,9 @@ package vagrantcloud import ( "bytes" - "github.com/mitchellh/packer/packer" "testing" + + "github.com/mitchellh/packer/packer" ) func testGoodConfig() map[string]interface{} { @@ -48,7 +49,7 @@ func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { var _ packer.PostProcessor = new(PostProcessor) } -func TestproviderFromBuilderName(t *testing.T) { +func TestProviderFromBuilderName(t *testing.T) { if providerFromBuilderName("foobar") != "foobar" { t.Fatal("should copy unknown provider") }