@@ -135,16 +135,39 @@ export function isCloudsmithConfig(
135135 return json . validateSchema ( cloudsmithConfigSchema , config ) ;
136136}
137137
138+ /** A schema for GCP OIDC configurations. */
139+ export const gcpConfigSchema = {
140+ "workload-identity-provider" : json . string ,
141+ "service-account" : json . optional ( json . string ) ,
142+ audience : json . optional ( json . string ) ,
143+ } as const satisfies json . Schema ;
144+
145+ /** Configuration for GCP OIDC. */
146+ export type GCPConfig = json . FromSchema < typeof gcpConfigSchema > ;
147+
148+ /** Decides whether `config` is a GCP OIDC configuration. */
149+ export function isGCPConfig (
150+ config : UnvalidatedObject < AuthConfig > ,
151+ ) : config is GCPConfig {
152+ return json . validateSchema ( gcpConfigSchema , config ) ;
153+ }
154+
138155/** An array of all OIDC configuration schemas along with output-friendly names. */
139156export const oidcSchemas = [
140157 { schema : azureConfigSchema , name : "Azure" } ,
141158 { schema : awsConfigSchema , name : "AWS" } ,
142159 { schema : jfrogConfigSchema , name : "JFrog" } ,
143160 { schema : cloudsmithConfigSchema , name : "Cloudsmith" } ,
161+ { schema : gcpConfigSchema , name : "GCP" } ,
144162] ;
145163
146164/** Represents all supported OIDC configurations. */
147- export type OIDC = AzureConfig | AWSConfig | JFrogConfig | CloudsmithConfig ;
165+ export type OIDC =
166+ | AzureConfig
167+ | AWSConfig
168+ | JFrogConfig
169+ | CloudsmithConfig
170+ | GCPConfig ;
148171
149172/** All authentication-related fields. */
150173export type AuthConfig = UsernamePassword | Token | OIDC ;
@@ -207,6 +230,13 @@ export function credentialToStr(credential: Credential): string {
207230 appendIfDefined ( "Cloudsmith Namespace" , credential . namespace ) ;
208231 appendIfDefined ( "Cloudsmith Service Slug" , credential [ "service-slug" ] ) ;
209232 appendIfDefined ( "Cloudsmith API Host" , credential [ "api-host" ] ) ;
233+ } else if ( isGCPConfig ( credential ) ) {
234+ appendIfDefined (
235+ "GCP Workload Identity Provider" ,
236+ credential [ "workload-identity-provider" ] ,
237+ ) ;
238+ appendIfDefined ( "GCP Service Account" , credential [ "service-account" ] ) ;
239+ appendIfDefined ( "GCP Audience" , credential . audience ) ;
210240 }
211241
212242 return result ;
0 commit comments