Skip to content

Commit 522106f

Browse files
authored
Merge branch 'main' into add_account_provisioning
2 parents 088103f + 669d8dc commit 522106f

File tree

5 files changed

+50
-50
lines changed

5 files changed

+50
-50
lines changed

baton_capabilities.json

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
11
{
2-
"@type": "type.googleapis.com/c1.connector.v2.ConnectorCapabilities",
3-
"resourceTypeCapabilities": [
2+
"@type": "type.googleapis.com/c1.connector.v2.ConnectorCapabilities",
3+
"resourceTypeCapabilities": [
44
{
5-
"resourceType": {
6-
"id": "account",
7-
"displayName": "Account"
5+
"resourceType": {
6+
"id": "account",
7+
"displayName": "Account"
88
},
9-
"capabilities": [
9+
"capabilities": [
1010
"CAPABILITY_SYNC",
1111
"CAPABILITY_PROVISION"
1212
]
1313
},
1414
{
15-
"resourceType": {
16-
"id": "group",
17-
"displayName": "Group",
18-
"traits": [
15+
"resourceType": {
16+
"id": "group",
17+
"displayName": "Group",
18+
"traits": [
1919
"TRAIT_GROUP"
2020
]
2121
},
22-
"capabilities": [
22+
"capabilities": [
2323
"CAPABILITY_SYNC",
2424
"CAPABILITY_PROVISION"
2525
]
2626
},
2727
{
28-
"resourceType": {
29-
"id": "role",
30-
"displayName": "Role",
31-
"traits": [
28+
"resourceType": {
29+
"id": "role",
30+
"displayName": "Role",
31+
"traits": [
3232
"TRAIT_ROLE"
3333
]
3434
},
35-
"capabilities": [
35+
"capabilities": [
3636
"CAPABILITY_SYNC",
3737
"CAPABILITY_PROVISION"
3838
]
3939
},
4040
{
41-
"resourceType": {
42-
"id": "service_principal",
43-
"displayName": "Service Principal",
44-
"traits": [
41+
"resourceType": {
42+
"id": "service_principal",
43+
"displayName": "Service Principal",
44+
"traits": [
4545
"TRAIT_GROUP"
4646
]
4747
},
48-
"capabilities": [
48+
"capabilities": [
4949
"CAPABILITY_SYNC",
5050
"CAPABILITY_PROVISION"
5151
]
5252
},
5353
{
54-
"resourceType": {
55-
"id": "user",
56-
"displayName": "User",
57-
"traits": [
54+
"resourceType": {
55+
"id": "user",
56+
"displayName": "User",
57+
"traits": [
5858
"TRAIT_USER"
5959
],
60-
"annotations": [
60+
"annotations": [
6161
{
62-
"@type": "type.googleapis.com/c1.connector.v2.SkipEntitlementsAndGrants"
62+
"@type": "type.googleapis.com/c1.connector.v2.SkipEntitlementsAndGrants"
6363
}
6464
]
6565
},
66-
"capabilities": [
66+
"capabilities": [
6767
"CAPABILITY_SYNC"
6868
]
6969
},
7070
{
71-
"resourceType": {
72-
"id": "workspace",
73-
"displayName": "Workspace",
74-
"traits": [
71+
"resourceType": {
72+
"id": "workspace",
73+
"displayName": "Workspace",
74+
"traits": [
7575
"TRAIT_GROUP"
7676
]
7777
},
78-
"capabilities": [
78+
"capabilities": [
7979
"CAPABILITY_SYNC",
8080
"CAPABILITY_PROVISION"
8181
]
8282
}
8383
],
84-
"connectorCapabilities": [
84+
"connectorCapabilities": [
8585
"CAPABILITY_PROVISION",
8686
"CAPABILITY_SYNC"
8787
],
88-
"credentialDetails": {}
88+
"credentialDetails": {}
8989
}
File renamed without changes.

cmd/baton-databricks/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/conductorone/baton-databricks/pkg/config"
8+
"github.com/conductorone/baton-databricks/cmd/baton-databricks/config"
99
configSchema "github.com/conductorone/baton-sdk/pkg/config"
1010
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
1111
"github.com/conductorone/baton-sdk/pkg/types"
@@ -20,6 +20,7 @@ import (
2020
var (
2121
connectorName = "baton-databricks"
2222
version = "dev"
23+
defaultHost = "cloud.databricks.com"
2324
)
2425

2526
func main() {
@@ -58,7 +59,7 @@ func prepareClientAuth(ctx context.Context, cfg *viper.Viper) databricks.Auth {
5859
password := cfg.GetString(config.PasswordField.FieldName)
5960
workspaces := cfg.GetStringSlice(config.WorkspacesField.FieldName)
6061
tokens := cfg.GetStringSlice(config.TokensField.FieldName)
61-
accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg))
62+
accountHostname := databricks.GetAccountHostname(getHostname(cfg))
6263

6364
switch {
6465
case username != "" && password != "":
@@ -108,8 +109,8 @@ func getConnector(ctx context.Context, cfg *viper.Viper) (types.ConnectorServer,
108109
return nil, err
109110
}
110111

111-
hostname := databricks.GetHostname(cfg)
112-
accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg))
112+
hostname := getHostname(cfg)
113+
accountHostname := databricks.GetAccountHostname(getHostname(cfg))
113114
auth := prepareClientAuth(ctx, cfg)
114115
cb, err := connector.New(
115116
ctx,
@@ -132,3 +133,10 @@ func getConnector(ctx context.Context, cfg *viper.Viper) (types.ConnectorServer,
132133

133134
return c, nil
134135
}
136+
137+
func getHostname(cfg *viper.Viper) string {
138+
if cfg.GetString(config.HostnameField.FieldName) == "" {
139+
return defaultHost
140+
}
141+
return cfg.GetString(config.HostnameField.FieldName)
142+
}

pkg/databricks/client.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ import (
77
"net/url"
88
"strings"
99

10-
"github.com/conductorone/baton-databricks/pkg/config"
1110
v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2"
1211
"github.com/conductorone/baton-sdk/pkg/uhttp"
13-
"github.com/spf13/viper"
1412
)
1513

1614
const (
15+
1716
defaultHost = "cloud.databricks.com" // aws
18-
azureHost = "azuredatabricks.net"
19-
gcpHost = "gcp.databricks.net"
17+
azureHost = "azuredatabricks.net"
18+
gcpHost = "gcp.databricks.net"
2019

2120
// Some of these are case sensitive.
2221
usersEndpoint = "/api/2.0/preview/scim/v2/Users"
@@ -47,13 +46,6 @@ type Client struct {
4746
isWSAPIAvailable bool
4847
}
4948

50-
func GetHostname(cfg *viper.Viper) string {
51-
if cfg.GetString(config.HostnameField.FieldName) == "" {
52-
return defaultHost
53-
}
54-
return cfg.GetString(config.HostnameField.FieldName)
55-
}
56-
5749
func GetAccountHostname(hostname string) string {
5850
if strings.HasSuffix(hostname, azureHost) {
5951
return "accounts." + azureHost

0 commit comments

Comments
 (0)