Skip to content

Commit

Permalink
revert change for NotificationTriggerType
Browse files Browse the repository at this point in the history
  • Loading branch information
uturunku1 committed Feb 24, 2022
1 parent ac9a8f4 commit bbba200
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion helper_test.go
Expand Up @@ -164,7 +164,7 @@ func createNotificationConfiguration(t *testing.T, client *Client, w *Workspace,
Name: String(randomString(t)),
Token: String(randomString(t)),
URL: String("http://example.com"),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
Triggers: []string{NotificationTriggerCreated},
}
}

Expand Down
20 changes: 9 additions & 11 deletions notification_configuration.go
Expand Up @@ -40,15 +40,13 @@ type notificationConfigurations struct {
client *Client
}

type NotificationTriggerType string

const (
NotificationTriggerCreated NotificationTriggerType = "run:created"
NotificationTriggerPlanning NotificationTriggerType = "run:planning"
NotificationTriggerNeedsAttention NotificationTriggerType = "run:needs_attention"
NotificationTriggerApplying NotificationTriggerType = "run:applying"
NotificationTriggerCompleted NotificationTriggerType = "run:completed"
NotificationTriggerErrored NotificationTriggerType = "run:errored"
NotificationTriggerCreated string = "run:created"
NotificationTriggerPlanning string = "run:planning"
NotificationTriggerNeedsAttention string = "run:needs_attention"
NotificationTriggerApplying string = "run:applying"
NotificationTriggerCompleted string = "run:completed"
NotificationTriggerErrored string = "run:errored"
)

// NotificationDestinationType represents the destination type of the
Expand Down Expand Up @@ -78,7 +76,7 @@ type NotificationConfiguration struct {
Enabled bool `jsonapi:"attr,enabled"`
Name string `jsonapi:"attr,name"`
Token string `jsonapi:"attr,token"`
Triggers []NotificationTriggerType `jsonapi:"attr,triggers"`
Triggers []string `jsonapi:"attr,triggers"`
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
URL string `jsonapi:"attr,url"`

Expand Down Expand Up @@ -149,7 +147,7 @@ type NotificationConfigurationCreateOptions struct {
Token *string `jsonapi:"attr,token,omitempty"`

// Optional: The list of run events that will trigger notifications.
Triggers []NotificationTriggerType `jsonapi:"attr,triggers,omitempty"`
Triggers []string `jsonapi:"attr,triggers,omitempty"`

// Optional: The url of the notification configuration
URL *string `jsonapi:"attr,url,omitempty"`
Expand Down Expand Up @@ -245,7 +243,7 @@ type NotificationConfigurationUpdateOptions struct {
Token *string `jsonapi:"attr,token,omitempty"`

// Optional: The list of run events that will trigger notifications.
Triggers []NotificationTriggerType `jsonapi:"attr,triggers,omitempty"`
Triggers []string `jsonapi:"attr,triggers,omitempty"`

// Optional: The url of the notification configuration
URL *string `jsonapi:"attr,url,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions notification_configuration_integration_test.go
Expand Up @@ -93,7 +93,7 @@ func TestNotificationConfigurationCreate(t *testing.T) {
Name: String(randomString(t)),
Token: String(randomString(t)),
URL: String("http://example.com"),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
Triggers: []string{NotificationTriggerCreated},
}

_, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
Expand All @@ -106,7 +106,7 @@ func TestNotificationConfigurationCreate(t *testing.T) {
Enabled: Bool(false),
Token: String(randomString(t)),
URL: String("http://example.com"),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
Triggers: []string{NotificationTriggerCreated},
}

nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
Expand All @@ -120,7 +120,7 @@ func TestNotificationConfigurationCreate(t *testing.T) {
Enabled: Bool(false),
Name: String(randomString(t)),
Token: String(randomString(t)),
Triggers: []NotificationTriggerType{NotificationTriggerCreated},
Triggers: []string{NotificationTriggerCreated},
}

nc, err := client.NotificationConfigurations.Create(ctx, wTest.ID, options)
Expand Down

0 comments on commit bbba200

Please sign in to comment.