-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
947 additions
and
53 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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Terraform Provider for the Steamdal eco system | ||
# Terraform Provider for the Steamdal ecosystem | ||
|
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
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,32 @@ | ||
terraform { | ||
required_providers { | ||
streamdal = { | ||
version = "0.1.0" | ||
source = "streamdal.com/tf/streamdal" | ||
} | ||
} | ||
} | ||
|
||
provider "streamdal" { | ||
token = "1234" | ||
address = "localhost:8082" | ||
connection_timeout = 10 | ||
} | ||
|
||
variable "notification_config_id" { | ||
type = string | ||
|
||
# Wildcards "*" are accepted | ||
default = "test slack *" | ||
} | ||
|
||
data "streamdal_notification" "slack_test" { | ||
filter { | ||
name = "name" | ||
values = [var.notification_config_id] | ||
} | ||
} | ||
|
||
output "notification" { | ||
value = data.streamdal_notification.slack_test | ||
} |
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
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
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,57 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/streamdal/terraform-provider-streamdal/streamdal" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func dataSourceNotification() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceNotificationRead, | ||
SchemaVersion: 1, | ||
Schema: map[string]*schema.Schema{ | ||
"filter": dataSourceFiltersSchema(), | ||
"id": { | ||
Description: "Notification Config ID", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
"name": { | ||
Description: "Pipeline name", | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceNotificationRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
var diags diag.Diagnostics | ||
var filters []*streamdal.Filter | ||
|
||
s := m.(*streamdal.Streamdal) | ||
|
||
if v, ok := d.GetOk("filter"); ok { | ||
filters = buildFiltersDataSource(v.(*schema.Set)) | ||
} else { | ||
return append(diags, diag.Diagnostic{ | ||
Severity: diag.Error, | ||
Summary: "No filters defined", | ||
Detail: "At least one filter must be defined", | ||
}) | ||
} | ||
|
||
notificationCfg, moreDiags := s.GetNotificationConfigFilter(filters) | ||
if moreDiags.HasError() { | ||
return append(diags, moreDiags...) | ||
} | ||
|
||
d.SetId(notificationCfg["id"].(string)) | ||
_ = d.Set("name", notificationCfg["name"].(string)) | ||
|
||
return diags | ||
} |
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
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
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
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
Oops, something went wrong.