-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate slack, teams and samlcertificate to new framework
- Loading branch information
Showing
16 changed files
with
250 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package slack | ||
|
||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
type SlackAlertsIntegration struct { | ||
Name string `json:"name"` | ||
URL string `json:"url"` | ||
} | ||
|
||
func (data SlackAlertsIntegration) WriteToSchema(d *schema.ResourceData) error { | ||
d.Set("name", data.Name) | ||
d.Set("url", data.URL) | ||
return nil | ||
} | ||
|
||
func (data *SlackAlertsIntegration) ReadFromSchema(d *schema.ResourceData) error { | ||
data.Name = d.Get("name").(string) | ||
data.URL = d.Get("url").(string) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package slack | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cyralinc/terraform-provider-cyral/cyral/client" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var resourceContextHandler = core.DefaultContextHandler{ | ||
ResourceName: "Slack Integration", | ||
ResourceType: resourcetype.Resource, | ||
SchemaReaderFactory: func() core.SchemaReader { return &SlackAlertsIntegration{} }, | ||
SchemaWriterFactory: func(_ *schema.ResourceData) core.SchemaWriter { return &SlackAlertsIntegration{} }, | ||
BaseURLFactory: func(d *schema.ResourceData, c *client.Client) string { | ||
return fmt.Sprintf("https://%s/v1/integrations/notifications/slack", c.ControlPlane) | ||
}, | ||
} | ||
|
||
func resourceSchema() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Manages [integration with Slack to push alerts](https://cyral.com/docs/integrations/messaging/slack).", | ||
CreateContext: resourceContextHandler.CreateContext(), | ||
ReadContext: resourceContextHandler.ReadContext(), | ||
UpdateContext: resourceContextHandler.UpdateContext(), | ||
DeleteContext: resourceContextHandler.DeleteContext(), | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Description: "ID of this resource in Cyral environment", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"name": { | ||
Description: "Integration name that will be used internally in the control plane.", | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"url": { | ||
Description: "Slack Alert Webhook url.", | ||
Type: schema.TypeString, | ||
Required: true, | ||
Sensitive: true, | ||
}, | ||
}, | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
} | ||
} |
100 changes: 0 additions & 100 deletions
100
cyral/internal/integration/slack/resource_cyral_integration_slack_alerts.go
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package slack | ||
|
||
import "github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
|
||
type packageSchema struct { | ||
} | ||
|
||
func (p *packageSchema) Name() string { | ||
return "Slack Integration" | ||
} | ||
|
||
func (p *packageSchema) Schemas() []*core.SchemaDescriptor { | ||
return []*core.SchemaDescriptor{ | ||
{ | ||
Name: "cyral_integration_slack_alerts", | ||
Type: core.ResourceSchemaType, | ||
Schema: resourceSchema, | ||
}, | ||
} | ||
} | ||
|
||
func PackageSchema() core.PackageSchema { | ||
return &packageSchema{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package teams | ||
|
||
import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
type MsTeamsIntegration struct { | ||
Name string `json:"name"` | ||
URL string `json:"url"` | ||
} | ||
|
||
func (data MsTeamsIntegration) WriteToSchema(d *schema.ResourceData) error { | ||
d.Set("name", data.Name) | ||
d.Set("url", data.URL) | ||
return nil | ||
} | ||
|
||
func (data *MsTeamsIntegration) ReadFromSchema(d *schema.ResourceData) error { | ||
data.Name = d.Get("name").(string) | ||
data.URL = d.Get("url").(string) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package teams | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/cyralinc/terraform-provider-cyral/cyral/client" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core/types/operationtype" | ||
"github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
var resourceContextHandler = core.DefaultContextHandler{ | ||
ResourceName: "Microsoft Teams Integration", | ||
ResourceType: resourcetype.Resource, | ||
SchemaReaderFactory: func() core.SchemaReader { return &MsTeamsIntegration{} }, | ||
SchemaWriterFactory: func(_ *schema.ResourceData) core.SchemaWriter { return &MsTeamsIntegration{} }, | ||
BaseURLFactory: func(d *schema.ResourceData, c *client.Client) string { | ||
return fmt.Sprintf("https://%s/v1/integrations/notifications/teams", c.ControlPlane) | ||
}, | ||
} | ||
|
||
var ReadMsTeamsConfig = core.ResourceOperationConfig{ | ||
ResourceName: "MsTeamsResourceRead", | ||
Type: operationtype.Read, | ||
HttpMethod: http.MethodGet, | ||
URLFactory: func(d *schema.ResourceData, c *client.Client) string { | ||
return fmt.Sprintf("https://%s/v1/integrations/notifications/teams/%s", c.ControlPlane, d.Id()) | ||
}, | ||
SchemaWriterFactory: func(_ *schema.ResourceData) core.SchemaWriter { return &MsTeamsIntegration{} }, | ||
RequestErrorHandler: &core.ReadIgnoreHttpNotFound{ResName: "Integration Teams"}, | ||
} | ||
|
||
func resourceSchema() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Manages [integration with Microsoft Teams](https://cyral.com/docs/integrations/messaging/microsoft-teams/).", | ||
CreateContext: resourceContextHandler.CreateContext(), | ||
ReadContext: resourceContextHandler.ReadContext(), | ||
UpdateContext: resourceContextHandler.UpdateContext(), | ||
DeleteContext: resourceContextHandler.DeleteContext(), | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Description: "ID of this resource in Cyral environment", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"name": { | ||
Description: "Integration name that will be used internally in the control plane.", | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"url": { | ||
Description: "Microsoft Teams webhook URL.", | ||
Type: schema.TypeString, | ||
Required: true, | ||
Sensitive: true, | ||
}, | ||
}, | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
} | ||
} |
100 changes: 0 additions & 100 deletions
100
cyral/internal/integration/teams/resource_cyral_integration_teams.go
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.