diff --git a/.gitignore b/.gitignore index 613a8412cff..08847fe3378 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ cover.html coverage.json coverage.xml testlogs.txt +.DS_Store # Kubernetes Generated files - skip generated files, except for vendored files @@ -32,3 +33,4 @@ testlogs.txt __debug_bin .vscode .devcontainer +.DS_Store \ No newline at end of file diff --git a/api/v1/eventhub_types.go b/api/v1/eventhub_types.go index 100a3d9754c..648a4ca916e 100644 --- a/api/v1/eventhub_types.go +++ b/api/v1/eventhub_types.go @@ -16,7 +16,7 @@ limitations under the License. package v1 import ( - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/api/v1/eventhub_webhook.go b/api/v1/eventhub_webhook.go index 7b93bc273b8..363ea839e10 100644 --- a/api/v1/eventhub_webhook.go +++ b/api/v1/eventhub_webhook.go @@ -1,7 +1,7 @@ package v1 import ( - eventhubsmanager "github.com/Azure/azure-service-operator/resourcemanager/eventhubs" + eventhubsmanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/eventhubs" "golang.org/x/net/context" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" diff --git a/api/v1/eventhubnamespace_types.go b/api/v1/eventhubnamespace_types.go index 93e6861c8af..e2687c8243d 100644 --- a/api/v1/eventhubnamespace_types.go +++ b/api/v1/eventhubnamespace_types.go @@ -16,7 +16,7 @@ limitations under the License. package v1 import ( - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/api/v1/eventhubnamespace_webhook.go b/api/v1/eventhubnamespace_webhook.go index 903fc0cd7d3..99c45653754 100644 --- a/api/v1/eventhubnamespace_webhook.go +++ b/api/v1/eventhubnamespace_webhook.go @@ -1,7 +1,7 @@ package v1 import ( - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" "golang.org/x/net/context" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" diff --git a/api/v1/resourcegroup_types.go b/api/v1/resourcegroup_types.go index 2b2eca209e4..02b93849435 100644 --- a/api/v1/resourcegroup_types.go +++ b/api/v1/resourcegroup_types.go @@ -16,7 +16,7 @@ limitations under the License. package v1 import ( - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/controllers/eventhub_controller.go b/controllers/eventhub_controller.go index 4ed5b266102..1252a8112d9 100644 --- a/controllers/eventhub_controller.go +++ b/controllers/eventhub_controller.go @@ -24,7 +24,7 @@ import ( model "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" azurev1 "github.com/Azure/azure-service-operator/api/v1" - eventhubsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/eventhubs" + eventhubsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/eventhubs" "github.com/go-logr/logr" v1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/eventhub_controller_test.go b/controllers/eventhub_controller_test.go index 57016b1f494..bd0d89a9b98 100644 --- a/controllers/eventhub_controller_test.go +++ b/controllers/eventhub_controller_test.go @@ -20,8 +20,8 @@ import ( "time" azurev1 "github.com/Azure/azure-service-operator/api/v1" - helpers "github.com/Azure/azure-service-operator/helpers" - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" . "github.com/onsi/ginkgo" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/controllers/eventhubnamespace_controller.go b/controllers/eventhubnamespace_controller.go index ccf5308273e..a032562ca1c 100644 --- a/controllers/eventhubnamespace_controller.go +++ b/controllers/eventhubnamespace_controller.go @@ -23,7 +23,7 @@ import ( "time" azurev1 "github.com/Azure/azure-service-operator/api/v1" - eventhubsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/eventhubs" + eventhubsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/eventhubs" "github.com/go-logr/logr" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" diff --git a/controllers/eventhubnamespace_controller_test.go b/controllers/eventhubnamespace_controller_test.go index f3ed771f66f..9c885b8102d 100644 --- a/controllers/eventhubnamespace_controller_test.go +++ b/controllers/eventhubnamespace_controller_test.go @@ -20,8 +20,8 @@ import ( "time" azurev1 "github.com/Azure/azure-service-operator/api/v1" - helpers "github.com/Azure/azure-service-operator/helpers" - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/controllers/resourcegroup_controller.go b/controllers/resourcegroup_controller.go index 5d2b2a4b0cd..499ca780519 100644 --- a/controllers/resourcegroup_controller.go +++ b/controllers/resourcegroup_controller.go @@ -22,7 +22,7 @@ import ( "time" azurev1 "github.com/Azure/azure-service-operator/api/v1" - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" "context" diff --git a/controllers/resourcegroup_controller_test.go b/controllers/resourcegroup_controller_test.go index 8a28e37de00..a9ec25a2eb0 100644 --- a/controllers/resourcegroup_controller_test.go +++ b/controllers/resourcegroup_controller_test.go @@ -21,9 +21,9 @@ import ( "time" azurev1 "github.com/Azure/azure-service-operator/api/v1" - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" - //resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + //resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 9be0f70a23e..ebe01e336d2 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -21,7 +21,7 @@ import ( "testing" azurev1 "github.com/Azure/azure-service-operator/api/v1" - resourcemanagerconfig "github.com/Azure/azure-service-operator/resourcemanager/config" + resourcemanagerconfig "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" diff --git a/go.mod b/go.mod index 520b33b96f8..a0fd3d61c2f 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,14 @@ module github.com/Azure/azure-service-operator go 1.12 require ( - github.com/Azure/azure-sdk-for-go v30.1.0+incompatible - github.com/Azure/go-autorest/autorest v0.2.0 - github.com/Azure/go-autorest/autorest/adal v0.1.0 + github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190805235326-79e3f3af791c + github.com/Azure/azure-sdk-for-go v32.0.0+incompatible + github.com/Azure/go-autorest/autorest v0.5.0 + github.com/Azure/go-autorest/autorest/adal v0.2.0 github.com/Azure/go-autorest/autorest/azure/auth v0.1.0 github.com/Azure/go-autorest/autorest/to v0.2.0 github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect + github.com/denisenkom/go-mssqldb v0.0.0-20190724012636-11b2859924c1 github.com/go-logr/logr v0.1.0 github.com/gobuffalo/envy v1.7.0 github.com/gogo/protobuf v1.2.1 // indirect @@ -16,6 +18,7 @@ require ( github.com/google/gofuzz v1.0.0 // indirect github.com/googleapis/gnostic v0.3.0 // indirect github.com/json-iterator/go v1.1.6 // indirect + github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c github.com/modern-go/reflect2 v1.0.1 // indirect github.com/onsi/ginkgo v1.8.0 github.com/onsi/gomega v1.5.0 @@ -24,7 +27,6 @@ require ( golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/sys v0.0.0-20190621203818-d432491b9138 // indirect golang.org/x/text v0.3.2 // indirect - gopkg.in/yaml.v2 v2.2.2 // indirect k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible diff --git a/go.sum b/go.sum index 530c896dbc7..5c03f5c1f11 100644 --- a/go.sum +++ b/go.sum @@ -2,15 +2,26 @@ cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.37.4 h1:glPeL3BQJsbF6aIIYfZizMwc5LTYz250bDMjttbBGAU= +cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw= contrib.go.opencensus.io/exporter/ocagent v0.4.12 h1:jGFvw3l57ViIVEPKKEUXPcLYIXJmQxLUh6ey1eJhwyc= contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA= +github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190717201944-ad38292fb10f/go.mod h1:fHSkenNUlKPxCdWPfkfEubZHu7B3er09X30oJ6db8Fg= +github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190805235326-79e3f3af791c h1:ND9JhvcUO30ENxUh4zfMHom+pszWyFqM5TCbyE/dXnM= +github.com/Azure-Samples/azure-sdk-for-go-samples v0.0.0-20190805235326-79e3f3af791c/go.mod h1:fHSkenNUlKPxCdWPfkfEubZHu7B3er09X30oJ6db8Fg= github.com/Azure/azure-sdk-for-go v30.1.0+incompatible h1:HyYPft8wXpxMd0kfLtXo6etWcO+XuPbLkcgx9g2cqxU= github.com/Azure/azure-sdk-for-go v30.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go v32.0.0+incompatible h1:lkD8YqWFj4DVw65CHwtjOtTnlMD2LLy9z/f8I+BBsVM= +github.com/Azure/azure-sdk-for-go v32.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest/autorest v0.1.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg= github.com/Azure/go-autorest/autorest v0.2.0 h1:zBtSTOQTtjzHVRe+mhkiHvHwRTKHhjBEyo1m6DfI3So= github.com/Azure/go-autorest/autorest v0.2.0/go.mod h1:AKyIcETwSUFxIcs/Wnq/C+kwCtlEYGUVd7FPNb2slmg= +github.com/Azure/go-autorest/autorest v0.5.0 h1:Mlm9qy2fpQ9MvfyI41G2Zf5B4CsgjjNbLOWszfK6KrY= +github.com/Azure/go-autorest/autorest v0.5.0/go.mod h1:9HLKlQjVBH6U3oDfsXOeVc56THsLPw1L03yban4xThw= github.com/Azure/go-autorest/autorest/adal v0.1.0 h1:RSw/7EAullliqwkZvgIGDYZWQm1PGKXI8c4aY/87yuU= github.com/Azure/go-autorest/autorest/adal v0.1.0/go.mod h1:MeS4XhScH55IST095THyTxElntu7WqB7pNbZo8Q5G3E= +github.com/Azure/go-autorest/autorest/adal v0.2.0 h1:7IBDu1jgh+ADHXnEYExkV9RE/ztOOlxdACkkPRthGKw= +github.com/Azure/go-autorest/autorest/adal v0.2.0/go.mod h1:MeS4XhScH55IST095THyTxElntu7WqB7pNbZo8Q5G3E= github.com/Azure/go-autorest/autorest/azure/auth v0.1.0 h1:YgO/vSnJEc76NLw2ecIXvXa8bDWiqf1pOJzARAoZsYU= github.com/Azure/go-autorest/autorest/azure/auth v0.1.0/go.mod h1:Gf7/i2FUpyb/sGBLIFxTBzrNzBo7aPXXE3ZVeDRwdpM= github.com/Azure/go-autorest/autorest/azure/cli v0.1.0 h1:YTtBrcb6mhA+PoSW8WxFDoIIyjp13XqJeX80ssQtri4= @@ -45,6 +56,8 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20190724012636-11b2859924c1 h1:vHTzcl17WBhVXW/KIk2wAoWva7w5WhdNsZtw4caVZZI= +github.com/denisenkom/go-mssqldb v0.0.0-20190724012636-11b2859924c1/go.mod h1:uU0N10vx1abI4qeVe79CxepBP6PPREVTgMS5Gx6/mOk= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= @@ -83,12 +96,14 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7 h1:u4bArs140e9+AfE52mFHOXVFnOSBJBRlzTHrOPLOIhE= github.com/golang/groupcache v0.0.0-20180513044358-24b0969c4cb7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -98,6 +113,9 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeq github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g= github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= @@ -122,6 +140,7 @@ github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswD github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -133,6 +152,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/marstr/collection v1.0.1 h1:j61osRfyny7zxBlLRtoCvOZ2VX7HEyybkZcsLNLJ0z0= +github.com/marstr/collection v1.0.1/go.mod h1:HHDXVxjLO3UYCBXJWY+J/ZrxCUOYqrO66ob1AzIsmYA= +github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c h1:JE+MDz5rhFN5EC9Dj/N8dLYKboTWm6FXeWhnyKVj0vA= +github.com/marstr/randname v0.0.0-20181206212954-d5b0f288ab8c/go.mod h1:Xc224oUXd7/sKMjWKl17cfkYOKQ1S+HSOW7YHEGXauI= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -190,6 +213,8 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.1.0 h1:g0fH8RicVgNl+zVZDCDfbdWxAWoAEJyI7I3TZYXFiig= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -217,6 +242,7 @@ golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk= golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU= @@ -265,10 +291,13 @@ golang.org/x/sys v0.0.0-20190621203818-d432491b9138/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -287,6 +316,8 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 h1:xtNn7qFlagY2mQNFHMSRPjT2RkOV4OXM7P5TVy9xATo= +google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1 h1:TrBcJ1yqAl1G++wO39nD/qtgpsW9/1+QGrluyMGEYgM= @@ -310,6 +341,7 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b h1:aBGgKJUM9Hk/3AE8WaZIApnTxG35kbuQba2w+SXqezo= k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA= diff --git a/main.go b/main.go index 72e4ff0616d..cc34282c9b1 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ import ( azurev1 "github.com/Azure/azure-service-operator/api/v1" "github.com/Azure/azure-service-operator/controllers" - resourcemanagerconfig "github.com/Azure/azure-service-operator/resourcemanager/config" + resourcemanagerconfig "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "k8s.io/apimachinery/pkg/runtime" kscheme "k8s.io/client-go/kubernetes/scheme" diff --git a/helpers/stringhelper.go b/pkg/helpers/stringhelper.go similarity index 100% rename from helpers/stringhelper.go rename to pkg/helpers/stringhelper.go diff --git a/resourcemanager/config/config.go b/pkg/resourcemanager/config/config.go similarity index 50% rename from resourcemanager/config/config.go rename to pkg/resourcemanager/config/config.go index 77b2ca793fa..7b5faa00fdf 100644 --- a/resourcemanager/config/config.go +++ b/pkg/resourcemanager/config/config.go @@ -2,9 +2,11 @@ package config import ( + "bytes" "fmt" "github.com/Azure/go-autorest/autorest/azure" + "github.com/marstr/randname" ) var ( @@ -16,12 +18,15 @@ var ( clientSecret string tenantID string subscriptionID string + locationDefault string authorizationServerURL string cloudName string = "AzurePublicCloud" useDeviceFlow bool - - userAgent string - environment *azure.Environment + keepResources bool + groupName string // deprecated, use baseGroupName instead + baseGroupName string + userAgent string + environment *azure.Environment ) // ClientID is the OAuth client ID. @@ -44,6 +49,19 @@ func SubscriptionID() string { return subscriptionID } +// deprecated: use DefaultLocation() instead +// Location returns the Azure location to be utilized. +func Location() string { + return locationDefault +} + +// DefaultLocation() returns the default location wherein to create new resources. +// Some resource types are not available in all locations so another location might need +// to be chosen. +func DefaultLocation() string { + return locationDefault +} + // AuthorizationServerURL is the OAuth authorization server URL. // Q: Can this be gotten from the `azure.Environment` in `Environment()`? func AuthorizationServerURL() string { @@ -56,12 +74,34 @@ func UseDeviceFlow() bool { return useDeviceFlow } +// deprecated: do not use global group names +// utilize `BaseGroupName()` for a shared prefix +func GroupName() string { + return groupName +} + +// deprecated: we have to set this because we use a global for group names +// once that's fixed this should be removed +func SetGroupName(name string) { + groupName = name +} + +// BaseGroupName() returns a prefix for new groups. +func BaseGroupName() string { + return baseGroupName +} + +// KeepResources() specifies whether to keep resources created by samples. +func KeepResources() bool { + return keepResources +} + // UserAgent() specifies a string to append to the agent identifier. func UserAgent() string { if len(userAgent) > 0 { return userAgent } - return "AzureOperator-resourcemanager" + return "sdk-samples" } // Environment() returns an `azure.Environment{...}` for the current cloud. @@ -78,3 +118,25 @@ func Environment() *azure.Environment { environment = &env return environment } + +// GenerateGroupName leverages BaseGroupName() to return a more detailed name, +// helping to avoid collisions. It appends each of the `affixes` to +// BaseGroupName() separated by dashes, and adds a 5-character random string. +func GenerateGroupName(affixes ...string) string { + // go1.10+ + // import strings + // var b strings.Builder + // b.WriteString(BaseGroupName()) + b := bytes.NewBufferString(BaseGroupName()) + b.WriteRune('-') + for _, affix := range affixes { + b.WriteString(affix) + b.WriteRune('-') + } + return randname.GenerateWithPrefix(b.String(), 5) +} + +// AppendRandomSuffix will append a suffix of five random characters to the specified prefix. +func AppendRandomSuffix(prefix string) string { + return randname.GenerateWithPrefix(prefix, 5) +} diff --git a/resourcemanager/config/env.go b/pkg/resourcemanager/config/env.go similarity index 73% rename from resourcemanager/config/env.go rename to pkg/resourcemanager/config/env.go index 4606e5d5a3f..e25910385cc 100644 --- a/resourcemanager/config/env.go +++ b/pkg/resourcemanager/config/env.go @@ -18,6 +18,13 @@ func LoadSettings() error { 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 = os.Getenv("AZURE_GROUP_NAME") + baseGroupName = os.Getenv("AZURE_BASE_GROUP_NAME") + + locationDefault = os.Getenv("AZURE_LOCATION_DEFAULT") + // these must be provided by environment // clientID clientID = os.Getenv("AZURE_CLIENT_ID") @@ -53,12 +60,24 @@ func ParseEnvironment() error { 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) + + locationDefault = envy.Get("AZURE_LOCATION_DEFAULT", "westus2") + var err error useDeviceFlow, err = strconv.ParseBool(envy.Get("AZURE_USE_DEVICEFLOW", "0")) 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")) + if err != nil { + log.Printf("invalid value specified for AZURE_SAMPLES_KEEP_RESOURCES, discarding\n") + keepResources = false + } // these must be provided by environment // clientID diff --git a/resourcemanager/config/flags.go b/pkg/resourcemanager/config/flags.go similarity index 59% rename from resourcemanager/config/flags.go rename to pkg/resourcemanager/config/flags.go index fd8eb6c68ac..c0a73a1d3fb 100644 --- a/resourcemanager/config/flags.go +++ b/pkg/resourcemanager/config/flags.go @@ -8,8 +8,12 @@ import ( // Remember to call `flag.Parse()` in your main or TestMain. func AddFlags() error { flag.StringVar(&subscriptionID, "subscription", subscriptionID, "Subscription for tests.") + flag.StringVar(&locationDefault, "location", locationDefault, "Default location for tests.") flag.StringVar(&cloudName, "cloud", cloudName, "Name of Azure cloud.") + flag.StringVar(&baseGroupName, "baseGroupName", BaseGroupName(), "Specify prefix name of resource group for sample resources.") + flag.BoolVar(&useDeviceFlow, "useDeviceFlow", useDeviceFlow, "Use device-flow grant type rather than client credentials.") + flag.BoolVar(&keepResources, "keepResources", keepResources, "Keep resources created by samples.") return nil } diff --git a/resourcemanager/eventhubs/hub.go b/pkg/resourcemanager/eventhubs/hub.go similarity index 96% rename from resourcemanager/eventhubs/hub.go rename to pkg/resourcemanager/eventhubs/hub.go index 9cf6ae81607..b1a500e22bd 100644 --- a/resourcemanager/eventhubs/hub.go +++ b/pkg/resourcemanager/eventhubs/hub.go @@ -4,8 +4,8 @@ import ( "context" "fmt" - "github.com/Azure/azure-service-operator/resourcemanager/config" - "github.com/Azure/azure-service-operator/resourcemanager/iam" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/go-autorest/autorest" diff --git a/resourcemanager/eventhubs/hub_test.go b/pkg/resourcemanager/eventhubs/hub_test.go similarity index 97% rename from resourcemanager/eventhubs/hub_test.go rename to pkg/resourcemanager/eventhubs/hub_test.go index 7e1f4aa2fa1..d76c3497826 100644 --- a/resourcemanager/eventhubs/hub_test.go +++ b/pkg/resourcemanager/eventhubs/hub_test.go @@ -21,8 +21,8 @@ import ( "time" model "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" - helpers "github.com/Azure/azure-service-operator/helpers" - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/resourcemanager/eventhubs/namespace.go b/pkg/resourcemanager/eventhubs/namespace.go similarity index 93% rename from resourcemanager/eventhubs/namespace.go rename to pkg/resourcemanager/eventhubs/namespace.go index 6a1ecc84228..9481d19fefe 100644 --- a/resourcemanager/eventhubs/namespace.go +++ b/pkg/resourcemanager/eventhubs/namespace.go @@ -3,8 +3,8 @@ package eventhubs import ( "context" - "github.com/Azure/azure-service-operator/resourcemanager/config" - "github.com/Azure/azure-service-operator/resourcemanager/iam" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/go-autorest/autorest/to" diff --git a/resourcemanager/eventhubs/namespace_test.go b/pkg/resourcemanager/eventhubs/namespace_test.go similarity index 96% rename from resourcemanager/eventhubs/namespace_test.go rename to pkg/resourcemanager/eventhubs/namespace_test.go index 93f5b3c18d9..1c24274135f 100644 --- a/resourcemanager/eventhubs/namespace_test.go +++ b/pkg/resourcemanager/eventhubs/namespace_test.go @@ -20,9 +20,9 @@ import ( "context" "time" - resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/resourcemanager/resourcegroups" + resoucegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/resourcemanager/eventhubs/suite_test.go b/pkg/resourcemanager/eventhubs/suite_test.go similarity index 98% rename from resourcemanager/eventhubs/suite_test.go rename to pkg/resourcemanager/eventhubs/suite_test.go index 4fa3ccd7acb..bd812b6d291 100644 --- a/resourcemanager/eventhubs/suite_test.go +++ b/pkg/resourcemanager/eventhubs/suite_test.go @@ -18,7 +18,7 @@ package eventhubs import ( "testing" - resourcemanagerconfig "github.com/Azure/azure-service-operator/resourcemanager/config" + resourcemanagerconfig "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/resourcemanager/iam/authorizers.go b/pkg/resourcemanager/iam/authorizers.go similarity index 98% rename from resourcemanager/iam/authorizers.go rename to pkg/resourcemanager/iam/authorizers.go index 0d9a603aa59..e2fa7ae8aab 100644 --- a/resourcemanager/iam/authorizers.go +++ b/pkg/resourcemanager/iam/authorizers.go @@ -5,7 +5,7 @@ import ( "net/url" "strings" - "github.com/Azure/azure-service-operator/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/adal" diff --git a/resourcemanager/resourcegroups/resourcegroup.go b/pkg/resourcemanager/resourcegroups/resourcegroup.go similarity index 96% rename from resourcemanager/resourcegroups/resourcegroup.go rename to pkg/resourcemanager/resourcegroups/resourcegroup.go index 18b193002c0..4464165acac 100644 --- a/resourcemanager/resourcegroups/resourcegroup.go +++ b/pkg/resourcemanager/resourcegroups/resourcegroup.go @@ -9,8 +9,8 @@ import ( "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" - "github.com/Azure/azure-service-operator/resourcemanager/config" - "github.com/Azure/azure-service-operator/resourcemanager/iam" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure/auth" diff --git a/resourcemanager/resourcegroups/resourcegroup_test.go b/pkg/resourcemanager/resourcegroups/resourcegroup_test.go similarity index 97% rename from resourcemanager/resourcegroups/resourcegroup_test.go rename to pkg/resourcemanager/resourcegroups/resourcegroup_test.go index 856aef60cee..1a87ef8f621 100644 --- a/resourcemanager/resourcegroups/resourcegroup_test.go +++ b/pkg/resourcemanager/resourcegroups/resourcegroup_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - helpers "github.com/Azure/azure-service-operator/helpers" + helpers "github.com/Azure/azure-service-operator/pkg/helpers" ) var _ = Describe("ResourceGroups", func() { diff --git a/resourcemanager/resourcegroups/suite_test.go b/pkg/resourcemanager/resourcegroups/suite_test.go similarity index 98% rename from resourcemanager/resourcegroups/suite_test.go rename to pkg/resourcemanager/resourcegroups/suite_test.go index c3497db6093..c5d2ed330ce 100644 --- a/resourcemanager/resourcegroups/suite_test.go +++ b/pkg/resourcemanager/resourcegroups/suite_test.go @@ -18,7 +18,7 @@ package resourcegroups import ( "testing" - resourcemanagerconfig "github.com/Azure/azure-service-operator/resourcemanager/config" + resourcemanagerconfig "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/client-go/rest" diff --git a/pkg/resourcemanager/resources/cleanup.go b/pkg/resourcemanager/resources/cleanup.go new file mode 100644 index 00000000000..2344060d6e4 --- /dev/null +++ b/pkg/resourcemanager/resources/cleanup.go @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "log" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" +) + +// Cleanup deletes the rescource group created for the sample +func Cleanup(ctx context.Context) error { + if config.KeepResources() { + log.Println("keeping resources") + return nil + } + log.Println("deleting resources") + _, err := DeleteGroup(ctx, config.GroupName()) + return err +} diff --git a/pkg/resourcemanager/resources/deployment.go b/pkg/resourcemanager/resources/deployment.go new file mode 100644 index 00000000000..e21a446a11f --- /dev/null +++ b/pkg/resourcemanager/resources/deployment.go @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "fmt" + + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" +) + +func getDeploymentsClient() resources.DeploymentsClient { + deployClient := resources.NewDeploymentsClient(config.SubscriptionID()) + a, _ := iam.GetResourceManagementAuthorizer() + deployClient.Authorizer = a + deployClient.AddToUserAgent(config.UserAgent()) + return deployClient +} + +// CreateDeployment creates a template deployment using the +// referenced JSON files for the template and its parameters +func CreateDeployment(ctx context.Context, deploymentName string, template, params *map[string]interface{}) (de resources.DeploymentExtended, err error) { + deployClient := getDeploymentsClient() + future, err := deployClient.CreateOrUpdate( + ctx, + config.GroupName(), + deploymentName, + resources.Deployment{ + Properties: &resources.DeploymentProperties{ + Template: template, + Parameters: params, + Mode: resources.Incremental, + }, + }, + ) + if err != nil { + return de, fmt.Errorf("cannot create deployment: %v", err) + } + + err = future.WaitForCompletionRef(ctx, deployClient.Client) + if err != nil { + return de, fmt.Errorf("cannot get the create deployment future respone: %v", err) + } + + return future.Result(deployClient) +} + +// ValidateDeployment validates the template deployments and their +// parameters are correct and will produce a successful deployment.GetResource +func ValidateDeployment(ctx context.Context, deploymentName string, template, params *map[string]interface{}) (valid resources.DeploymentValidateResult, err error) { + deployClient := getDeploymentsClient() + return deployClient.Validate(ctx, + config.GroupName(), + deploymentName, + resources.Deployment{ + Properties: &resources.DeploymentProperties{ + Template: template, + Parameters: params, + Mode: resources.Incremental, + }, + }) +} diff --git a/pkg/resourcemanager/resources/deployment_test.go b/pkg/resourcemanager/resources/deployment_test.go new file mode 100644 index 00000000000..f936771c349 --- /dev/null +++ b/pkg/resourcemanager/resources/deployment_test.go @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "go/build" + "log" + "path/filepath" + "time" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/util" +) + +func EgCreateTemplateDeployment() { + groupName := config.GenerateGroupName("groups-template") + config.SetGroupName(groupName) // TODO: don't rely on globals + ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) + defer cancel() + defer Cleanup(ctx) + + _, err := CreateGroup(ctx, config.GroupName()) + if err != nil { + util.PrintAndLog(err.Error()) + } + + gopath := build.Default.GOPATH + repo := filepath.Join("github.com", "Azure-Samples", "azure-sdk-for-go-samples") + templateFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "template.json") + parametersFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "parameters.json") + deployName := "VMdeploy" + + template, err := util.ReadJSON(templateFile) + if err != nil { + return + } + params, err := util.ReadJSON(parametersFile) + if err != nil { + return + } + + _, err = ValidateDeployment(ctx, deployName, template, params) + if err != nil { + util.PrintAndLog(err.Error()) + } + util.PrintAndLog("validated VM template deployment") + + _, err = CreateDeployment(ctx, deployName, template, params) + if err != nil { + util.PrintAndLog(err.Error()) + } + util.PrintAndLog("created VM template deployment") + + ipName := (*params)["publicIPAddresses_QuickstartVM_ip_name"].(map[string]interface{})["value"].(string) + vmUser := (*params)["vm_user"].(map[string]interface{})["value"].(string) + vmPass := (*params)["vm_password"].(map[string]interface{})["value"].(string) + + resource, err := GetResource(ctx, + "Microsoft.Network", + "publicIPAddresses", + ipName, + "2018-01-01") + if err != nil { + util.PrintAndLog(err.Error()) + } + util.PrintAndLog("got public IP info via get generic resource") + + log.Printf("Log in with ssh: %s@%s, password: %s", + vmUser, + resource.Properties.(map[string]interface{})["ipAddress"].(string), + vmPass) + + // Output: + // validated VM template deployment + // created VM template deployment + // got public IP info via get generic resource +} diff --git a/pkg/resourcemanager/resources/groups.go b/pkg/resourcemanager/resources/groups.go new file mode 100644 index 00000000000..03a0b869d24 --- /dev/null +++ b/pkg/resourcemanager/resources/groups.go @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "fmt" + "log" + "strings" + "sync" + + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources" + + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/azure/auth" + "github.com/Azure/go-autorest/autorest/to" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" +) + +func getGroupsClient() resources.GroupsClient { + groupsClient := resources.NewGroupsClient(config.SubscriptionID()) + a, err := iam.GetResourceManagementAuthorizer() + if err != nil { + log.Fatalf("failed to initialize authorizer: %v\n", err) + } + groupsClient.Authorizer = a + groupsClient.AddToUserAgent(config.UserAgent()) + return groupsClient +} + +func getGroupsClientWithAuthFile() resources.GroupsClient { + groupsClient := resources.NewGroupsClient(config.SubscriptionID()) + // requires env var AZURE_AUTH_LOCATION set to output of + // `az ad sp create-for-rbac --sdk-auth` + a, err := auth.NewAuthorizerFromFile(azure.PublicCloud.ResourceManagerEndpoint) + if err != nil { + log.Fatalf("failed to initialize authorizer: %v\n", err) + } + groupsClient.Authorizer = a + groupsClient.AddToUserAgent(config.UserAgent()) + return groupsClient +} + +// CreateGroup creates a new resource group named by env var +func CreateGroup(ctx context.Context, groupName string) (resources.Group, error) { + groupsClient := getGroupsClient() + log.Println(fmt.Sprintf("creating resource group '%s' on location: %v", groupName, config.Location())) + return groupsClient.CreateOrUpdate( + ctx, + groupName, + resources.Group{ + Location: to.StringPtr(config.Location()), + }) +} + +// CreateGroupWithAuthFile creates a new resource group. The client authorizer +// is set up based on an auth file created using the Azure CLI. +func CreateGroupWithAuthFile(ctx context.Context, groupName string) (resources.Group, error) { + groupsClient := getGroupsClientWithAuthFile() + log.Println(fmt.Sprintf("creating resource group '%s' on location: %v", groupName, config.Location())) + return groupsClient.CreateOrUpdate( + ctx, + groupName, + resources.Group{ + Location: to.StringPtr(config.Location()), + }) +} + +// DeleteGroup removes the resource group named by env var +func DeleteGroup(ctx context.Context, groupName string) (result resources.GroupsDeleteFuture, err error) { + groupsClient := getGroupsClient() + return groupsClient.Delete(ctx, groupName) +} + +// ListGroups gets an interator that gets all resource groups in the subscription +func ListGroups(ctx context.Context) (resources.GroupListResultIterator, error) { + groupsClient := getGroupsClient() + return groupsClient.ListComplete(ctx, "", nil) +} + +// GetGroup gets info on the resource group in use +func GetGroup(ctx context.Context) (resources.Group, error) { + groupsClient := getGroupsClient() + return groupsClient.Get(ctx, config.GroupName()) +} + +// DeleteAllGroupsWithPrefix deletes all rescource groups that start with a certain prefix +func DeleteAllGroupsWithPrefix(ctx context.Context, prefix string) (futures []resources.GroupsDeleteFuture, groups []string) { + if config.KeepResources() { + log.Println("keeping resource groups") + return + } + for list, err := ListGroups(ctx); list.NotDone(); err = list.Next() { + if err != nil { + log.Fatalf("got error: %s", err) + } + rgName := *list.Value().Name + if strings.HasPrefix(rgName, prefix) { + fmt.Printf("deleting group '%s'\n", rgName) + future, err := DeleteGroup(ctx, rgName) + if err != nil { + log.Fatalf("got error: %s", err) + } + futures = append(futures, future) + groups = append(groups, rgName) + } + } + return +} + +// WaitForDeleteCompletion concurrently waits for delete group operations to finish +func WaitForDeleteCompletion(ctx context.Context, wg *sync.WaitGroup, futures []resources.GroupsDeleteFuture, groups []string) { + for i, f := range futures { + wg.Add(1) + go func(ctx context.Context, future resources.GroupsDeleteFuture, rg string) { + err := future.WaitForCompletionRef(ctx, getGroupsClient().Client) + if err != nil { + log.Fatalf("got error: %s", err) + } else { + fmt.Printf("finished deleting group '%s'\n", rg) + } + wg.Done() + }(ctx, f, groups[i]) + } +} diff --git a/pkg/resourcemanager/resources/hybrid/cleanup.go b/pkg/resourcemanager/resources/hybrid/cleanup.go new file mode 100644 index 00000000000..bd24c55c473 --- /dev/null +++ b/pkg/resourcemanager/resources/hybrid/cleanup.go @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "log" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" +) + +// Cleanup deletes the rescource group created for the sample +func Cleanup(ctx context.Context) error { + if config.KeepResources() { + log.Println("Hybrid resources cleanup: keeping resources") + return nil + } + log.Println("Hybrid resources cleanup: deleting resources") + _, err := DeleteGroup(ctx) + return err +} diff --git a/pkg/resourcemanager/resources/hybrid/groups.go b/pkg/resourcemanager/resources/hybrid/groups.go new file mode 100644 index 00000000000..0f09123b6ff --- /dev/null +++ b/pkg/resourcemanager/resources/hybrid/groups.go @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/resources" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/to" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" +) + +const ( + errorPrefix = "Cannot create resource group, reason: %v" +) + +func getGroupsClient(activeDirectoryEndpoint, tokenAudience string) resources.GroupsClient { + token, err := iam.GetResourceManagementTokenHybrid( + activeDirectoryEndpoint, tokenAudience) + if err != nil { + log.Fatalf("failed to get token: %v\n", err) + } + + groupsClient := resources.NewGroupsClientWithBaseURI( + config.Environment().ResourceManagerEndpoint, + config.SubscriptionID()) + groupsClient.Authorizer = autorest.NewBearerAuthorizer(token) + groupsClient.AddToUserAgent(config.UserAgent()) + return groupsClient +} + +// CreateGroup creates a new resource group named by env var +func CreateGroup(ctx context.Context) (resources.Group, error) { + groupClient := getGroupsClient( + config.Environment().ActiveDirectoryEndpoint, + config.Environment().TokenAudience) + + return groupClient.CreateOrUpdate(ctx, + config.GroupName(), + resources.Group{ + Location: to.StringPtr(config.Location()), + }, + ) +} + +// DeleteGroup removes the resource group named by env var +func DeleteGroup(ctx context.Context) (result resources.GroupsDeleteFuture, err error) { + groupsClient := getGroupsClient( + config.Environment().ActiveDirectoryEndpoint, + config.Environment().TokenAudience) + + return groupsClient.Delete(ctx, config.GroupName()) +} diff --git a/pkg/resourcemanager/resources/hybrid/resources_test.go b/pkg/resourcemanager/resources/hybrid/resources_test.go new file mode 100644 index 00000000000..b57cb0aa4a1 --- /dev/null +++ b/pkg/resourcemanager/resources/hybrid/resources_test.go @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "flag" + "testing" + "time" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/util" +) + +func setupEnvironment() error { + err1 := config.ParseEnvironment() + err2 := config.AddFlags() + err3 := addLocalConfig() + + for _, err := range []error{err1, err2, err3} { + if err != nil { + return err + } + } + + flag.Parse() + return nil +} + +func addLocalConfig() error { + return nil +} + +func TestGroupsHybrid(t *testing.T) { + err := setupEnvironment() + if err != nil { + t.Fatalf("could not set up environment: %v\n", err) + } + + groupName := config.GenerateGroupName("resource-groups-hybrid") + config.SetGroupName(groupName) // TODO: don't rely on globals + + ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) + defer cancel() + defer Cleanup(ctx) + + _, err = CreateGroup(ctx) + if err != nil { + util.PrintAndLog(err.Error()) + } + util.PrintAndLog("resource group created") + + // Output: + // resource group created +} diff --git a/pkg/resourcemanager/resources/provider.go b/pkg/resourcemanager/resources/provider.go new file mode 100644 index 00000000000..15e2a7ce358 --- /dev/null +++ b/pkg/resourcemanager/resources/provider.go @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" +) + +func getProviderClient() resources.ProvidersClient { + providerClient := resources.NewProvidersClient(config.SubscriptionID()) + a, _ := iam.GetResourceManagementAuthorizer() + providerClient.Authorizer = a + providerClient.AddToUserAgent(config.UserAgent()) + return providerClient +} + +// RegisterProvider registers an azure resource provider for the subscription +func RegisterProvider(ctx context.Context, provider string) (resources.Provider, error) { + providerClient := getProviderClient() + return providerClient.Register(ctx, provider) +} diff --git a/resourcemanager/resources.go b/pkg/resourcemanager/resources/resources.go similarity index 73% rename from resourcemanager/resources.go rename to pkg/resourcemanager/resources/resources.go index 70ce0a6718d..a1a716d4e29 100644 --- a/resourcemanager/resources.go +++ b/pkg/resourcemanager/resources/resources.go @@ -1,3 +1,8 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + package resources import ( @@ -5,11 +10,11 @@ import ( "net/http" "net/url" - "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" + "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-02-01/resources" "github.com/Azure/go-autorest/autorest" - "github.com/Azure/azure-service-operator/resourcemanager/config" - "github.com/Azure/azure-service-operator/resourcemanager/iam" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/iam" ) func getResourcesClient() resources.Client { @@ -44,13 +49,13 @@ func WithAPIVersion(apiVersion string) autorest.PrepareDecorator { // The API version parameter overrides the API version in // the SDK, this is needed because not all resources are // supported on all API versions. -func GetResource(ctx context.Context, resourceProvider, resourceType, resourceName, groupName string, apiVersion string) (resources.GenericResource, error) { +func GetResource(ctx context.Context, resourceProvider, resourceType, resourceName, apiVersion string) (resources.GenericResource, error) { resourcesClient := getResourcesClient() resourcesClient.RequestInspector = WithAPIVersion(apiVersion) return resourcesClient.Get( ctx, - groupName, + config.GroupName(), resourceProvider, "", resourceType, diff --git a/pkg/resourcemanager/resources/resources_test.go b/pkg/resourcemanager/resources/resources_test.go new file mode 100644 index 00000000000..78e1592d9f3 --- /dev/null +++ b/pkg/resourcemanager/resources/resources_test.go @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. + +package resources + +import ( + "context" + "flag" + "log" + "os" + "testing" + "time" + + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" +) + +const ( + CI_KEY_NAME = "TRAVIS" +) + +func TestMain(m *testing.M) { + err := setupEnvironment() + if err != nil { + log.Fatalf("could not set up environment: %v\n", err) + } + + os.Exit(m.Run()) +} + +func setupEnvironment() error { + err1 := config.ParseEnvironment() + err2 := config.AddFlags() + err3 := addLocalConfig() + + for _, err := range []error{err1, err2, err3} { + if err != nil { + return err + } + } + + flag.Parse() + return nil +} + +func addLocalConfig() error { + return nil +} + +func TestGroups(t *testing.T) { + groupName := config.GenerateGroupName("Groups") + config.SetGroupName(groupName) // TODO: don't rely on globals + + ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) + defer cancel() + defer Cleanup(ctx) + + var err error + _, err = CreateGroup(ctx, config.GroupName()) + if err != nil { + t.Fatalf("failed to create group: %v\n", err.Error()) + } + t.Logf("created group: %s\n", config.GroupName()) +} + +func TestGroupsWithAuthFile(t *testing.T) { + if _, is_ci := os.LookupEnv(CI_KEY_NAME); is_ci == true { + t.Skipf("skipping auth file test in CI") + } + groupName := config.GenerateGroupName("resource-groups-authfile") + config.SetGroupName(groupName) // TODO: don't rely on globals + ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) + defer cancel() + defer Cleanup(ctx) + + var err error + _, err = CreateGroupWithAuthFile(ctx, config.GroupName()) + if err != nil { + t.Fatalf("failed to create group: %v\n", err.Error()) + } + t.Logf("created group with auth file: %s\n", config.GroupName()) +} diff --git a/pkg/resourcemanager/resources/testdata/parameters.json b/pkg/resourcemanager/resources/testdata/parameters.json new file mode 100644 index 00000000000..9f3e57743e4 --- /dev/null +++ b/pkg/resourcemanager/resources/testdata/parameters.json @@ -0,0 +1,32 @@ +{ + "virtualNetworks_GoQSVM_vnet_name": { + "value": "QuickstartVnet" + }, + "virtualMachines_QuickstartVM_name": { + "value": "QuickstartVM" + }, + "networkInterfaces_quickstartvm_name": { + "value": "QuickstartNIC" + }, + "publicIPAddresses_QuickstartVM_ip_name": { + "value": "QuickstartIP" + }, + "networkSecurityGroups_QuickstartVM_nsg_name": { + "value": "QuickstartNSG" + }, + "subnets_default_name": { + "value": "QuickstartSubnet" + }, + "securityRules_default_allow_ssh_name": { + "value": "qsuser" + }, + "osDisk_name": { + "value": "_OsDisk_1_2e3ae1ad37414eaca81b432401fcdd75" + }, + "vm_user": { + "value": "quickstart" + }, + "vm_password": { + "value": "NoSoupForYou!1" + } +} diff --git a/pkg/resourcemanager/resources/testdata/template.json b/pkg/resourcemanager/resources/testdata/template.json new file mode 100644 index 00000000000..82920b8344c --- /dev/null +++ b/pkg/resourcemanager/resources/testdata/template.json @@ -0,0 +1,353 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "virtualNetworks_GoQSVM_vnet_name": { + "defaultValue": null, + "type": "String" + }, + "virtualMachines_QuickstartVM_name": { + "defaultValue": null, + "type": "String" + }, + "networkInterfaces_quickstartvm_name": { + "defaultValue": null, + "type": "String" + }, + "publicIPAddresses_QuickstartVM_ip_name": { + "defaultValue": null, + "type": "String" + }, + "networkSecurityGroups_QuickstartVM_nsg_name": { + "defaultValue": null, + "type": "String" + }, + "subnets_default_name": { + "defaultValue": null, + "type": "String" + }, + "securityRules_default_allow_ssh_name": { + "defaultValue": null, + "type": "String" + }, + "osDisk_name": { + "defaultvalue": null, + "type": "String" + }, + "vm_user": { + "defaultValue": null, + "type":"String" + }, + "vm_password": { + "defaultValue": null, + "type": "String" + } + }, + "variables": {}, + "resources": [ + { + "type": "Microsoft.Compute/virtualMachines", + "name": "[parameters('virtualMachines_QuickstartVM_name')]", + "apiVersion": "2017-03-30", + "location": "eastus", + "scale": null, + "properties": { + "hardwareProfile": { + "vmSize": "Standard_B1s" + }, + "storageProfile": { + "imageReference": { + "publisher": "Canonical", + "offer": "UbuntuServer", + "sku": "16.04-LTS", + "version": "latest" + }, + "osDisk": { + "osType": "Linux", + "name": "[concat(parameters('virtualMachines_QuickstartVM_name'), parameters('osDisk_name'))]", + "createOption": "FromImage", + "caching": "ReadWrite", + "managedDisk": { + "storageAccountType": "Premium_LRS" + }, + "diskSizeGB": 30 + }, + "dataDisks": [] + }, + "osProfile": { + "computerName": "[parameters('virtualMachines_QuickstartVM_name')]", + "adminUsername": "[parameters('vm_user')]", + "adminPassword": "[parameters('vm_password')]", + "linuxConfiguration": { + "disablePasswordAuthentication": false + }, + "secrets": [] + }, + "networkProfile": { + "networkInterfaces": [ + { + "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_quickstartvm_name'))]" + } + ] + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaces_quickstartvm_name'))]" + ] + }, + { + "type": "Microsoft.Network/networkInterfaces", + "name": "[parameters('networkInterfaces_quickstartvm_name')]", + "apiVersion": "2017-06-01", + "location": "eastus", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "d25c4596-2f13-4758-bccb-35cde6369ed6", + "ipConfigurations": [ + { + "name": "ipconfig1", + "etag": "W/\"ce7de133-36d6-45a0-901e-a76a1ae65cc5\"", + "properties": { + "provisioningState": "Succeeded", + "privateIPAddress": "10.0.0.4", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_QuickstartVM_ip_name'))]" + }, + "subnet": { + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworks_GoQSVM_vnet_name'), parameters('subnets_default_name'))]" + }, + "primary": true, + "privateIPAddressVersion": "IPv4" + } + } + ], + "dnsSettings": { + "dnsServers": [], + "appliedDnsServers": [], + "internalDomainNameSuffix": "w2dmkj1zjdbelhvojagffco4ja.bx.internal.cloudapp.net" + }, + "macAddress": "00-0D-3A-1C-E3-A9", + "enableAcceleratedNetworking": false, + "enableIPForwarding": false, + "networkSecurityGroup": { + "id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_QuickstartVM_nsg_name'))]" + }, + "primary": true, + "virtualMachine": { + "id": "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachines_QuickstartVM_name'))]" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_QuickstartVM_ip_name'))]", + "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworks_GoQSVM_vnet_name'), parameters('subnets_default_name'))]", + "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_QuickstartVM_nsg_name'))]" + ] + }, + { + "type": "Microsoft.Network/networkSecurityGroups", + "name": "[parameters('networkSecurityGroups_QuickstartVM_nsg_name')]", + "apiVersion": "2017-06-01", + "location": "eastus", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "6c8dc2b9-7688-4907-a483-c33308540c85", + "securityRules": [ + ], + "defaultSecurityRules": [ + { + "name": "AllowVnetInBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Inbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + }, + { + "name": "AllowAzureLoadBalancerInBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from azure load balancer", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "AzureLoadBalancer", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 65001, + "direction": "Inbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + }, + { + "name": "DenyAllInBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all inbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Inbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + }, + { + "name": "AllowVnetOutBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Outbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + }, + { + "name": "AllowInternetOutBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to Internet", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "Internet", + "access": "Allow", + "priority": 65001, + "direction": "Outbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + }, + { + "name": "DenyAllOutBound", + "etag": "W/\"578e9cf5-4d23-40cc-aed4-4ed9646b52df\"", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all outbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Outbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + } + } + ] + }, + "dependsOn": [] + }, + { + "type": "Microsoft.Network/publicIPAddresses", + "name": "[parameters('publicIPAddresses_QuickstartVM_ip_name')]", + "apiVersion": "2017-06-01", + "location": "eastus", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "48b2c96b-40e6-4378-973c-fd9b7b066c2c", + "ipAddress": "40.121.193.102", + "publicIPAddressVersion": "IPv4", + "publicIPAllocationMethod": "Dynamic", + "idleTimeoutInMinutes": 4 + }, + "dependsOn": [] + }, + { + "type": "Microsoft.Network/virtualNetworks", + "name": "[parameters('virtualNetworks_GoQSVM_vnet_name')]", + "apiVersion": "2017-06-01", + "location": "eastus", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "resourceGuid": "27c506b7-4879-45c2-9eae-480c5289de48", + "addressSpace": { + "addressPrefixes": [ + "10.0.0.0/24" + ] + }, + "subnets": [ + { + "name": "[parameters('subnets_default_name')]", + "etag": "W/\"2d36bb91-8d73-4836-b61b-658cb73debbc\"", + "properties": { + "provisioningState": "Succeeded", + "addressPrefix": "10.0.0.0/24" + } + } + ], + "virtualNetworkPeerings": [] + }, + "dependsOn": [] + }, + { + "type": "Microsoft.Network/networkSecurityGroups/securityRules", + "name": "[concat(parameters('networkSecurityGroups_QuickstartVM_nsg_name'), '/', parameters('securityRules_default_allow_ssh_name'))]", + "apiVersion": "2017-06-01", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "protocol": "TCP", + "sourcePortRange": "*", + "destinationPortRange": "22", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 1000, + "direction": "Inbound", + "sourceAddressPrefixes": [], + "destinationAddressPrefixes": [] + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('networkSecurityGroups_QuickstartVM_nsg_name'))]" + ] + }, + { + "type": "Microsoft.Network/virtualNetworks/subnets", + "name": "[concat(parameters('virtualNetworks_GoQSVM_vnet_name'), '/', parameters('subnets_default_name'))]", + "apiVersion": "2017-06-01", + "scale": null, + "properties": { + "provisioningState": "Succeeded", + "addressPrefix": "10.0.0.0/24" + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworks_GoQSVM_vnet_name'))]" + ] + } + ] + } + \ No newline at end of file diff --git a/resourcemanager/util/util.go b/pkg/util/util.go similarity index 100% rename from resourcemanager/util/util.go rename to pkg/util/util.go