From 25e82cb9b21f6bca93f6341d7e1d63a873322826 Mon Sep 17 00:00:00 2001 From: artaasadi Date: Wed, 6 Nov 2024 23:41:15 +0100 Subject: [PATCH] fix: change IntegrationCredentials --- pkg/describer/resources.go | 4 ++-- pkg/sdk/models/resource_type.go | 4 ++-- provider/configs/credentials.go | 12 ++++++------ provider/credentials.go | 8 ++++---- provider/describer_wrapper.go | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/describer/resources.go b/pkg/describer/resources.go index 8d7b11a6..e3efcd79 100755 --- a/pkg/describer/resources.go +++ b/pkg/describer/resources.go @@ -49,7 +49,7 @@ func GetResources( logger *zap.Logger, resourceType string, triggerType enums.DescribeTriggerType, - cfg configs.AccountCredentials, + cfg configs.IntegrationCredentials, additionalData map[string]string, stream *model.StreamSender, ) error { @@ -60,7 +60,7 @@ func GetResources( return nil } -func describe(ctx context.Context, logger *zap.Logger, accountCfg configs.AccountCredentials, resourceType string, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { +func describe(ctx context.Context, logger *zap.Logger, accountCfg configs.IntegrationCredentials, resourceType string, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { resourceTypeObject, ok := provider.ResourceTypes[resourceType] if !ok { return nil, fmt.Errorf("unsupported resource type: %s", resourceType) diff --git a/pkg/sdk/models/resource_type.go b/pkg/sdk/models/resource_type.go index a2faed9b..9b318a94 100644 --- a/pkg/sdk/models/resource_type.go +++ b/pkg/sdk/models/resource_type.go @@ -8,8 +8,8 @@ import ( ) // any types are used to load your provider configuration. -type ResourceDescriber func(context.Context, configs.AccountCredentials, enums.DescribeTriggerType, map[string]string, *StreamSender) ([]Resource, error) -type SingleResourceDescriber func(context.Context, configs.AccountCredentials, enums.DescribeTriggerType, map[string]string) (*Resource, error) +type ResourceDescriber func(context.Context, configs.IntegrationCredentials, enums.DescribeTriggerType, map[string]string, *StreamSender) ([]Resource, error) +type SingleResourceDescriber func(context.Context, configs.IntegrationCredentials, enums.DescribeTriggerType, map[string]string) (*Resource, error) type ResourceType struct { IntegrationType integration.Type diff --git a/provider/configs/credentials.go b/provider/configs/credentials.go index da28f9bc..1287e444 100644 --- a/provider/configs/credentials.go +++ b/provider/configs/credentials.go @@ -1,11 +1,11 @@ package configs -type AccountCredentials struct { - TenantID string `json:"azure_tenant_id"` - ClientID string `json:"azure_client_id"` - ClientSecret string `json:"azure_client_password"` - CertificatePath string `json:"certificatePath"` - CertificatePass string `json:"certificatePass"` +type IntegrationCredentials struct { + TenantID string `json:"tenant_id"` + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` + CertificatePath string `json:"certificate_path"` + CertificatePass string `json:"certificate_pass"` Username string `json:"username"` Password string `json:"password"` } diff --git a/provider/credentials.go b/provider/credentials.go index 9d0e85ae..3d357655 100644 --- a/provider/credentials.go +++ b/provider/credentials.go @@ -10,16 +10,16 @@ import ( "strings" ) -func AccountConfigFromMap(m map[string]any) (configs.AccountCredentials, error) { +func AccountConfigFromMap(m map[string]any) (configs.IntegrationCredentials, error) { mj, err := json.Marshal(m) if err != nil { - return configs.AccountCredentials{}, err + return configs.IntegrationCredentials{}, err } - var c configs.AccountCredentials + var c configs.IntegrationCredentials err = json.Unmarshal(mj, &c) if err != nil { - return configs.AccountCredentials{}, err + return configs.IntegrationCredentials{}, err } return c, nil diff --git a/provider/describer_wrapper.go b/provider/describer_wrapper.go index 87053340..365edf34 100755 --- a/provider/describer_wrapper.go +++ b/provider/describer_wrapper.go @@ -11,7 +11,7 @@ import ( ) func DescribeBySubscription(describe func(context.Context, *azidentity.ClientSecretCredential, string, *model.StreamSender) ([]model.Resource, error)) model.ResourceDescriber { - return func(ctx context.Context, cfg configs.AccountCredentials, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { + return func(ctx context.Context, cfg configs.IntegrationCredentials, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { ctx = describer.WithTriggerType(ctx, triggerType) cred, err := azidentity.NewClientSecretCredential(cfg.TenantID, cfg.ClientID, cfg.ClientSecret, nil) if err != nil { @@ -36,7 +36,7 @@ func DescribeBySubscription(describe func(context.Context, *azidentity.ClientSec } func DescribeADByTenantID(describe func(context.Context, *azidentity.ClientSecretCredential, string, *model.StreamSender) ([]model.Resource, error)) model.ResourceDescriber { - return func(ctx context.Context, cfg configs.AccountCredentials, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { + return func(ctx context.Context, cfg configs.IntegrationCredentials, triggerType enums.DescribeTriggerType, additionalData map[string]string, stream *model.StreamSender) ([]model.Resource, error) { ctx = describer.WithTriggerType(ctx, triggerType) cred, err := azidentity.NewClientSecretCredential(cfg.TenantID, cfg.ClientID, cfg.ClientSecret, nil) if err != nil {