Skip to content

Commit e67c271

Browse files
authored
Merge pull request #153 from thand-io/provider-activities-enable
Enable activities for remaining providers
2 parents ba3e8e9 + 77c4a2b commit e67c271

11 files changed

Lines changed: 83 additions & 13 deletions

File tree

internal/models/provider_activities.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66

77
"github.com/sirupsen/logrus"
8+
"go.temporal.io/sdk/temporal"
89
)
910

1011
// RegisterActivities registers provider-specific activities with the Temporal worker
@@ -22,6 +23,26 @@ func NewProviderActivities(provider ProviderImpl) *ProviderActivities {
2223
}
2324
}
2425

26+
func (a *ProviderActivities) AuthorizeRole(
27+
ctx context.Context,
28+
req *AuthorizeRoleRequest,
29+
) (*AuthorizeRoleResponse, error) {
30+
31+
logrus.Infoln("Starting AuthorizeRole activity")
32+
return handleNotImplementedError(a.provider.AuthorizeRole(ctx, req))
33+
34+
}
35+
36+
func (a *ProviderActivities) RevokeRole(
37+
ctx context.Context,
38+
req *RevokeRoleRequest,
39+
) (*RevokeRoleResponse, error) {
40+
41+
logrus.Infoln("Starting RevokeRole activity")
42+
return handleNotImplementedError(a.provider.RevokeRole(ctx, req))
43+
44+
}
45+
2546
func (a *ProviderActivities) SynchronizeIdentities(
2647
ctx context.Context,
2748
req SynchronizeUsersRequest,
@@ -97,10 +118,11 @@ func (a *ProviderActivities) SynchronizeRoles(
97118
func handleNotImplementedError[T any](res T, err error) (T, error) {
98119
if err != nil {
99120
if errors.Is(err, ErrNotImplemented) {
100-
// Ignore not implemented errors. This will
101-
// just complete the activity as successful without doing anything.
102-
logrus.WithError(err).Infoln("Activity not implemented for this provider, skipping")
103-
return res, nil
121+
return res, temporal.NewNonRetryableApplicationError(
122+
"activity not implemented for this provider",
123+
"NotImplementedError",
124+
err,
125+
)
104126
}
105127
}
106128
return res, err

internal/providers/aws/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (b *awsProvider) RegisterActivities(temporalClient models.TemporalImpl) err
1010
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
1111
}
1212

13-
// Aws uses static roles and permissions so we don't need to them.
13+
// Aws uses static roles and permissions so we don't need to fetch them.
1414
// Instead we will just return these in the synchronize call.
1515
func (p *awsProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
1616

internal/providers/azure/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (b *azureProvider) RegisterActivities(temporalClient models.TemporalImpl) e
1010
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
1111
}
1212

13-
// Azure uses static roles and permissions so we don't need to them.
13+
// Azure uses static roles and permissions so we don't need to fetch them.
1414
// Instead we will just return these in the synchronize call.
1515
func (p *azureProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
1616

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package cloudflare
22

3-
import "github.com/thand-io/agent/internal/models"
3+
import (
4+
"context"
5+
6+
"github.com/thand-io/agent/internal/models"
7+
)
48

59
func (b *cloudflareProvider) RegisterActivities(temporalClient models.TemporalImpl) error {
610
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
711
}
12+
13+
// Cloudflare uses static roles and permissions so we don't need to fetch them.
14+
// Instead we will just return these in the synchronize call.
15+
func (p *cloudflareProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
16+
return models.Synchronize(ctx, temporalService, p)
17+
}

internal/providers/gcp/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (b *gcpProvider) RegisterActivities(temporalClient models.TemporalImpl) err
1010
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
1111
}
1212

13-
// GCP uses static roles and permissions so we don't need to them.
13+
// GCP uses static roles and permissions so we don't need to fetch them.
1414
// Instead we will just return these in the synchronize call.
1515
func (p *gcpProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
1616

internal/providers/github/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (b *githubProvider) RegisterActivities(temporalClient models.TemporalImpl)
1010
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
1111
}
1212

13-
// GitHub uses static roles and permissions so we don't need to them.
13+
// GitHub uses static roles and permissions so we don't need to fetch them.
1414
// Instead we will just return these in the synchronize call.
1515
func (p *githubProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
1616

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package gsuite
22

3-
import "github.com/thand-io/agent/internal/models"
3+
import (
4+
"context"
5+
6+
"github.com/thand-io/agent/internal/models"
7+
)
48

59
func (b *gsuiteProvider) RegisterActivities(temporalClient models.TemporalImpl) error {
610
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
711
}
12+
13+
// GSuite uses static roles and permissions so we don't need to fetch them.
14+
// Instead we will just return these in the synchronize call.
15+
func (p *gsuiteProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
16+
return models.Synchronize(ctx, temporalService, p)
17+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
package kubernetes
22

33
import (
4+
"context"
5+
46
"github.com/thand-io/agent/internal/models"
57
)
68

79
func (b *kubernetesProvider) RegisterActivities(temporalClient models.TemporalImpl) error {
810
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
911
}
12+
13+
// Kubernetes uses static roles and permissions so we don't need to fetch them.
14+
// Instead we will just return these in the synchronize call.
15+
func (p *kubernetesProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
16+
return models.Synchronize(ctx, temporalService, p)
17+
}

internal/providers/okta/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ func (b *oktaProvider) RegisterActivities(temporalClient models.TemporalImpl) er
1010
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
1111
}
1212

13-
// GitHub uses static roles and permissions so we don't need to them.
13+
// GitHub uses static roles and permissions so we don't need to fetch them.
1414
// Instead we will just return these in the synchronize call.
1515
func (p *oktaProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
1616

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package salesforce
22

3-
import "github.com/thand-io/agent/internal/models"
3+
import (
4+
"context"
5+
6+
"github.com/thand-io/agent/internal/models"
7+
)
48

59
func (b *salesForceProvider) RegisterActivities(temporalClient models.TemporalImpl) error {
610
return models.RegisterActivities(temporalClient, models.NewProviderActivities(b))
711
}
12+
13+
// Salesforce uses static roles and permissions so we don't need to fetch them.
14+
// Instead we will just return these in the synchronize call.
15+
func (p *salesForceProvider) Synchronize(ctx context.Context, temporalService models.TemporalImpl) error {
16+
return models.Synchronize(ctx, temporalService, p)
17+
}

0 commit comments

Comments
 (0)