11/*
2- Copyright 2018 The Kubernetes Authors.
2+ Copyright 2019 The Kubernetes Authors.
3+
34Licensed under the Apache License, Version 2.0 (the "License");
45you may not use this file except in compliance with the License.
56You may obtain a copy of the License at
7+
68 http://www.apache.org/licenses/LICENSE-2.0
9+
710Unless required by applicable law or agreed to in writing, software
811distributed under the License is distributed on an "AS IS" BASIS,
912WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,32 +25,18 @@ import (
2225 "testing"
2326 "time"
2427
25- "github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/awserrors"
26- "github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/cloudformation"
27- "github.com/kubernetes-sigs/cluster-api-provider-aws/pkg/cloud/aws/services/sts"
2828 . "github.com/onsi/ginkgo"
2929 . "github.com/onsi/gomega"
3030
31- // "github.com/aws/aws-sdk-go/aws"
32- // "github.com/aws/aws-sdk-go/aws/client"
33- // "github.com/aws/aws-sdk-go/aws/credentials"
34- // "github.com/aws/aws-sdk-go/aws/session"
35- // cfn "github.com/aws/aws-sdk-go/service/cloudformation"
36- // "github.com/aws/aws-sdk-go/service/ec2"
37- // awssts "github.com/aws/aws-sdk-go/service/sts"
3831 appsv1 "k8s.io/api/apps/v1"
3932 apimachinerytypes "k8s.io/apimachinery/pkg/types"
33+ "sigs.k8s.io/cluster-api-provider-azure/test/e2e/util/kind"
4034 "sigs.k8s.io/cluster-api/pkg/util"
4135 crclient "sigs.k8s.io/controller-runtime/pkg/client"
42-
43- // "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/awserrors"
44- // "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/cloudformation"
45- // "sigs.k8s.io/cluster-api-provider-azure/pkg/cloud/aws/services/sts"
46- "sigs.k8s.io/cluster-api-provider-azure/test/e2e/util/kind"
4736)
4837
4938func TestE2e (t * testing.T ) {
50- if err := initRegion (); err != nil {
39+ if err := initLocation (); err != nil {
5140 t .Fatal (err )
5241 }
5342 RegisterFailHandler (Fail )
@@ -58,21 +47,18 @@ const (
5847 setupTimeout = 10 * 60
5948 capzProviderNamespace = "azure-provider-system"
6049 capzStatefulSetName = "azure-provider-controller-manager"
61- stackName = "cluster-api-provider-azure-sigs-k8s-io"
62- keyPairName = "cluster-api-provider-azure-sigs-k8s-io"
6350)
6451
6552var (
66- credFile = flag .String ("credFile" , "" , "path to an Azure credentials file" )
67- regionFile = flag .String ("regionFile" , "" , "The path to a text file containing the Azure region" )
53+ // TODO: Do we want to do file-based auth? Not suggested. If we determine no, remove this deadcode
54+ //credFile = flag.String("credFile", "", "path to an Azure credentials file")
55+ locationFile = flag .String ("locationFile" , "" , "The path to a text file containing the Azure location" )
6856 providerComponentsYAML = flag .String ("providerComponentsYAML" , "" , "path to the provider components YAML for the cluster API" )
6957 managerImageTar = flag .String ("managerImageTar" , "" , "a script to load the manager Docker image into Docker" )
7058
7159 kindCluster kind.Cluster
7260 kindClient crclient.Client
73- sess client.ConfigProvider
74- accountID string
75- region string
61+ location string
7662)
7763
7864var _ = BeforeSuite (func () {
@@ -91,10 +77,7 @@ var _ = BeforeSuite(func() {
9177 Expect (err ).To (BeNil ())
9278
9379 fmt .Fprintf (GinkgoWriter , "Creating Azure prerequisites\n " )
94- // sess = getSession()
95- // accountID = getAccountID(sess)
96- // createKeyPair(sess)
97- // createIAMRoles(sess, accountID)
80+ // TODO: Probably need to init auth session to Azure here
9881
9982 fmt .Fprintf (GinkgoWriter , "Ensuring ProviderComponents are deployed\n " )
10083 Eventually (
@@ -107,66 +90,30 @@ var _ = BeforeSuite(func() {
10790 }, 5 * time .Minute , 15 * time .Second ,
10891 ).ShouldNot (BeZero ())
10992
110- fmt .Fprintf (GinkgoWriter , "Running in Azure region : %s\n " , region )
93+ fmt .Fprintf (GinkgoWriter , "Running in Azure location : %s\n " , location )
11194}, setupTimeout )
11295
11396var _ = AfterSuite (func () {
11497 fmt .Fprintf (GinkgoWriter , "Tearing down kind cluster\n " )
11598 kindCluster .Teardown ()
11699})
117100
118- func initRegion () error {
119- if regionFile != nil && * regionFile != "" {
120- data , err := ioutil .ReadFile (* regionFile )
101+ // TODO: Determine if we need this
102+ func initLocation () error {
103+ if locationFile != nil && * locationFile != "" {
104+ data , err := ioutil .ReadFile (* locationFile )
121105 if err != nil {
122- return fmt .Errorf ("error reading AWS region file: %v" , err )
106+ return fmt .Errorf ("error reading AWS location file: %v" , err )
123107 }
124- region = string (bytes .TrimSpace (data ))
108+ location = string (bytes .TrimSpace (data ))
125109 return nil
126110 }
127111
128- region = "eastus2 "
112+ location = "eastus "
129113 return nil
130114}
131115
132- func getSession () client.ConfigProvider {
133- if credFile != nil && * credFile != "" {
134- creds := credentials .NewCredentials (& credentials.SharedCredentialsProvider {
135- Filename : * credFile ,
136- })
137- sess , err := session .NewSession (aws .NewConfig ().WithCredentials (creds ).WithRegion (region ))
138- Expect (err ).To (BeNil ())
139- return sess
140- }
141-
142- sess , err := session .NewSessionWithOptions (session.Options {
143- SharedConfigState : session .SharedConfigEnable ,
144- })
145- Expect (err ).To (BeNil ())
146- return sess
147- }
148-
149- func getAccountID (prov client.ConfigProvider ) string {
150- stsSvc := sts .NewService (awssts .New (prov ))
151- accountID , err := stsSvc .AccountID ()
152- Expect (err ).To (BeNil ())
153- return accountID
154- }
155-
156- func createIAMRoles (prov client.ConfigProvider , accountID string ) {
157- cfnSvc := cloudformation .NewService (cfn .New (prov ))
158- Expect (
159- cfnSvc .ReconcileBootstrapStack (stackName , accountID ),
160- ).To (Succeed ())
161- }
162-
163- func createKeyPair (prov client.ConfigProvider ) {
164- ec2c := ec2 .New (prov )
165- _ , err := ec2c .CreateKeyPair (& ec2.CreateKeyPairInput {KeyName : aws .String (keyPairName )})
166- if code , _ := awserrors .Code (err ); code != "InvalidKeyPair.Duplicate" {
167- Expect (err ).To (BeNil ())
168- }
169- }
116+ // TODO: Add function to handle auth to Azure
170117
171118func loadManagerImage (kindCluster kind.Cluster ) {
172119 if managerImageTar != nil && * managerImageTar != "" {
0 commit comments