Skip to content

Commit

Permalink
Add azureusgovernment to environment list, fix Makefile (#695)
Browse files Browse the repository at this point in the history
* Add azureusgovernment to environment list, fix Makefile

* add support for AZURECLOUD

Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
  • Loading branch information
rguptar and jhendrixMSFT committed Apr 21, 2022
1 parent f9a841b commit 7525a9b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 24 deletions.
23 changes: 0 additions & 23 deletions GNUmakefile

This file was deleted.

17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DIR?=./autorest/

default: build

build: fmt
cd $(DIR); go install

test:
cd $(DIR); go test -v

vet:
cd $(DIR); go vet

fmt:
gofmt -w $(DIR)

.PHONY: build test vet fmt
4 changes: 3 additions & 1 deletion autorest/azure/environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ const (
var environments = map[string]Environment{
"AZURECHINACLOUD": ChinaCloud,
"AZUREGERMANCLOUD": GermanCloud,
"AZURECLOUD": PublicCloud,
"AZUREPUBLICCLOUD": PublicCloud,
"AZUREUSGOVERNMENTCLOUD": USGovernmentCloud,
"AZUREUSGOVERNMENT": USGovernmentCloud,
"AZUREUSGOVERNMENTCLOUD": USGovernmentCloud, //TODO: deprecate
}

// ResourceIdentifier contains a set of Azure resource IDs.
Expand Down
15 changes: 15 additions & 0 deletions autorest/azure/environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ func TestEnvironmentFromName(t *testing.T) {
t.Errorf("Expected to get GermanCloud for %q", name)
}

name = "AzureCloud"
if env, _ := EnvironmentFromName(name); env != PublicCloud {
t.Errorf("Expected to get PublicCloud for %q", name)
}

name = "azurepubliccloud"
if env, _ := EnvironmentFromName(name); env != PublicCloud {
t.Errorf("Expected to get PublicCloud for %q", name)
Expand All @@ -196,6 +201,16 @@ func TestEnvironmentFromName(t *testing.T) {
t.Errorf("Expected to get USGovernmentCloud for %q", name)
}

name = "azureusgovernment"
if env, _ := EnvironmentFromName(name); env != USGovernmentCloud {
t.Errorf("Expected to get USGovernmentCloud for %q", name)
}

name = "AzureUSGovernment"
if env, _ := EnvironmentFromName(name); env != USGovernmentCloud {
t.Errorf("Expected to get USGovernmentCloud for %q", name)
}

name = "thisisnotarealcloudenv"
if _, err := EnvironmentFromName(name); err == nil {
t.Errorf("Expected to get an error for %q", name)
Expand Down

0 comments on commit 7525a9b

Please sign in to comment.