Skip to content

Commit c9db079

Browse files
authored
Add support for docker_registry and kms_key_name (#211)
1 parent 564e6a0 commit c9db079

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,22 @@ steps:
102102
- `build_environment_variables_file`: (Optional) Path to a local YAML file
103103
containing variables. See 'env_vars_file' for syntax.
104104

105+
- `docker_repository`: (Optional) User managed repository created in Artifact
106+
Registry optionally with a customer managed encryption key. If specified,
107+
deployments will use Artifact Registry and must be of the format
108+
`projects/p/locations/l/repositories/r`. If unspecified and the deployment is
109+
eligible to use Artifact Registry, GCF will create and use a repository named
110+
'gcf-artifacts' for every deployed region. This is the repository to which the
111+
function docker image will be pushed after it is built by Cloud Build. For
112+
more information, please see [the
113+
documentation](https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy#--docker-repository).
114+
115+
- `kms_key_name`: (Optional) Resource name of a Google Cloud KMS crypto key used
116+
to encrypt/decrypt function resources of the format
117+
`projects/p/locations/l/keyRings/r/cryptoKeys/k`. If specified, you must also
118+
provide an artifact registry repository using the `docker_repository` field
119+
that was created with the same key.
120+
105121
- `credentials`: (**Deprecated**) This input is deprecated. See [auth section](https://github.com/google-github-actions/deploy-cloud-functions#via-google-github-actionsauth) for more details.
106122
Service account key to use for authentication. This should be
107123
the JSON formatted private key which can be exported from the Cloud Console. The

action.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,19 @@ inputs:
147147
syntax.
148148
required: false
149149

150+
docker_repository:
151+
description: |-
152+
User managed repository created in Artifact Registry.
153+
required: false
154+
155+
kms_key_name:
156+
description: |-
157+
Resource name of a Google Cloud KMS crypto key used to encrypt/decrypt
158+
function resources. If specified, you must also provide an artifact
159+
registry repository using the 'docker_repository' field that was created
160+
with the same key.
161+
required: false
162+
150163
outputs:
151164
url:
152165
description: The URL of your Cloud Function. Only available with HTTP Trigger.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ async function run(): Promise<void> {
6767
getInput('build_environment_variables_file'),
6868
);
6969

70+
const dockerRepository = presence(getInput('docker_repository'));
71+
const kmsKeyName = presence(getInput('kms_key_name'));
72+
7073
// Add warning if using credentials
7174
let credentialsJSON:
7275
| ServiceAccountKey
@@ -99,6 +102,20 @@ async function run(): Promise<void> {
99102
// from a docker repo.
100103
throw new Error(`Missing required value 'source_dir'`);
101104
}
105+
if (dockerRepository || kmsKeyName) {
106+
if (!dockerRepository) {
107+
throw new Error(
108+
`Missing required field 'docker_repository'. This is required when ` +
109+
`'kms_key_name' is set.`,
110+
);
111+
}
112+
if (!kmsKeyName) {
113+
throw new Error(
114+
`Missing required field 'kms_key_name'. This is required when ` +
115+
`'docker_repository' is set.`,
116+
);
117+
}
118+
}
102119

103120
// Create Cloud Functions client
104121
const client = new CloudFunctionsClient({
@@ -121,11 +138,11 @@ async function run(): Promise<void> {
121138
availableMemoryMb: availableMemoryMb ? +availableMemoryMb : undefined,
122139
buildEnvironmentVariables: buildEnvironmentVariables,
123140
// buildWorkerPool: buildWorkerPool, // TODO: add support
124-
// dockerRepository: dockerRepository, // TODO: add support
141+
dockerRepository: dockerRepository,
125142
entryPoint: entryPoint,
126143
environmentVariables: environmentVariables,
127144
ingressSettings: ingressSettings,
128-
// kmsKeyName: kmsKeyName, // TODO: add support
145+
kmsKeyName: kmsKeyName,
129146
labels: labels,
130147
maxInstances: maxInstances ? +maxInstances : undefined,
131148
// minInstances: minInstances ? + minInstances : undefined, // TODO: add support

0 commit comments

Comments
 (0)