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

Commit e515ec9

Browse files
author
Jonathan Chauncey
committed
fix(Get-AzureConstants.py): remove the date string from the header
* add test to circle config * add make target to run test in test.mk * add script that executes the test update azure-const.sh to do an azure login add client_id and client_secret vars to test run
1 parent 8d04677 commit e515ec9

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

.circleci/config.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ jobs:
1313
GOPATH: /go
1414
steps:
1515
- checkout
16-
- run: echo 'export PATH=$GOPATH/bin:$PATH' >> $BASH_ENV
16+
- run: |
17+
echo 'export PATH=$GOPATH/bin:$PATH' >> $BASH_ENV
18+
echo 'export CLIENT_ID=${CLUSTER_SERVICE_PRINCIPAL_CLIENT_ID}' >> $BASH_ENV
19+
echo 'export CLIENT_SECRET=${CLUSTER_SERVICE_PRINCIPAL_CLIENT_SECRET}' >> $BASH_ENV
1720
- run:
1821
name: Install dependencies
1922
command: make bootstrap
2023
- run:
2124
name: Run linting rules
2225
command: make test-style
26+
- run:
27+
name: Test Azure Constants
28+
command: make test-azure-constants
2329
- run:
2430
name: Build binaries
2531
command: make build-binary

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ dev:
4848
generate: bootstrap
4949
go generate $(GOFLAGS) -v `glide novendor | xargs go list`
5050

51+
.PHONY: generate-azure-constants
52+
generate-azure-constants:
53+
python pkg/acsengine/Get-AzureConstants.py
54+
5155
.PHONY: build
5256
build: generate
5357
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -ldflags '$(LDFLAGS)'

pkg/acsengine/Get-AzureConstants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def getStorageAccountType(sizeName):
6767
def getFileContents(dcosMasterMap, masterAgentMap, kubernetesAgentMap, sizeMap, locations):
6868
text = r"""package acsengine
6969
70-
// AUTOGENERATED FILE - last generated """ + time
70+
// AUTOGENERATED FILE """
7171

7272
text += r"""
7373

pkg/acsengine/azureconst.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package acsengine
22

3-
// AUTOGENERATED FILE - last generated 2017-10-26 03:04:32
3+
// AUTOGENERATED FILE
44

55
// AzureLocations provides all azure regions in prod.
66
// Related powershell to refresh this list:

scripts/azure-const.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
if [ -z "$CLIENT_ID" ]; then
3+
echo "must provide a CLIENT_ID env var"
4+
exit 1;
5+
fi
6+
7+
if [ -z "$CLIENT_SECRET" ]; then
8+
echo "must provide a CLIENT_SECRET env var"
9+
exit 1;
10+
fi
11+
12+
if [ -z "$TENANT_ID" ]; then
13+
echo "must provide a TENANT_ID env var"
14+
exit 1;
15+
fi
16+
17+
if [ -z "$SUBSCRIPTION_ID" ]; then
18+
echo "must provide a SUBSCRIPTION_ID env var"
19+
exit 1;
20+
fi
21+
22+
az login --service-principal \
23+
--username "${CLIENT_ID}" \
24+
--password "${CLIENT_SECRET}" \
25+
--tenant "${TENANT_ID}" &>/dev/null
26+
27+
# set to the sub id we want to cleanup
28+
az account set -s $SUBSCRIPTION_ID
29+
30+
python pkg/acsengine/Get-AzureConstants.py
31+
git status | grep pkg/acsengine/azureconst.go
32+
exit_code=$?
33+
if [ $exit_code -gt "0" ]; then
34+
echo "No modifications found! Exiting 0"
35+
exit 0
36+
else
37+
echo "File was modified! Exiting 1"
38+
exit 1
39+
fi

test.mk

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ test-kubernetes:
2626
@ORCHESTRATOR=kubernetes go run ./test/e2e/runner.go
2727

2828
test-dcos:
29-
@ORCHESTRATOR=dcos go run ./test/e2e/runner.go
29+
@ORCHESTRATOR=dcos go run ./test/e2e/runner.go
30+
31+
test-azure-constants:
32+
./scripts/azure-const.sh

0 commit comments

Comments
 (0)