From 931da57ff1df757854f92520d3ccf35693124f1b Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Tue, 18 Sep 2018 19:45:31 -0700 Subject: [PATCH 1/7] adding delete app fn and adding appObjectID to createApp --- cmd/deploy.go | 2 +- pkg/armhelpers/graph.go | 25 +++++++++++++++++++++---- pkg/armhelpers/interfaces.go | 4 +++- pkg/armhelpers/mockclients.go | 9 +++++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 50d0b70921..43f12d26a6 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -365,7 +365,7 @@ func autofillApimodel(dc *deployCmd) error { }, } } - applicationID, servicePrincipalObjectID, secret, err := dc.client.CreateApp(ctx, appName, appURL, replyURLs, requiredResourceAccess) + _, applicationID, servicePrincipalObjectID, secret, err := dc.client.CreateApp(ctx, appName, appURL, replyURLs, requiredResourceAccess) if err != nil { return errors.Wrap(err, "apimodel invalid: ServicePrincipalProfile was empty, and we failed to create valid credentials") } diff --git a/pkg/armhelpers/graph.go b/pkg/armhelpers/graph.go index 47fa215ec0..a87b5cdcf3 100644 --- a/pkg/armhelpers/graph.go +++ b/pkg/armhelpers/graph.go @@ -8,6 +8,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization" "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac" + "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/satori/go.uuid" @@ -28,6 +29,11 @@ func (az *AzureClient) CreateGraphApplication(ctx context.Context, applicationCr return az.applicationsClient.Create(ctx, applicationCreateParameters) } +// DeleteGraphApplication creates an application via the graphrbac client +func (az *AzureClient) DeleteGraphApplication(ctx context.Context, applicationObjectID string) (result autorest.Response, err error) { + return az.applicationsClient.Delete(ctx, applicationObjectID) +} + // CreateGraphPrincipal creates a service principal via the graphrbac client func (az *AzureClient) CreateGraphPrincipal(ctx context.Context, servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) { return az.servicePrincipalsClient.Create(ctx, servicePrincipalCreateParameters) @@ -50,7 +56,7 @@ func (az *AzureClient) ListRoleAssignmentsForPrincipal(ctx context.Context, scop } // CreateApp is a simpler method for creating an application -func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationID, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { +func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { notBefore := time.Now() notAfter := time.Now().Add(10000 * 24 * time.Hour) @@ -78,9 +84,10 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } applicationResp, err := az.CreateGraphApplication(ctx, applicationReq) if err != nil { - return "", "", "", err + return "", "", "", "", err } applicationID = to.String(applicationResp.AppID) + applicationObjectID = to.String(applicationResp.ObjectID) log.Debugf("ad: creating servicePrincipal for applicationID: %q", applicationID) @@ -90,12 +97,22 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } servicePrincipalResp, err := az.servicePrincipalsClient.Create(ctx, servicePrincipalReq) if err != nil { - return "", "", "", err + return "", "", "", "", err } servicePrincipalObjectID = to.String(servicePrincipalResp.ObjectID) - return applicationID, servicePrincipalObjectID, servicePrincipalClientSecret, nil + return applicationObjectID, applicationID, servicePrincipalObjectID, servicePrincipalClientSecret, nil +} + +// DeleteApp is a simpler method for deleting an application and the associated spn +func (az *AzureClient) DeleteApp(ctx context.Context, appName, applicationObjectID string) (autorest.Response, error) { + log.Debugf("ad: deleting application with name=%q", appName) + applicationResp, err := az.DeleteGraphApplication(ctx, applicationObjectID) + if err != nil { + return applicationResp, err + } + return applicationResp, nil } // CreateRoleAssignmentSimple is a wrapper around RoleAssignmentsClient.Create diff --git a/pkg/armhelpers/interfaces.go b/pkg/armhelpers/interfaces.go index edbfe8b1ee..ee023f2cdd 100644 --- a/pkg/armhelpers/interfaces.go +++ b/pkg/armhelpers/interfaces.go @@ -10,6 +10,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/preview/msi/mgmt/2015-08-31-preview/msi" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources" azStorage "github.com/Azure/azure-sdk-for-go/storage" + "github.com/Azure/go-autorest/autorest" log "github.com/sirupsen/logrus" "k8s.io/api/core/v1" ) @@ -102,7 +103,8 @@ type ACSEngineClient interface { // CreateGraphPrincipal creates a service principal via the graphrbac client CreateGraphPrincipal(ctx context.Context, servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) - CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationID, servicePrincipalObjectID, secret string, err error) + CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, secret string, err error) + DeleteApp(ctx context.Context, appName, applicationObjectID string) (autorest.Response, error) // User Assigned MSI //CreateUserAssignedID - Creates a user assigned msi. diff --git a/pkg/armhelpers/mockclients.go b/pkg/armhelpers/mockclients.go index 08d7e233fd..3bf8ad7290 100644 --- a/pkg/armhelpers/mockclients.go +++ b/pkg/armhelpers/mockclients.go @@ -550,8 +550,13 @@ func (mc *MockACSEngineClient) CreateGraphPrincipal(ctx context.Context, service } // CreateApp is a simpler method for creating an application -func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationID, servicePrincipalObjectID, secret string, err error) { - return "app-id", "client-id", "client-secret", nil +func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, secret string, err error) { + return "app-object-id", "app-id", "client-id", "client-secret", nil +} + +// DeleteApp is a simpler method for deleting an application +func (mc *MockACSEngineClient) DeleteApp(ctx context.Context, appName, applicationObjectID string) (response autorest.Response, err error) { + return response, nil } // User Assigned MSI From a244076fc092493ba0d2a9b6b76924896ca56e01 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 10:16:46 -0700 Subject: [PATCH 2/7] changed appName to applicationName --- pkg/armhelpers/graph.go | 6 +++--- pkg/armhelpers/interfaces.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/armhelpers/graph.go b/pkg/armhelpers/graph.go index a87b5cdcf3..1e8d4f4a13 100644 --- a/pkg/armhelpers/graph.go +++ b/pkg/armhelpers/graph.go @@ -29,7 +29,7 @@ func (az *AzureClient) CreateGraphApplication(ctx context.Context, applicationCr return az.applicationsClient.Create(ctx, applicationCreateParameters) } -// DeleteGraphApplication creates an application via the graphrbac client +// DeleteGraphApplication deletes an application via the graphrbac client func (az *AzureClient) DeleteGraphApplication(ctx context.Context, applicationObjectID string) (result autorest.Response, err error) { return az.applicationsClient.Delete(ctx, applicationObjectID) } @@ -106,8 +106,8 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } // DeleteApp is a simpler method for deleting an application and the associated spn -func (az *AzureClient) DeleteApp(ctx context.Context, appName, applicationObjectID string) (autorest.Response, error) { - log.Debugf("ad: deleting application with name=%q", appName) +func (az *AzureClient) DeleteApp(ctx context.Context, applicationName, applicationObjectID string) (autorest.Response, error) { + log.Debugf("ad: deleting application with name=%q", applicationName) applicationResp, err := az.DeleteGraphApplication(ctx, applicationObjectID) if err != nil { return applicationResp, err diff --git a/pkg/armhelpers/interfaces.go b/pkg/armhelpers/interfaces.go index ee023f2cdd..3dc2484c9b 100644 --- a/pkg/armhelpers/interfaces.go +++ b/pkg/armhelpers/interfaces.go @@ -104,7 +104,7 @@ type ACSEngineClient interface { // CreateGraphPrincipal creates a service principal via the graphrbac client CreateGraphPrincipal(ctx context.Context, servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, secret string, err error) - DeleteApp(ctx context.Context, appName, applicationObjectID string) (autorest.Response, error) + DeleteApp(ctx context.Context, applicationName, applicationObjectID string) (autorest.Response, error) // User Assigned MSI //CreateUserAssignedID - Creates a user assigned msi. From 8dd4afbc9e2c4c2fbc86e78b9d170ddfb0d45516 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 11:33:36 -0700 Subject: [PATCH 3/7] returning autorest.Response from CreateApp --- cmd/deploy.go | 3 ++- pkg/armhelpers/graph.go | 11 +++++------ pkg/armhelpers/interfaces.go | 2 +- pkg/armhelpers/mockclients.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/deploy.go b/cmd/deploy.go index 43f12d26a6..00249f4b80 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -365,10 +365,11 @@ func autofillApimodel(dc *deployCmd) error { }, } } - _, applicationID, servicePrincipalObjectID, secret, err := dc.client.CreateApp(ctx, appName, appURL, replyURLs, requiredResourceAccess) + applicationResp, servicePrincipalObjectID, secret, err := dc.client.CreateApp(ctx, appName, appURL, replyURLs, requiredResourceAccess) if err != nil { return errors.Wrap(err, "apimodel invalid: ServicePrincipalProfile was empty, and we failed to create valid credentials") } + applicationID := to.String(applicationResp.AppID) log.Warnf("created application with applicationID (%s) and servicePrincipalObjectID (%s).", applicationID, servicePrincipalObjectID) log.Warnln("apimodel: ServicePrincipalProfile was empty, assigning role to application...") diff --git a/pkg/armhelpers/graph.go b/pkg/armhelpers/graph.go index 1e8d4f4a13..751b1f190d 100644 --- a/pkg/armhelpers/graph.go +++ b/pkg/armhelpers/graph.go @@ -56,7 +56,7 @@ func (az *AzureClient) ListRoleAssignmentsForPrincipal(ctx context.Context, scop } // CreateApp is a simpler method for creating an application -func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { +func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationRes autorest.Response, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { notBefore := time.Now() notAfter := time.Now().Add(10000 * 24 * time.Hour) @@ -84,10 +84,9 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } applicationResp, err := az.CreateGraphApplication(ctx, applicationReq) if err != nil { - return "", "", "", "", err + return applicationResp.Response, "", "", err } - applicationID = to.String(applicationResp.AppID) - applicationObjectID = to.String(applicationResp.ObjectID) + applicationID := to.String(applicationResp.AppID) log.Debugf("ad: creating servicePrincipal for applicationID: %q", applicationID) @@ -97,12 +96,12 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } servicePrincipalResp, err := az.servicePrincipalsClient.Create(ctx, servicePrincipalReq) if err != nil { - return "", "", "", "", err + return applicationResp.Response, "", "", err } servicePrincipalObjectID = to.String(servicePrincipalResp.ObjectID) - return applicationObjectID, applicationID, servicePrincipalObjectID, servicePrincipalClientSecret, nil + return applicationResp.Response, servicePrincipalObjectID, servicePrincipalClientSecret, nil } // DeleteApp is a simpler method for deleting an application and the associated spn diff --git a/pkg/armhelpers/interfaces.go b/pkg/armhelpers/interfaces.go index 3dc2484c9b..fd90431951 100644 --- a/pkg/armhelpers/interfaces.go +++ b/pkg/armhelpers/interfaces.go @@ -103,7 +103,7 @@ type ACSEngineClient interface { // CreateGraphPrincipal creates a service principal via the graphrbac client CreateGraphPrincipal(ctx context.Context, servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) - CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, secret string, err error) + CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (response autorest.Response, servicePrincipalObjectID, secret string, err error) DeleteApp(ctx context.Context, applicationName, applicationObjectID string) (autorest.Response, error) // User Assigned MSI diff --git a/pkg/armhelpers/mockclients.go b/pkg/armhelpers/mockclients.go index 3bf8ad7290..ec93452a7a 100644 --- a/pkg/armhelpers/mockclients.go +++ b/pkg/armhelpers/mockclients.go @@ -550,8 +550,8 @@ func (mc *MockACSEngineClient) CreateGraphPrincipal(ctx context.Context, service } // CreateApp is a simpler method for creating an application -func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationObjectID, applicationID, servicePrincipalObjectID, secret string, err error) { - return "app-object-id", "app-id", "client-id", "client-secret", nil +func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (response autorest.Response, servicePrincipalObjectID, secret string, err error) { + return response, "client-id", "client-secret", nil } // DeleteApp is a simpler method for deleting an application From a68ac3150b66999f34f2e42061379eae4d05aa41 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 11:52:44 -0700 Subject: [PATCH 4/7] returning graphrbac.Application type for CreateApp --- pkg/armhelpers/graph.go | 8 ++++---- pkg/armhelpers/interfaces.go | 2 +- pkg/armhelpers/mockclients.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/armhelpers/graph.go b/pkg/armhelpers/graph.go index 751b1f190d..9395874db4 100644 --- a/pkg/armhelpers/graph.go +++ b/pkg/armhelpers/graph.go @@ -56,7 +56,7 @@ func (az *AzureClient) ListRoleAssignmentsForPrincipal(ctx context.Context, scop } // CreateApp is a simpler method for creating an application -func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationRes autorest.Response, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { +func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationRes graphrbac.Application, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { notBefore := time.Now() notAfter := time.Now().Add(10000 * 24 * time.Hour) @@ -84,7 +84,7 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } applicationResp, err := az.CreateGraphApplication(ctx, applicationReq) if err != nil { - return applicationResp.Response, "", "", err + return applicationResp, "", "", err } applicationID := to.String(applicationResp.AppID) @@ -96,12 +96,12 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re } servicePrincipalResp, err := az.servicePrincipalsClient.Create(ctx, servicePrincipalReq) if err != nil { - return applicationResp.Response, "", "", err + return applicationResp, "", "", err } servicePrincipalObjectID = to.String(servicePrincipalResp.ObjectID) - return applicationResp.Response, servicePrincipalObjectID, servicePrincipalClientSecret, nil + return applicationResp, servicePrincipalObjectID, servicePrincipalClientSecret, nil } // DeleteApp is a simpler method for deleting an application and the associated spn diff --git a/pkg/armhelpers/interfaces.go b/pkg/armhelpers/interfaces.go index fd90431951..6764f7f284 100644 --- a/pkg/armhelpers/interfaces.go +++ b/pkg/armhelpers/interfaces.go @@ -103,7 +103,7 @@ type ACSEngineClient interface { // CreateGraphPrincipal creates a service principal via the graphrbac client CreateGraphPrincipal(ctx context.Context, servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) - CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (response autorest.Response, servicePrincipalObjectID, secret string, err error) + CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (result graphrbac.Application, servicePrincipalObjectID, secret string, err error) DeleteApp(ctx context.Context, applicationName, applicationObjectID string) (autorest.Response, error) // User Assigned MSI diff --git a/pkg/armhelpers/mockclients.go b/pkg/armhelpers/mockclients.go index ec93452a7a..a390cc6373 100644 --- a/pkg/armhelpers/mockclients.go +++ b/pkg/armhelpers/mockclients.go @@ -550,8 +550,8 @@ func (mc *MockACSEngineClient) CreateGraphPrincipal(ctx context.Context, service } // CreateApp is a simpler method for creating an application -func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (response autorest.Response, servicePrincipalObjectID, secret string, err error) { - return response, "client-id", "client-secret", nil +func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (result graphrbac.Application, servicePrincipalObjectID, secret string, err error) { + return result, "client-id", "client-secret", nil } // DeleteApp is a simpler method for deleting an application From 9df2d478b9f4b86c4eb57ac6a53dfa13d2ac13a1 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 11:59:07 -0700 Subject: [PATCH 5/7] correcting param name --- pkg/armhelpers/graph.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/armhelpers/graph.go b/pkg/armhelpers/graph.go index 9395874db4..4774b5c541 100644 --- a/pkg/armhelpers/graph.go +++ b/pkg/armhelpers/graph.go @@ -56,7 +56,7 @@ func (az *AzureClient) ListRoleAssignmentsForPrincipal(ctx context.Context, scop } // CreateApp is a simpler method for creating an application -func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationRes graphrbac.Application, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { +func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationResp graphrbac.Application, servicePrincipalObjectID, servicePrincipalClientSecret string, err error) { notBefore := time.Now() notAfter := time.Now().Add(10000 * 24 * time.Hour) @@ -82,7 +82,7 @@ func (az *AzureClient) CreateApp(ctx context.Context, appName, appURL string, re }, RequiredResourceAccess: requiredResourceAccess, } - applicationResp, err := az.CreateGraphApplication(ctx, applicationReq) + applicationResp, err = az.CreateGraphApplication(ctx, applicationReq) if err != nil { return applicationResp, "", "", err } From 33f10f8c6ff86919d2baac26f63c20725b2ab545 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 12:12:23 -0700 Subject: [PATCH 6/7] updating test files --- pkg/armhelpers/mockclients.go | 6 +++++- pkg/helpers/helpers.go | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/armhelpers/mockclients.go b/pkg/armhelpers/mockclients.go index a390cc6373..5d1fa03a00 100644 --- a/pkg/armhelpers/mockclients.go +++ b/pkg/armhelpers/mockclients.go @@ -9,6 +9,8 @@ import ( "net/http" "time" + "github.com/Azure/acs-engine/pkg/helpers" + "github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac" @@ -551,7 +553,9 @@ func (mc *MockACSEngineClient) CreateGraphPrincipal(ctx context.Context, service // CreateApp is a simpler method for creating an application func (mc *MockACSEngineClient) CreateApp(ctx context.Context, applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (result graphrbac.Application, servicePrincipalObjectID, secret string, err error) { - return result, "client-id", "client-secret", nil + return graphrbac.Application{ + AppID: helpers.PointerToString("app-id"), + }, "client-id", "client-secret", nil } // DeleteApp is a simpler method for deleting an application diff --git a/pkg/helpers/helpers.go b/pkg/helpers/helpers.go index 2c2d81cb12..152ef304da 100644 --- a/pkg/helpers/helpers.go +++ b/pkg/helpers/helpers.go @@ -73,6 +73,12 @@ func PointerToBool(b bool) *bool { return &p } +// PointerToString returns a pointer to a bool +func PointerToString(s string) *string { + p := s + return &p +} + // PointerToInt returns a pointer to a int func PointerToInt(i int) *int { p := i From f1a4484af89cc17e39826b8521a13ffa46e38092 Mon Sep 17 00:00:00 2001 From: Shruti Ramesh Date: Wed, 19 Sep 2018 12:21:13 -0700 Subject: [PATCH 7/7] updating test files --- pkg/helpers/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/helpers/helpers.go b/pkg/helpers/helpers.go index 152ef304da..053fe82ce8 100644 --- a/pkg/helpers/helpers.go +++ b/pkg/helpers/helpers.go @@ -73,7 +73,7 @@ func PointerToBool(b bool) *bool { return &p } -// PointerToString returns a pointer to a bool +// PointerToString returns a pointer to a string func PointerToString(s string) *string { p := s return &p