Skip to content

Commit

Permalink
fix: change IntegrationCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Nov 6, 2024
1 parent 51fb020 commit 25e82cb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/describer/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/models/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions provider/configs/credentials.go
Original file line number Diff line number Diff line change
@@ -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"`
}
8 changes: 4 additions & 4 deletions provider/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions provider/describer_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 25e82cb

Please sign in to comment.