8000 🐛 Mark Webex roomId and toPersonEmail as exactly one by abahmed · Pull Request #612 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deploy/provider-catalog.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pushover|Pushover|retry|integer|false|false|integer||Emergency retry interval in
pushover|Pushover|expire|integer|false|false|integer||Emergency expiration in seconds
pushover|Pushover|title|string|false|false|||Custom title
webex|Webex|accessToken|string|true|true|||Bot access token
webex|Webex|roomId|string|false|false|||Room ID (set exactly one of roomId or toPersonEmail)|destination|at-least-one
webex|Webex|toPersonEmail|string|false|false|||Person email (set exactly one of roomId or toPersonEmail)|destination|at-least-one
webex|Webex|roomId|string|false|false|||Room ID (set exactly one of roomId or toPersonEmail)|destination|exactly-one
webex|Webex|toPersonEmail|string|false|false|||Person email (set exactly one of roomId or toPersonEmail)|destination|exactly-one
github|GitHub|token|string|true|true|||Personal access token
github|GitHub|owner|string|true|false|||Repository owner
github|GitHub|repo|string|true|false|||Repository name
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ the catalog is informational and does not change runtime behavior.
Guided notification setup uses `deploy/provider-catalog.tsv`. It covers every
supported provider and documented provider field, and marks every credential
field as Secret-backed. It can also describe provider-specific choice groups,
conditional fields, and at-least-one destination groups (for example, one
conditional fields, and at-least-one or exactly-one destination groups (for example, one
authentication method requiring a channel). The installer interprets those
relationships generically, so adding a new provider does not require
provider-specific shell logic. Provider credentials never appear in the
Expand Down
4 changes: 2 additions & 2 deletions internal/config/provider_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func validateProviderCondition(group, condition string) error {
}
return nil
}
if condition == "at-least-one" {
if condition == "at-least-one" || condition == "exactly-one" {
if group == "" {
return fmt.Errorf("at-least-one conditions need a group")
return fmt.Errorf("%s conditions need a group", condition)
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/config/provider_catalog.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ pushover|Pushover|retry|integer|false|false|integer||Emergency retry interval in
pushover|Pushover|expire|integer|false|false|integer||Emergency expiration in seconds
pushover|Pushover|title|string|false|false|||Custom title
webex|Webex|accessToken|string|true|true|||Bot access token
webex|Webex|roomId|string|false|false|||Room ID (set exactly one of roomId or toPersonEmail)|destination|at-least-one
webex|Webex|toPersonEmail|string|false|false|||Person email (set exactly one of roomId or toPersonEmail)|destination|at-least-one
webex|Webex|roomId|string|false|false|||Room ID (set exactly one of roomId or toPersonEmail)|destination|exactly-one
webex|Webex|toPersonEmail|string|false|false|||Person email (set exactly one of roomId or toPersonEmail)|destination|exactly-one
github|GitHub|token|string|true|true|||Personal access token
github|GitHub|owner|string|true|false|||Repository owner
github|GitHub|repo|string|true|false|||Repository name
Expand Down
10 changes: 8 additions & 2 deletions internal/config/secret_refs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ func TestProviderCatalogDescribesConditionalCredentials(t *testing.T) {
assert.Equal(t, "destination", fields["sns.topicArn"].Group)
assert.Equal(t, "choice:target", fields["sns.targetArn"].Condition)
assert.Equal(t, "destination", fields["webex.roomId"].Group)
assert.Equal(t, "at-least-one", fields["webex.roomId"].Condition)
assert.Equal(t, "at-least-one", fields["webex.toPersonEmail"].Condition)
assert.Equal(t, "exactly-one", fields["webex.roomId"].Condition)
assert.Equal(t, "exactly-one", fields["webex.toPersonEmail"].Condition)
}

func providerCatalogTestConfig(field ProviderField, value string) string {
Expand Down Expand Up @@ -191,3 +191,9 @@ func TestProxyURLWithCredentialsMustBeFileReference(t *testing.T) {
})
}
}

func TestValidateProviderConditionExactlyOne(t *testing.T) {
assert.NoError(t, validateProviderCondition("destination", "exactly-one"))
assert.Error(t, validateProviderCondition("", "exactly-one"))
assert.Error(t, validateProviderCondition("destination", "exactly-two"))
}
0