-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables live-tests on Azure-Pipeline for keyvault (#273)
* Update livetest.yml
- Loading branch information
1 parent
13286d0
commit 587488a
Showing
6 changed files
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
jobs: | ||
- job: | ||
pool: | ||
vmImage: 'Ubuntu 18.04' | ||
steps: | ||
- template: steps/init_workspace.yml | ||
- template: steps/live_test.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
steps: | ||
- script: | | ||
go test -count=1 -v ./keyvault/ | ||
displayName: 'Live Test' | ||
env: | ||
AZURE_AUTH_LOCATION: $(AZURE_AUTH_LOCATION) | ||
AZURE_BASE_GROUP_NAME: $(AZURE_BASE_GROUP_NAME) | ||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID) | ||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET) | ||
AZURE_TENANT_ID: $(AZURE_TENANT_ID) | ||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) | ||
AZURE_LOCATION_DEFAULT: $(AZURE_LOCATION_DEFAULT) | ||
AZURE_SAMPLES_KEEP_RESOURCES: $(AZURE_SAMPLES_KEEP_RESOURCES) | ||
AZURE_USE_DEVICEFLOW: $(AZURE_USE_DEVICEFLOW) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,46 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/Azure/go-autorest/autorest/azure" | ||
"github.com/gobuffalo/envy" | ||
) | ||
|
||
// ParseEnvironment loads a sibling `.env` file then looks through all environment | ||
// variables to set global configuration. | ||
func ParseEnvironment() error { | ||
if err := envy.Load(); err != nil { | ||
return err | ||
} | ||
azureEnv, _ := azure.EnvironmentFromName("AzurePublicCloud") // shouldn't fail | ||
authorizationServerURL = azureEnv.ActiveDirectoryEndpoint | ||
|
||
// AZURE_GROUP_NAME and `config.GroupName()` are deprecated. | ||
// Use AZURE_BASE_GROUP_NAME and `config.GenerateGroupName()` instead. | ||
groupName = envy.Get("AZURE_GROUP_NAME", "azure-go-samples") | ||
baseGroupName = envy.Get("AZURE_BASE_GROUP_NAME", groupName) | ||
groupName = os.Getenv("AZURE_GROUP_NAME") | ||
baseGroupName = os.Getenv("AZURE_BASE_GROUP_NAME") | ||
|
||
locationDefault = envy.Get("AZURE_LOCATION_DEFAULT", "westus2") | ||
locationDefault = os.Getenv("AZURE_LOCATION_DEFAULT") | ||
|
||
var err error | ||
useDeviceFlow, err = strconv.ParseBool(envy.Get("AZURE_USE_DEVICEFLOW", "0")) | ||
useDeviceFlow, err = strconv.ParseBool(os.Getenv("AZURE_USE_DEVICEFLOW")) | ||
if err != nil { | ||
log.Printf("invalid value specified for AZURE_USE_DEVICEFLOW, disabling\n") | ||
useDeviceFlow = false | ||
} | ||
keepResources, err = strconv.ParseBool(envy.Get("AZURE_SAMPLES_KEEP_RESOURCES", "0")) | ||
keepResources, err = strconv.ParseBool(os.Getenv("AZURE_SAMPLES_KEEP_RESOURCES")) | ||
if err != nil { | ||
log.Printf("invalid value specified for AZURE_SAMPLES_KEEP_RESOURCES, discarding\n") | ||
keepResources = false | ||
} | ||
|
||
// these must be provided by environment | ||
// clientID | ||
clientID, err = envy.MustGet("AZURE_CLIENT_ID") | ||
if err != nil { | ||
return fmt.Errorf("expected env vars not provided: %+v", err) | ||
} | ||
clientID = os.Getenv("AZURE_CLIENT_ID") | ||
|
||
// clientSecret | ||
clientSecret, err = envy.MustGet("AZURE_CLIENT_SECRET") | ||
if err != nil && !useDeviceFlow { // don't need a secret for device flow | ||
return fmt.Errorf("expected env vars not provided: %+v", err) | ||
} | ||
clientSecret = os.Getenv("AZURE_CLIENT_SECRET") | ||
|
||
// tenantID (AAD) | ||
tenantID, err = envy.MustGet("AZURE_TENANT_ID") | ||
if err != nil { | ||
return fmt.Errorf("expected env vars not provided: %+v", err) | ||
} | ||
tenantID = os.Getenv("AZURE_TENANT_ID") | ||
|
||
// subscriptionID (ARM) | ||
subscriptionID, err = envy.MustGet("AZURE_SUBSCRIPTION_ID") | ||
if err != nil { | ||
return fmt.Errorf("expected env vars not provided: %+v", err) | ||
} | ||
subscriptionID = os.Getenv("AZURE_SUBSCRIPTION_ID") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters