Skip to content

Commit 3be1608

Browse files
committed
Claude: GCP Connection, holds Service Account Key
1 parent 3b52de4 commit 3be1608

16 files changed

Lines changed: 259 additions & 14 deletions

File tree

Cargo.lock

Lines changed: 86 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ futures = "0.3.32"
346346
futures-core = "0.3.31"
347347
futures-task = "0.3.31"
348348
futures-util = "0.3.31"
349+
gcp_auth = "0.12.6"
349350
glob = "0.3.3"
350351
globset = "0.4.18"
351352
governor = "0.10.1"

deny.toml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ skip = [
130130
{ name = "hashbrown", version = "0.16.1" },
131131
# Used by dynfmt; iceberg/typetag pulls in v0.4.
132132
{ name = "erased-serde", version = "0.3.26" },
133+
# gcp_auth → hyper-rustls → rustls-native-certs pulls newer versions
134+
# while native-tls still pulls older versions.
135+
{ name = "core-foundation", version = "0.10.1" },
136+
{ name = "security-framework", version = "3.7.0" },
137+
{ name = "openssl-probe", version = "0.2.1" },
138+
# reqsign (via iceberg-storage-opendal / opendal) pins older deps
139+
# than the workspace.
140+
{ name = "jsonwebtoken", version = "9.3.1" },
141+
{ name = "quick-xml", version = "0.37.5" },
142+
# aws-lc-rs (via jsonwebtoken 10) and ring pull different `untrusted`.
143+
{ name = "untrusted", version = "0.7.1" },
144+
# Held back by lazy_static 1.4.0 (used by num-bigint-dig).
145+
{ name = "spin", version = "0.5.2" },
133146
]
134147

135148
[[bans.deny]]
@@ -206,9 +219,11 @@ wrappers = [
206219
]
207220

208221
# We prefer the system's native TLS or OpenSSL to Rustls, since they are more
209-
# mature and more widely used.
222+
# mature and more widely used. `gcp_auth` only ships with rustls-based TLS,
223+
# so allow it through.
210224
[[bans.deny]]
211225
name = "rustls"
226+
wrappers = ["hyper-rustls", "tokio-rustls"]
212227

