Add tailscale driver

Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-28 11:52:22 -07:00
parent dd547471e6
commit d579879707
16 changed files with 518 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import (
"time"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"go.gearno.de/kit/pg"
"go.probo.inc/probo/pkg/connector"
"go.probo.inc/probo/pkg/crypto/cipher"
@@ -401,6 +402,12 @@ INSERT INTO connectors (
_, err = conn.Exec(ctx, q, args)
if err != nil {
if pgErr, ok := errors.AsType[*pgconn.PgError](err); ok {
if pgErr.Code == "23505" && pgErr.ConstraintName == "idx_connectors_organization_id_provider" {
return ErrResourceAlreadyExists
}
}
return fmt.Errorf("cannot insert connector: %w", err)
}

View File

@@ -49,6 +49,7 @@ const (
ConnectorProviderClickUp ConnectorProvider = "CLICKUP"
ConnectorProviderVercel ConnectorProvider = "VERCEL"
ConnectorProviderMonday ConnectorProvider = "MONDAY"
ConnectorProviderTailscale ConnectorProvider = "TAILSCALE"
)
var (
@@ -85,6 +86,7 @@ func ConnectorProviders() []ConnectorProvider {
ConnectorProviderClickUp,
ConnectorProviderVercel,
ConnectorProviderMonday,
ConnectorProviderTailscale,
}
}
@@ -116,7 +118,8 @@ func (v ConnectorProvider) IsValid() bool {
ConnectorProviderNetlify,
ConnectorProviderClickUp,
ConnectorProviderVercel,
ConnectorProviderMonday:
ConnectorProviderMonday,
ConnectorProviderTailscale:
return true
}

View File

@@ -0,0 +1,15 @@
-- Copyright (c) 2026 Probo Inc <hello@getprobo.com>.
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
-- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
ALTER TYPE connector_provider ADD VALUE IF NOT EXISTS 'TAILSCALE';

View File

@@ -265,6 +265,32 @@ LIMIT 1;
return nil
}
func (s *SCIMBridges) CountByConnectorID(
ctx context.Context,
conn pg.Querier,
scope Scoper,
connectorID gid.GID,
) (int, error) {
q := `
SELECT COUNT(id)
FROM iam_scim_bridges
WHERE
%s
AND connector_id = @connector_id;
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"connector_id": connectorID}
maps.Copy(args, scope.SQLArguments())
var count int
if err := conn.QueryRow(ctx, q, args).Scan(&count); err != nil {
return 0, fmt.Errorf("cannot count iam_scim_bridges by connector ID: %w", err)
}
return count, nil
}
func (s *SCIMBridge) Insert(
ctx context.Context,
conn pg.Tx,