generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 12
/
createScopeAzure.go
44 lines (37 loc) · 1.27 KB
/
createScopeAzure.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package scope
import (
"context"
"errors"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/composed"
)
func createScopeAzure(ctx context.Context, st composed.State) (error, context.Context) {
logger := composed.LoggerFromCtx(ctx)
state := st.(*State)
subscriptionID, ok := state.credentialData["subscriptionID"]
if !ok {
err := errors.New("gardener credential for azure missing subscriptionID key")
logger.Error(err, "error defining Azure scope")
return composed.StopAndForget, nil // no requeue
}
tenantID, ok := state.credentialData["tenantID"]
if !ok {
err := errors.New("gardener credential for azure missing tenantID key")
logger.Error(err, "error defining Azure scope")
return composed.StopAndForget, nil // no requeue
}
// just create the scope with Azure specifics, the ensureScopeCommonFields will set common values
scope := &cloudcontrolv1beta1.Scope{
Spec: cloudcontrolv1beta1.ScopeSpec{
Scope: cloudcontrolv1beta1.ScopeInfo{
Azure: &cloudcontrolv1beta1.AzureScope{
TenantId: tenantID,
SubscriptionId: subscriptionID,
VpcNetwork: commonVpcName(state.shootNamespace, state.shootName),
},
},
},
}
state.SetObj(scope)
return nil, nil
}