Move Vercel /v2/user fetch to pkg/connector/vercel.go → Migrate connector settings callers to generic

- Move Vercel /v2/user fetch to pkg/connector/vercel.go
- Authorize NeedsConfiguration and SelectedOrganization
- Add coredata.ConnectorSettings[T] generic helper
- Migrate connector settings callers to generic

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-05-17 17:22:49 +02:00
parent caec9f1ad5
commit 8917b46541
8 changed files with 154 additions and 72 deletions

View File

@@ -214,7 +214,7 @@ func (c *Connector) LoadByID(
if c.Provider == ConnectorProviderSlack {
if slackConn, ok := c.Connection.(*connector.SlackConnection); ok {
settings, _ := c.SlackSettings()
settings, _ := ConnectorSettings[SlackConnectorSettings](c)
slackConn.Settings.Channel = settings.Channel
slackConn.Settings.ChannelID = settings.ChannelID
}
@@ -613,7 +613,7 @@ func (c *Connectors) decryptConnections(encryptionKey cipher.EncryptionKey) erro
if cnnctr.Provider == ConnectorProviderSlack {
if slackConn, ok := cnnctr.Connection.(*connector.SlackConnection); ok {
settings, _ := cnnctr.SlackSettings()
settings, _ := ConnectorSettings[SlackConnectorSettings](cnnctr)
slackConn.Settings.Channel = settings.Channel
slackConn.Settings.ChannelID = settings.ChannelID
}

View File

@@ -250,3 +250,16 @@ func (c *Connector) unmarshalSettings(v any) error {
}
return nil
}
// ConnectorSettings unmarshals the connector's RawSettings into the
// requested settings struct. Empty or null RawSettings yields the zero
// value with no error. Use as:
//
// settings, err := coredata.ConnectorSettings[coredata.GitHubConnectorSettings](dbConnector)
func ConnectorSettings[T any](c *Connector) (T, error) {
var s T
if err := c.unmarshalSettings(&s); err != nil {
return s, err
}
return s, nil
}