-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
AuthV0.kt
350 lines (337 loc) · 15.8 KB
/
AuthV0.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
// This file was generated using action-binding-generator. Don't change it by hand, otherwise your
// changes will be overwritten with the next binding code regeneration.
// See https://github.com/typesafegithub/github-workflows-kt for more info.
@file:Suppress(
"DataClassPrivateConstructor",
"UNUSED_PARAMETER",
"DEPRECATION",
)
package io.github.typesafegithub.workflows.actions.googlegithubactions
import io.github.typesafegithub.workflows.domain.actions.Action
import io.github.typesafegithub.workflows.domain.actions.RegularAction
import java.util.LinkedHashMap
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.collections.toList
import kotlin.collections.toTypedArray
/**
* Action: Authenticate to Google Cloud
*
* Authenticate to Google Cloud from GitHub Actions via Workload Identity
* Federation or service account keys.
*
* [Action on GitHub](https://github.com/google-github-actions/auth)
*
* @param projectId ID of the default project to use for future API calls and invocations. If
* unspecified, this action will attempt to extract the value from other
* inputs such as "service_account" or "credentials_json".
* @param workloadIdentityProvider The full identifier of the Workload Identity Provider, including
* the
* project number, pool name, and provider name. If provided, this must be
* the full identifier which includes all parts, for example:
* "projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider".
* This is mutually exclusive with "credentials_json".
* @param serviceAccount Email address or unique identifier of the Google Cloud service account for
* which to generate credentials. This is required if
* "workload_identity_provider" is specified.
* @param audience The value for the audience (aud) parameter in GitHub's generated OIDC
* token. This value defaults to the value of "workload_identity_provider",
* which is also the default value Google Cloud expects for the audience
* parameter on the token.
* @param credentialsJson The Google Cloud JSON service account key to use for authentication. This
* is mutually exclusive with "workload_identity_provider".
* @param createCredentialsFile If true, the action will securely generate a credentials file which
* can be
* used for authentication via gcloud and Google Cloud SDKs.
* @param exportEnvironmentVariables If true, the action will export common environment variables
* which are
* known to be consumed by popular downstream libraries and tools, including:
*
* - CLOUDSDK_PROJECT
* - CLOUDSDK_CORE_PROJECT
* - GCP_PROJECT
* - GCLOUD_PROJECT
* - GOOGLE_CLOUD_PROJECT
*
* If "create_credentials_file" is true, additional environment variables are
* exported:
*
* - CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE
* - GOOGLE_APPLICATION_CREDENTIALS
* - GOOGLE_GHA_CREDS_PATH
*
* If false, the action will not export any environment variables, meaning
* future steps are unlikely to be automatically authenticated to Google
* Cloud.
* @param tokenFormat Output format for the generated authentication token. For OAuth 2.0 access
* tokens, specify "access_token". For OIDC tokens, specify "id_token". To
* skip token generation, leave this value empty.
* @param delegates List of additional service account emails or unique identities to use for
* impersonation in the chain.
* @param cleanupCredentials If true, the action will remove any created credentials from the
* filesystem upon completion. This only applies if "create_credentials_file"
* is true.
* @param accessTokenLifetime Desired lifetime duration of the access token, in seconds. This must
* be
* specified as the number of seconds with a trailing "s" (e.g. 30s). This is
* only valid when "token_format" is "access_token".
* @param accessTokenScopes List of OAuth 2.0 access scopes to be included in the generated token.
* This is only valid when "token_format" is "access_token".
* @param accessTokenSubject Email address of a user to impersonate for Domain-Wide Delegation
* Access
* tokens created for Domain-Wide Delegation cannot have a lifetime beyond 1
* hour. This is only valid when "token_format" is "access_token".
* @param retries Number of times to retry a failed authentication attempt. This is useful
* for automated pipelines that may execute before IAM permissions are fully propogated.
* @param backoff Delay time before trying another authentication attempt. This
* is implemented using a fibonacci backoff method (e.g. 1-1-2-3-5).
* This value defaults to 100 milliseconds when retries are greater than 0.
* @param backoffLimit Limits the retry backoff to the specified value.
* @param idTokenAudience The audience (aud) for the generated Google Cloud ID Token. This is only
* valid when "token_format" is "id_token".
* @param idTokenIncludeEmail Optional parameter of whether to include the service account email in
* the
* generated token. If true, the token will contain "email" and
* "email_verified" claims. This is only valid when "token_format" is
* "id_token".
* @param _customInputs Type-unsafe map where you can put any inputs that are not yet supported by
* the binding
* @param _customVersion Allows overriding action's version, for example to use a specific minor
* version, or a newer version that the binding doesn't yet know about
*/
@Deprecated(
message = "This action has a newer major version: AuthV2",
replaceWith = ReplaceWith("AuthV2"),
)
public data class AuthV0 private constructor(
/**
* ID of the default project to use for future API calls and invocations. If
* unspecified, this action will attempt to extract the value from other
* inputs such as "service_account" or "credentials_json".
*/
public val projectId: String? = null,
/**
* The full identifier of the Workload Identity Provider, including the
* project number, pool name, and provider name. If provided, this must be
* the full identifier which includes all parts, for example:
* "projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider".
* This is mutually exclusive with "credentials_json".
*/
public val workloadIdentityProvider: String? = null,
/**
* Email address or unique identifier of the Google Cloud service account for
* which to generate credentials. This is required if
* "workload_identity_provider" is specified.
*/
public val serviceAccount: String? = null,
/**
* The value for the audience (aud) parameter in GitHub's generated OIDC
* token. This value defaults to the value of "workload_identity_provider",
* which is also the default value Google Cloud expects for the audience
* parameter on the token.
*/
public val audience: String? = null,
/**
* The Google Cloud JSON service account key to use for authentication. This
* is mutually exclusive with "workload_identity_provider".
*/
public val credentialsJson: String? = null,
/**
* If true, the action will securely generate a credentials file which can be
* used for authentication via gcloud and Google Cloud SDKs.
*/
public val createCredentialsFile: Boolean? = null,
/**
* If true, the action will export common environment variables which are
* known to be consumed by popular downstream libraries and tools, including:
*
* - CLOUDSDK_PROJECT
* - CLOUDSDK_CORE_PROJECT
* - GCP_PROJECT
* - GCLOUD_PROJECT
* - GOOGLE_CLOUD_PROJECT
*
* If "create_credentials_file" is true, additional environment variables are
* exported:
*
* - CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE
* - GOOGLE_APPLICATION_CREDENTIALS
* - GOOGLE_GHA_CREDS_PATH
*
* If false, the action will not export any environment variables, meaning
* future steps are unlikely to be automatically authenticated to Google
* Cloud.
*/
public val exportEnvironmentVariables: Boolean? = null,
/**
* Output format for the generated authentication token. For OAuth 2.0 access
* tokens, specify "access_token". For OIDC tokens, specify "id_token". To
* skip token generation, leave this value empty.
*/
public val tokenFormat: AuthV0.TokenFormat? = null,
/**
* List of additional service account emails or unique identities to use for
* impersonation in the chain.
*/
public val delegates: List<String>? = null,
/**
* If true, the action will remove any created credentials from the
* filesystem upon completion. This only applies if "create_credentials_file"
* is true.
*/
public val cleanupCredentials: Boolean? = null,
/**
* Desired lifetime duration of the access token, in seconds. This must be
* specified as the number of seconds with a trailing "s" (e.g. 30s). This is
* only valid when "token_format" is "access_token".
*/
public val accessTokenLifetime: String? = null,
/**
* List of OAuth 2.0 access scopes to be included in the generated token.
* This is only valid when "token_format" is "access_token".
*/
public val accessTokenScopes: List<String>? = null,
/**
* Email address of a user to impersonate for Domain-Wide Delegation Access
* tokens created for Domain-Wide Delegation cannot have a lifetime beyond 1
* hour. This is only valid when "token_format" is "access_token".
*/
public val accessTokenSubject: String? = null,
/**
* Number of times to retry a failed authentication attempt. This is useful
* for automated pipelines that may execute before IAM permissions are fully propogated.
*/
public val retries: Int? = null,
/**
* Delay time before trying another authentication attempt. This
* is implemented using a fibonacci backoff method (e.g. 1-1-2-3-5).
* This value defaults to 100 milliseconds when retries are greater than 0.
*/
public val backoff: Int? = null,
/**
* Limits the retry backoff to the specified value.
*/
public val backoffLimit: Int? = null,
/**
* The audience (aud) for the generated Google Cloud ID Token. This is only
* valid when "token_format" is "id_token".
*/
public val idTokenAudience: String? = null,
/**
* Optional parameter of whether to include the service account email in the
* generated token. If true, the token will contain "email" and
* "email_verified" claims. This is only valid when "token_format" is
* "id_token".
*/
public val idTokenIncludeEmail: Boolean? = null,
/**
* Type-unsafe map where you can put any inputs that are not yet supported by the binding
*/
public val _customInputs: Map<String, String> = mapOf(),
/**
* Allows overriding action's version, for example to use a specific minor version, or a newer
* version that the binding doesn't yet know about
*/
public val _customVersion: String? = null,
) : RegularAction<AuthV0.Outputs>("google-github-actions", "auth", _customVersion ?: "v0") {
public constructor(
vararg pleaseUseNamedArguments: Unit,
projectId: String? = null,
workloadIdentityProvider: String? = null,
serviceAccount: String? = null,
audience: String? = null,
credentialsJson: String? = null,
createCredentialsFile: Boolean? = null,
exportEnvironmentVariables: Boolean? = null,
tokenFormat: AuthV0.TokenFormat? = null,
delegates: List<String>? = null,
cleanupCredentials: Boolean? = null,
accessTokenLifetime: String? = null,
accessTokenScopes: List<String>? = null,
accessTokenSubject: String? = null,
retries: Int? = null,
backoff: Int? = null,
backoffLimit: Int? = null,
idTokenAudience: String? = null,
idTokenIncludeEmail: Boolean? = null,
_customInputs: Map<String, String> = mapOf(),
_customVersion: String? = null,
) : this(projectId=projectId, workloadIdentityProvider=workloadIdentityProvider,
serviceAccount=serviceAccount, audience=audience, credentialsJson=credentialsJson,
createCredentialsFile=createCredentialsFile,
exportEnvironmentVariables=exportEnvironmentVariables, tokenFormat=tokenFormat,
delegates=delegates, cleanupCredentials=cleanupCredentials,
accessTokenLifetime=accessTokenLifetime, accessTokenScopes=accessTokenScopes,
accessTokenSubject=accessTokenSubject, retries=retries, backoff=backoff,
backoffLimit=backoffLimit, idTokenAudience=idTokenAudience,
idTokenIncludeEmail=idTokenIncludeEmail, _customInputs=_customInputs,
_customVersion=_customVersion)
@Suppress("SpreadOperator")
override fun toYamlArguments(): LinkedHashMap<String, String> = linkedMapOf(
*listOfNotNull(
projectId?.let { "project_id" to it },
workloadIdentityProvider?.let { "workload_identity_provider" to it },
serviceAccount?.let { "service_account" to it },
audience?.let { "audience" to it },
credentialsJson?.let { "credentials_json" to it },
createCredentialsFile?.let { "create_credentials_file" to it.toString() },
exportEnvironmentVariables?.let { "export_environment_variables" to it.toString() },
tokenFormat?.let { "token_format" to it.stringValue },
delegates?.let { "delegates" to it.joinToString(",") },
cleanupCredentials?.let { "cleanup_credentials" to it.toString() },
accessTokenLifetime?.let { "access_token_lifetime" to it },
accessTokenScopes?.let { "access_token_scopes" to it.joinToString(",") },
accessTokenSubject?.let { "access_token_subject" to it },
retries?.let { "retries" to it.toString() },
backoff?.let { "backoff" to it.toString() },
backoffLimit?.let { "backoff_limit" to it.toString() },
idTokenAudience?.let { "id_token_audience" to it },
idTokenIncludeEmail?.let { "id_token_include_email" to it.toString() },
*_customInputs.toList().toTypedArray(),
).toTypedArray()
)
override fun buildOutputObject(stepId: String): Outputs = Outputs(stepId)
public sealed class TokenFormat(
public val stringValue: String,
) {
public object AccessToken : AuthV0.TokenFormat("access_token")
public object IdToken : AuthV0.TokenFormat("id_token")
public class Custom(
customStringValue: String,
) : AuthV0.TokenFormat(customStringValue)
}
public class Outputs(
stepId: String,
) : Action.Outputs(stepId) {
/**
* Provided or extracted value for the Google Cloud project ID.
*/
public val projectId: String = "steps.$stepId.outputs.project_id"
/**
* Path on the local filesystem where the generated credentials file resides.
* This is only available if "create_credentials_file" was set to true.
*/
public val credentialsFilePath: String = "steps.$stepId.outputs.credentials_file_path"
/**
* The Google Cloud access token for calling other Google Cloud APIs. This is
* only available when "token_format" is "access_token".
*/
public val accessToken: String = "steps.$stepId.outputs.access_token"
/**
* The RFC3339 UTC "Zulu" format timestamp for the access token. This is only
* available when "token_format" is "access_token".
*/
public val accessTokenExpiration: String = "steps.$stepId.outputs.access_token_expiration"
/**
* The Google Cloud ID token. This is only available when "token_format" is
* "id_token".
*/
public val idToken: String = "steps.$stepId.outputs.id_token"
}
}