213228
# once_cell is going to be added to std, and doesn't use macros
214229
# Unfortunately, its heavily used, so we have lots of exceptions.
@@ -219,6 +234,7 @@ wrappers = [
219234
"findshlibs",
220235
"launchdarkly-server-sdk",
221236
"launchdarkly-server-sdk-evaluation",
237+
"num-bigint-dig",
222238
"prometheus",
223239
"rayon-core",
224240
"sharded-slab",

src/adapter/src/catalog/builtin_table_updates.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ impl CatalogState {
10391039
updates.push(self.pack_ssh_tunnel_connection_update(id, key_1, key_2, diff));
10401040
}
10411041
ConnectionDetails::Csr(_)
1042+
| ConnectionDetails::Gcp(_)
10421043
| ConnectionDetails::Postgres(_)
10431044
| ConnectionDetails::MySql(_)
10441045
| ConnectionDetails::SqlServer(_)

src/adapter/src/catalog/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,7 @@ impl ConnectionResolver for CatalogState {
27772777
Ssh(conn) => Ssh(conn),
27782778
Aws(conn) => Aws(conn),
27792779
AwsPrivatelink(conn) => AwsPrivatelink(conn),
2780+
Gcp(conn) => Gcp(conn),
27802781
MySql(conn) => MySql(conn.into_inline_connection(self)),
27812782
SqlServer(conn) => SqlServer(conn.into_inline_connection(self)),
27822783
IcebergCatalog(conn) => IcebergCatalog(conn.into_inline_connection(self)),

src/adapter/src/coord/ddl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ impl Coordinator {
11351135
ConnectionDetails::Csr(_)
11361136
| ConnectionDetails::Ssh { .. }
11371137
| ConnectionDetails::Aws(_)
1138+
| ConnectionDetails::Gcp(_)
11381139
| ConnectionDetails::IcebergCatalog(_) => {}
11391140
},
11401141
CatalogItem::Table(_) => {
@@ -1311,6 +1312,7 @@ impl Coordinator {
13111312
ConnectionDetails::Csr(_)
13121313
| ConnectionDetails::Ssh { .. }
13131314
| ConnectionDetails::Aws(_)
1315+
| ConnectionDetails::Gcp(_)
13141316
| ConnectionDetails::IcebergCatalog(_) => {}
13151317
}
13161318
}

src/sql-lexer/src/keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
Abort
2727
Access
28+
Account
2829
Action
2930
Add
3031
Added
@@ -200,6 +201,7 @@ Full
200201
Fullname
201202
Function
202203
Fusion
204+
Gcp
203205
Generator
204206
Grant
205207
Greatest

src/sql-parser/src/ast/defs/ddl.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ pub enum ConnectionOptionName {
791791
Scope,
792792
SecretAccessKey,
793793
SecurityProtocol,
794+
ServiceAccountKey,
794795
ServiceName,
795796
SshTunnel,
796797
SslCertificate,
@@ -834,6 +835,7 @@ impl AstDisplay for ConnectionOptionName {
834835
ConnectionOptionName::Scope => "SCOPE",
835836
ConnectionOptionName::SecurityProtocol => "SECURITY PROTOCOL",
836837
ConnectionOptionName::SecretAccessKey => "SECRET ACCESS KEY",
838+
ConnectionOptionName::ServiceAccountKey => "SERVICE ACCOUNT KEY",
837839
ConnectionOptionName::ServiceName => "SERVICE NAME",
838840
ConnectionOptionName::SshTunnel => "SSH TUNNEL",
839841
ConnectionOptionName::SslCertificate => "SSL CERTIFICATE",
@@ -883,6 +885,7 @@ impl WithOptionName for ConnectionOptionName {
883885
| ConnectionOptionName::Scope
884886
| ConnectionOptionName::SecurityProtocol
885887
| ConnectionOptionName::SecretAccessKey
888+
| ConnectionOptionName::ServiceAccountKey
886889
| ConnectionOptionName::ServiceName
887890
| ConnectionOptionName::SshTunnel
888891
| ConnectionOptionName::SslCertificate
@@ -911,6 +914,7 @@ impl_display_t!(ConnectionOption);
911914
pub enum CreateConnectionType {
912915
Aws,
913916
AwsPrivatelink,
917+
Gcp,
914918
Kafka,
915919
Csr,
916920
Postgres,
@@ -928,6 +932,7 @@ impl CreateConnectionType {
928932
Self::Postgres => "postgres",
929933
Self::Aws => "aws",
930934
Self::AwsPrivatelink => "aws-privatelink",
935+
Self::Gcp => "gcp",
931936
Self::Ssh => "ssh-tunnel",
932937
Self::MySql => "mysql",
933938
Self::SqlServer => "sql-server",
@@ -954,6 +959,9 @@ impl AstDisplay for CreateConnectionType {
954959
Self::AwsPrivatelink => {
955960
f.write_str("AWS PRIVATELINK");
956961
}
962+
Self::Gcp => {
963+
f.write_str("GCP");
964+
}
957965
Self::Ssh => {
958966
f.write_str("SSH TUNNEL");
959967
}

src/sql-parser/src/parser.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,16 +2456,17 @@ impl<'a> Parser<'a> {
24562456
TO => true,
24572457
_ => unreachable!(),
24582458
};
2459-
let connection_type = match self
2460-
.expect_one_of_keywords(&[AWS, KAFKA, CONFLUENT, POSTGRES, SSH, SQL, MYSQL, ICEBERG])?
2461-
{
2459+
let connection_type = match self.expect_one_of_keywords(&[
2460+
AWS, GCP, KAFKA, CONFLUENT, POSTGRES, SSH, SQL, MYSQL, ICEBERG,
2461+
])? {
24622462
AWS => {
24632463
if self.parse_keyword(PRIVATELINK) {
24642464
CreateConnectionType::AwsPrivatelink
24652465
} else {
24662466
CreateConnectionType::Aws
24672467
}
24682468
}
2469+
GCP => CreateConnectionType::Gcp,
24692470
KAFKA => CreateConnectionType::Kafka,
24702471
CONFLUENT => {
24712472
self.expect_keywords(&[SCHEMA, REGISTRY])?;
@@ -2873,10 +2874,14 @@ impl<'a> Parser<'a> {
28732874
self.expect_keywords(&[ACCESS, KEY])?;
28742875
ConnectionOptionName::SecretAccessKey
28752876
}
2876-
SERVICE => {
2877-
self.expect_keyword(NAME)?;
2878-
ConnectionOptionName::ServiceName
2879-
}
2877+
SERVICE => match self.expect_one_of_keywords(&[ACCOUNT, NAME])? {
2878+
ACCOUNT => {
2879+
self.expect_keyword(KEY)?;
2880+
ConnectionOptionName::ServiceAccountKey
2881+
}
2882+
NAME => ConnectionOptionName::ServiceName,
2883+
_ => unreachable!(),
2884+
},
28802885
SESSION => {
28812886
self.expect_keyword(TOKEN)?;
28822887
ConnectionOptionName::SessionToken

src/sql-parser/tests/testdata/ddl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ CREATE CONNECTION privatelinkconn TO AWS PRIVATELINK (SERVICE NAME = 'com.amazon
561561
=>
562562
CreateConnection(CreateConnectionStatement { name: UnresolvedItemName([Ident("privatelinkconn")]), connection_type: AwsPrivatelink, if_not_exists: false, values: [ConnectionOption { name: ServiceName, value: Some(Value(String("com.amazonaws.vpce.us-east-1.vpce-svc-0e123abc123198abc"))) }, ConnectionOption { name: AvailabilityZones, value: Some(Sequence([Value(String("use1-az1")), Value(String("use1-az4"))])) }], with_options: [] })
563563

564+
parse-statement
565+
CREATE CONNECTION gcpconn TO GCP (SERVICE ACCOUNT KEY = SECRET keyfile)
566+
----
567+
CREATE CONNECTION gcpconn TO GCP (SERVICE ACCOUNT KEY = SECRET keyfile)
568+
=>
569+
CreateConnection(CreateConnectionStatement { name: UnresolvedItemName([Ident("gcpconn")]), connection_type: Gcp, if_not_exists: false, values: [ConnectionOption { name: ServiceAccountKey, value: Some(Secret(Name(UnresolvedItemName([Ident("keyfile")])))) }], with_options: [] })
570+
564571
parse-statement
565572
CREATE CONNECTION privatelinkconn TO AWS PRIVATELINK (SERVICE NAME 'com.amazonaws.vpce.us-east-1.vpce-svc-0e123abc123198abc', AVAILABILITY ZONES ('use1-az1', 'use1-az4')) WITH (VALIDATE = FALSE)
566573
----

0 commit comments

Comments
 (0)