├── .compodocrc ├── .eslintignore ├── .eslintrc.json ├── .gitattributes ├── .github ├── .OwlBot.lock.yaml ├── .OwlBot.yaml ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ ├── question.md │ └── support_request.md ├── PULL_REQUEST_TEMPLATE.md ├── auto-approve.yml ├── auto-label.yaml ├── generated-files-bot.yml ├── release-please.yml ├── release-trigger.yml ├── sync-repo-settings.yaml └── workflows │ └── ci.yaml ├── .gitignore ├── .jsdoc.js ├── .kokoro ├── .gitattributes ├── common.cfg ├── continuous │ └── node14 │ │ ├── common.cfg │ │ ├── lint.cfg │ │ ├── samples-test.cfg │ │ ├── system-test.cfg │ │ └── test.cfg ├── docs.sh ├── lint.sh ├── populate-secrets.sh ├── presubmit │ ├── node14 │ │ ├── common.cfg │ │ ├── samples-test.cfg │ │ ├── system-test.cfg │ │ └── test.cfg │ └── windows │ │ ├── common.cfg │ │ └── test.cfg ├── publish.sh ├── release │ ├── common.cfg │ ├── docs-devsite.cfg │ ├── docs-devsite.sh │ ├── docs.cfg │ ├── docs.sh │ └── publish.cfg ├── samples-test.sh ├── system-test.sh ├── test.bat ├── test.sh ├── trampoline.sh └── trampoline_v2.sh ├── .mocharc.js ├── .nycrc ├── .prettierignore ├── .prettierrc.js ├── .readme-partials.yaml ├── .repo-metadata.json ├── .trampolinerc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── linkinator.config.json ├── owlbot.py ├── package.json ├── renovate.json ├── samples ├── .eslintrc.yml ├── README.md ├── fromProject.js ├── latestSpecificOS.js ├── package.json ├── quickstart.js ├── specificOS.js └── test │ ├── .eslintrc.yml │ └── samples.js ├── src └── index.ts ├── test └── test.ts └── tsconfig.json /.compodocrc: -------------------------------------------------------------------------------- 1 | --- 2 | tsconfig: ./tsconfig.json 3 | output: ./docs 4 | theme: material 5 | hideGenerator: true 6 | disablePrivate: true 7 | disableProtected: true 8 | disableInternal: true 9 | disableCoverage: true 10 | disableGraph: true 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | test/fixtures 4 | build/ 5 | docs/ 6 | protos/ 7 | samples/generated/ 8 | system-test/**/fixtures 9 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts" 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ts text eol=lf 2 | *.js text eol=lf 3 | protos/* linguist-generated 4 | **/api-extractor.json linguist-language=JSON-with-Comments 5 | -------------------------------------------------------------------------------- /.github/.OwlBot.lock.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | docker: 15 | image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest 16 | digest: sha256:68e1cece0d6d3336c4f1cb9d2857b020af5574dff6da6349293d1c6d4eea82d8 17 | # created: 2024-05-31T15:46:42.989947733Z 18 | -------------------------------------------------------------------------------- /.github/.OwlBot.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | docker: 15 | image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest 16 | 17 | 18 | begin-after-commit-hash: efb563da184f479fabf98da24f969494944d059b 19 | 20 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | # 4 | # For syntax help see: 5 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax 6 | 7 | 8 | # The yoshi-nodejs team is the default owner for nodejs repositories. 9 | * @googleapis/yoshi-nodejs 10 | 11 | # The github automation team is the default owner for the auto-approve file. 12 | .github/auto-approve.yml @googleapis/github-automation 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | labels: 'type: bug, priority: p2' 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | 1) Is this a client library issue or a product issue? 12 | This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the [ Support page]() to reach the most relevant engineers. 13 | 14 | 2) Did someone already solve this? 15 | - Search the issues already opened: https://github.com/googleapis/nodejs-gce-images/issues 16 | - Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node 17 | - Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js 18 | 19 | 3) Do you have a support contract? 20 | Please create an issue in the [support console](https://cloud.google.com/support/) to ensure a timely response. 21 | 22 | If the support paths suggested above still do not result in a resolution, please provide the following details. 23 | 24 | #### Environment details 25 | 26 | - OS: 27 | - Node.js version: 28 | - npm version: 29 | - `gce-images` version: 30 | 31 | #### Steps to reproduce 32 | 33 | 1. ? 34 | 2. ? 35 | 36 | Making sure to follow these steps will guarantee the quickest resolution possible. 37 | 38 | Thanks! 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Google Cloud Support 3 | url: https://cloud.google.com/support/ 4 | about: If you have a support contract with Google, please use the Google Cloud Support portal. 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this library 4 | labels: 'type: feature request, priority: p3' 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | **Additional context** 18 | Add any other context or screenshots about the feature request here. 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question 4 | labels: 'type: question, priority: p3' 5 | --- 6 | 7 | Thanks for stopping by to ask us a question! Please make sure to include: 8 | - What you're trying to do 9 | - What code you've already tried 10 | - Any error messages you're getting 11 | 12 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. 4 | 5 | --- 6 | 7 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 2 | - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/gce-images/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 3 | - [ ] Ensure the tests and linter pass 4 | - [ ] Code coverage does not decrease (if any source code was changed) 5 | - [ ] Appropriate docs were updated (if necessary) 6 | 7 | Fixes # 🦕 8 | -------------------------------------------------------------------------------- /.github/auto-approve.yml: -------------------------------------------------------------------------------- 1 | processes: 2 | - "NodeDependency" 3 | - "OwlBotTemplateChangesNode" 4 | - "OwlBotPRsNode" -------------------------------------------------------------------------------- /.github/auto-label.yaml: -------------------------------------------------------------------------------- 1 | requestsize: 2 | enabled: true 3 | -------------------------------------------------------------------------------- /.github/generated-files-bot.yml: -------------------------------------------------------------------------------- 1 | generatedFiles: 2 | - path: '.kokoro/**' 3 | message: '`.kokoro` files are templated and should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 4 | - path: '.github/CODEOWNERS' 5 | message: 'CODEOWNERS should instead be modified via the `codeowner_team` property in .repo-metadata.json' 6 | - path: '.github/workflows/ci.yaml' 7 | message: '`.github/workflows/ci.yaml` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 8 | - path: '.github/generated-files-bot.+(yml|yaml)' 9 | message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 10 | - path: 'README.md' 11 | message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' 12 | - path: 'samples/README.md' 13 | message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' 14 | ignoreAuthors: 15 | - 'gcf-owl-bot[bot]' 16 | - 'yoshi-automation' 17 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | handleGHRelease: true 2 | releaseType: node 3 | -------------------------------------------------------------------------------- /.github/release-trigger.yml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | branchProtectionRules: 2 | - pattern: main 3 | isAdminEnforced: true 4 | requiredApprovingReviewCount: 1 5 | requiresCodeOwnerReviews: true 6 | requiresStrictStatusChecks: true 7 | requiredStatusCheckContexts: 8 | - "ci/kokoro: Samples test" 9 | - "ci/kokoro: System test" 10 | - lint 11 | - test (14) 12 | - test (16) 13 | - test (18) 14 | - cla/google 15 | - windows 16 | - OwlBot Post Processor 17 | permissionRules: 18 | - team: yoshi-admins 19 | permission: admin 20 | - team: jsteam-admins 21 | permission: admin 22 | - team: jsteam 23 | permission: push 24 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: ci 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node: [14, 16, 18, 20] 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3 16 | with: 17 | node-version: ${{ matrix.node }} 18 | - run: node --version 19 | # The first installation step ensures that all of our production 20 | # dependencies work on the given Node.js version, this helps us find 21 | # dependencies that don't match our engines field: 22 | - run: npm install --production --engine-strict --ignore-scripts --no-package-lock 23 | # Clean up the production install, before installing dev/production: 24 | - run: rm -rf node_modules 25 | - run: npm install --engine-strict 26 | - run: npm test 27 | env: 28 | MOCHA_THROW_DEPRECATION: false 29 | windows: 30 | runs-on: windows-latest 31 | steps: 32 | - uses: actions/checkout@v3 33 | - uses: actions/setup-node@v3 34 | with: 35 | node-version: 14 36 | - run: npm install --engine-strict 37 | - run: npm test 38 | env: 39 | MOCHA_THROW_DEPRECATION: false 40 | lint: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - uses: actions/checkout@v3 44 | - uses: actions/setup-node@v3 45 | with: 46 | node-version: 14 47 | - run: npm install 48 | - run: npm run lint 49 | docs: 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v3 53 | - uses: actions/setup-node@v3 54 | with: 55 | node-version: 14 56 | - run: npm install 57 | - run: npm run docs 58 | - uses: JustinBeckwith/linkinator-action@v1 59 | with: 60 | paths: docs/ 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.log 2 | **/node_modules 3 | .coverage 4 | .nyc_output 5 | docs/ 6 | out/ 7 | build/ 8 | system-test/secrets.js 9 | system-test/*key.json 10 | *.lock 11 | .DS_Store 12 | package-lock.json 13 | .vscode 14 | __pycache__ 15 | -------------------------------------------------------------------------------- /.jsdoc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | 'use strict'; 17 | 18 | module.exports = { 19 | opts: { 20 | readme: './README.md', 21 | package: './package.json', 22 | template: './node_modules/jsdoc-fresh', 23 | recurse: true, 24 | verbose: true, 25 | destination: './docs/' 26 | }, 27 | plugins: [ 28 | 'plugins/markdown', 29 | 'jsdoc-region-tag' 30 | ], 31 | source: { 32 | excludePattern: '(^|\\/|\\\\)[._]', 33 | include: [ 34 | 'src',, 35 | ], 36 | includePattern: '\\.js$' 37 | }, 38 | templates: { 39 | copyright: 'Copyright 2019 Google, LLC.', 40 | includeDate: false, 41 | sourceFiles: false, 42 | systemName: 'gce-images', 43 | theme: 'lumen', 44 | default: { 45 | outputSourceFiles: false 46 | } 47 | }, 48 | markdown: { 49 | idInHeadings: true 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /.kokoro/.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-generated=true 2 | -------------------------------------------------------------------------------- /.kokoro/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-gce-images/.kokoro/test.sh" 24 | } 25 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-gce-images/.kokoro/test.sh" 24 | } 25 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/lint.cfg: -------------------------------------------------------------------------------- 1 | env_vars: { 2 | key: "TRAMPOLINE_BUILD_FILE" 3 | value: "github/nodejs-gce-images/.kokoro/lint.sh" 4 | } 5 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/samples-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-gce-images/.kokoro/samples-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/continuous/node14/system-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-gce-images/.kokoro/system-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/continuous/node14/test.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/nodejs-gce-images/edc4ad9f30ff794e953405468ea6da968e436dd2/.kokoro/continuous/node14/test.cfg -------------------------------------------------------------------------------- /.kokoro/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | 25 | npm run docs-test 26 | -------------------------------------------------------------------------------- /.kokoro/lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | 25 | # Install and link samples 26 | if [ -f samples/package.json ]; then 27 | cd samples/ 28 | npm link ../ 29 | npm install 30 | cd .. 31 | fi 32 | 33 | npm run lint 34 | -------------------------------------------------------------------------------- /.kokoro/populate-secrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This file is called in the early stage of `trampoline_v2.sh` to 17 | # populate secrets needed for the CI builds. 18 | 19 | set -eo pipefail 20 | 21 | function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} 22 | function msg { println "$*" >&2 ;} 23 | function println { printf '%s\n' "$(now) $*" ;} 24 | 25 | # Populates requested secrets set in SECRET_MANAGER_KEYS 26 | 27 | # In Kokoro CI builds, we use the service account attached to the 28 | # Kokoro VM. This means we need to setup auth on other CI systems. 29 | # For local run, we just use the gcloud command for retrieving the 30 | # secrets. 31 | 32 | if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then 33 | GCLOUD_COMMANDS=( 34 | "docker" 35 | "run" 36 | "--entrypoint=gcloud" 37 | "--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}" 38 | "gcr.io/google.com/cloudsdktool/cloud-sdk" 39 | ) 40 | if [[ "${TRAMPOLINE_CI:-}" == "kokoro" ]]; then 41 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 42 | else 43 | echo "Authentication for this CI system is not implemented yet." 44 | exit 2 45 | # TODO: Determine appropriate SECRET_LOCATION and the GCLOUD_COMMANDS. 46 | fi 47 | else 48 | # For local run, use /dev/shm or temporary directory for 49 | # KOKORO_GFILE_DIR. 50 | if [[ -d "/dev/shm" ]]; then 51 | export KOKORO_GFILE_DIR=/dev/shm 52 | else 53 | export KOKORO_GFILE_DIR=$(mktemp -d -t ci-XXXXXXXX) 54 | fi 55 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 56 | GCLOUD_COMMANDS=("gcloud") 57 | fi 58 | 59 | msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" 60 | mkdir -p ${SECRET_LOCATION} 61 | 62 | for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") 63 | do 64 | msg "Retrieving secret ${key}" 65 | "${GCLOUD_COMMANDS[@]}" \ 66 | secrets versions access latest \ 67 | --project cloud-devrel-kokoro-resources \ 68 | --secret $key > \ 69 | "$SECRET_LOCATION/$key" 70 | if [[ $? == 0 ]]; then 71 | msg "Secret written to ${SECRET_LOCATION}/${key}" 72 | else 73 | msg "Error retrieving secret ${key}" 74 | exit 2 75 | fi 76 | done 77 | -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-gce-images/.kokoro/test.sh" 24 | } 25 | -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/samples-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-gce-images/.kokoro/samples-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/system-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-gce-images/.kokoro/system-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/test.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/nodejs-gce-images/edc4ad9f30ff794e953405468ea6da968e436dd2/.kokoro/presubmit/node14/test.cfg -------------------------------------------------------------------------------- /.kokoro/presubmit/windows/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | -------------------------------------------------------------------------------- /.kokoro/presubmit/windows/test.cfg: -------------------------------------------------------------------------------- 1 | # Use the test file directly 2 | build_file: "nodejs-gce-images/.kokoro/test.bat" 3 | -------------------------------------------------------------------------------- /.kokoro/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Start the releasetool reporter 22 | python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script 23 | 24 | cd $(dirname $0)/.. 25 | 26 | NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-npm-token-1) 27 | echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc 28 | 29 | npm install 30 | npm pack . 31 | # npm provides no way to specify, observe, or predict the name of the tarball 32 | # file it generates. We have to look in the current directory for the freshest 33 | # .tgz file. 34 | TARBALL=$(ls -1 -t *.tgz | head -1) 35 | 36 | npm publish --access=public --registry=https://wombat-dressing-room.appspot.com "$TARBALL" 37 | 38 | # Kokoro collects *.tgz and package-lock.json files and stores them in Placer 39 | # so we can generate SBOMs and attestations. 40 | # However, we *don't* want Kokoro to collect package-lock.json and *.tgz files 41 | # that happened to be installed with dependencies. 42 | find node_modules -name package-lock.json -o -name "*.tgz" | xargs rm -f -------------------------------------------------------------------------------- /.kokoro/release/common.cfg: -------------------------------------------------------------------------------- 1 | before_action { 2 | fetch_keystore { 3 | keystore_resource { 4 | keystore_config_id: 73713 5 | keyname: "yoshi-automation-github-key" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.kokoro/release/docs-devsite.cfg: -------------------------------------------------------------------------------- 1 | # service account used to publish up-to-date docs. 2 | before_action { 3 | fetch_keystore { 4 | keystore_resource { 5 | keystore_config_id: 73713 6 | keyname: "docuploader_service_account" 7 | } 8 | } 9 | } 10 | 11 | # doc publications use a Python image. 12 | env_vars: { 13 | key: "TRAMPOLINE_IMAGE" 14 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 15 | } 16 | 17 | # Download trampoline resources. 18 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 19 | 20 | # Use the trampoline script to run in docker. 21 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 22 | 23 | env_vars: { 24 | key: "TRAMPOLINE_BUILD_FILE" 25 | value: "github/nodejs-gce-images/.kokoro/release/docs-devsite.sh" 26 | } 27 | -------------------------------------------------------------------------------- /.kokoro/release/docs-devsite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2021 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | if [[ -z "$CREDENTIALS" ]]; then 20 | # if CREDENTIALS are explicitly set, assume we're testing locally 21 | # and don't set NPM_CONFIG_PREFIX. 22 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 23 | export PATH="$PATH:${NPM_CONFIG_PREFIX}/bin" 24 | cd $(dirname $0)/../.. 25 | fi 26 | 27 | npm install 28 | npm install --no-save @google-cloud/cloud-rad@^0.4.0 29 | # publish docs to devsite 30 | npx @google-cloud/cloud-rad . cloud-rad 31 | -------------------------------------------------------------------------------- /.kokoro/release/docs.cfg: -------------------------------------------------------------------------------- 1 | # service account used to publish up-to-date docs. 2 | before_action { 3 | fetch_keystore { 4 | keystore_resource { 5 | keystore_config_id: 73713 6 | keyname: "docuploader_service_account" 7 | } 8 | } 9 | } 10 | 11 | # doc publications use a Python image. 12 | env_vars: { 13 | key: "TRAMPOLINE_IMAGE" 14 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 15 | } 16 | 17 | # Download trampoline resources. 18 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 19 | 20 | # Use the trampoline script to run in docker. 21 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 22 | 23 | env_vars: { 24 | key: "TRAMPOLINE_BUILD_FILE" 25 | value: "github/nodejs-gce-images/.kokoro/release/docs.sh" 26 | } 27 | -------------------------------------------------------------------------------- /.kokoro/release/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | # build jsdocs (Python is installed on the Node 10 docker image). 20 | if [[ -z "$CREDENTIALS" ]]; then 21 | # if CREDENTIALS are explicitly set, assume we're testing locally 22 | # and don't set NPM_CONFIG_PREFIX. 23 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 24 | export PATH="$PATH:${NPM_CONFIG_PREFIX}/bin" 25 | cd $(dirname $0)/../.. 26 | fi 27 | npm install 28 | npm run docs 29 | 30 | # create docs.metadata, based on package.json and .repo-metadata.json. 31 | npm i json@9.0.6 -g 32 | python3 -m docuploader create-metadata \ 33 | --name=$(cat .repo-metadata.json | json name) \ 34 | --version=$(cat package.json | json version) \ 35 | --language=$(cat .repo-metadata.json | json language) \ 36 | --distribution-name=$(cat .repo-metadata.json | json distribution_name) \ 37 | --product-page=$(cat .repo-metadata.json | json product_documentation) \ 38 | --github-repository=$(cat .repo-metadata.json | json repo) \ 39 | --issue-tracker=$(cat .repo-metadata.json | json issue_tracker) 40 | cp docs.metadata ./docs/docs.metadata 41 | 42 | # deploy the docs. 43 | if [[ -z "$CREDENTIALS" ]]; then 44 | CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account 45 | fi 46 | if [[ -z "$BUCKET" ]]; then 47 | BUCKET=docs-staging 48 | fi 49 | python3 -m docuploader upload ./docs --credentials $CREDENTIALS --staging-bucket $BUCKET 50 | -------------------------------------------------------------------------------- /.kokoro/release/publish.cfg: -------------------------------------------------------------------------------- 1 | before_action { 2 | fetch_keystore { 3 | keystore_resource { 4 | keystore_config_id: 73713 5 | keyname: "docuploader_service_account" 6 | } 7 | } 8 | } 9 | 10 | before_action { 11 | fetch_keystore { 12 | keystore_resource { 13 | keystore_config_id: 73713 14 | keyname: "google-cloud-npm-token-1" 15 | } 16 | } 17 | } 18 | 19 | env_vars: { 20 | key: "SECRET_MANAGER_KEYS" 21 | value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" 22 | } 23 | 24 | # Download trampoline resources. 25 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 26 | 27 | # Use the trampoline script to run in docker. 28 | build_file: "nodejs-gce-images/.kokoro/trampoline_v2.sh" 29 | 30 | # Configure the docker image for kokoro-trampoline. 31 | env_vars: { 32 | key: "TRAMPOLINE_IMAGE" 33 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 34 | } 35 | 36 | env_vars: { 37 | key: "TRAMPOLINE_BUILD_FILE" 38 | value: "github/nodejs-gce-images/.kokoro/publish.sh" 39 | } 40 | 41 | # Store the packages we uploaded to npmjs.org and their corresponding 42 | # package-lock.jsons in Placer. That way, we have a record of exactly 43 | # what we published, and which version of which tools we used to publish 44 | # it, which we can use to generate SBOMs and attestations. 45 | action { 46 | define_artifacts { 47 | regex: "github/**/*.tgz" 48 | regex: "github/**/package-lock.json" 49 | strip_prefix: "github" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /.kokoro/samples-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Setup service account credentials. 22 | export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account 23 | export GCLOUD_PROJECT=long-door-651 24 | 25 | cd $(dirname $0)/.. 26 | 27 | # Run a pre-test hook, if a pre-samples-test.sh is in the project 28 | if [ -f .kokoro/pre-samples-test.sh ]; then 29 | set +x 30 | . .kokoro/pre-samples-test.sh 31 | set -x 32 | fi 33 | 34 | if [ -f samples/package.json ]; then 35 | npm install 36 | 37 | # Install and link samples 38 | cd samples/ 39 | npm link ../ 40 | npm install 41 | cd .. 42 | # If tests are running against main branch, configure flakybot 43 | # to open issues on failures: 44 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 45 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 46 | export MOCHA_REPORTER=xunit 47 | cleanup() { 48 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 49 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 50 | } 51 | trap cleanup EXIT HUP 52 | fi 53 | 54 | npm run samples-test 55 | fi 56 | 57 | # codecov combines coverage across integration and unit tests. Include 58 | # the logic below for any environment you wish to collect coverage for: 59 | COVERAGE_NODE=14 60 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 61 | NYC_BIN=./node_modules/nyc/bin/nyc.js 62 | if [ -f "$NYC_BIN" ]; then 63 | $NYC_BIN report || true 64 | fi 65 | bash $KOKORO_GFILE_DIR/codecov.sh 66 | else 67 | echo "coverage is only reported for Node $COVERAGE_NODE" 68 | fi 69 | -------------------------------------------------------------------------------- /.kokoro/system-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Setup service account credentials. 22 | export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account 23 | export GCLOUD_PROJECT=long-door-651 24 | 25 | cd $(dirname $0)/.. 26 | 27 | # Run a pre-test hook, if a pre-system-test.sh is in the project 28 | if [ -f .kokoro/pre-system-test.sh ]; then 29 | set +x 30 | . .kokoro/pre-system-test.sh 31 | set -x 32 | fi 33 | 34 | npm install 35 | 36 | # If tests are running against main branch, configure flakybot 37 | # to open issues on failures: 38 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 39 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 40 | export MOCHA_REPORTER=xunit 41 | cleanup() { 42 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 43 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 44 | } 45 | trap cleanup EXIT HUP 46 | fi 47 | 48 | npm run system-test 49 | 50 | # codecov combines coverage across integration and unit tests. Include 51 | # the logic below for any environment you wish to collect coverage for: 52 | COVERAGE_NODE=14 53 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 54 | NYC_BIN=./node_modules/nyc/bin/nyc.js 55 | if [ -f "$NYC_BIN" ]; then 56 | $NYC_BIN report || true 57 | fi 58 | bash $KOKORO_GFILE_DIR/codecov.sh 59 | else 60 | echo "coverage is only reported for Node $COVERAGE_NODE" 61 | fi 62 | -------------------------------------------------------------------------------- /.kokoro/test.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2018 Google LLC. All rights reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @echo "Starting Windows build" 16 | 17 | cd /d %~dp0 18 | cd .. 19 | 20 | @rem npm path is not currently set in our image, we should fix this next time 21 | @rem we upgrade Node.js in the image: 22 | SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm 23 | 24 | call nvm use v14.17.3 25 | call which node 26 | 27 | call npm install || goto :error 28 | call npm run test || goto :error 29 | 30 | goto :EOF 31 | 32 | :error 33 | exit /b 1 34 | -------------------------------------------------------------------------------- /.kokoro/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | # If tests are running against main branch, configure flakybot 25 | # to open issues on failures: 26 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 27 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 28 | export MOCHA_REPORTER=xunit 29 | cleanup() { 30 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 31 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 32 | } 33 | trap cleanup EXIT HUP 34 | fi 35 | # Unit tests exercise the entire API surface, which may include 36 | # deprecation warnings: 37 | export MOCHA_THROW_DEPRECATION=false 38 | npm test 39 | 40 | # codecov combines coverage across integration and unit tests. Include 41 | # the logic below for any environment you wish to collect coverage for: 42 | COVERAGE_NODE=14 43 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 44 | NYC_BIN=./node_modules/nyc/bin/nyc.js 45 | if [ -f "$NYC_BIN" ]; then 46 | $NYC_BIN report || true 47 | fi 48 | bash $KOKORO_GFILE_DIR/codecov.sh 49 | else 50 | echo "coverage is only reported for Node $COVERAGE_NODE" 51 | fi 52 | -------------------------------------------------------------------------------- /.kokoro/trampoline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2017 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This file is not used any more, but we keep this file for making it 17 | # easy to roll back. 18 | # TODO: Remove this file from the template. 19 | 20 | set -eo pipefail 21 | 22 | # Always run the cleanup script, regardless of the success of bouncing into 23 | # the container. 24 | function cleanup() { 25 | chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 26 | ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 27 | echo "cleanup"; 28 | } 29 | trap cleanup EXIT 30 | 31 | $(dirname $0)/populate-secrets.sh # Secret Manager secrets. 32 | python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" 33 | -------------------------------------------------------------------------------- /.kokoro/trampoline_v2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2020 Google LLC 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # trampoline_v2.sh 17 | # 18 | # If you want to make a change to this file, consider doing so at: 19 | # https://github.com/googlecloudplatform/docker-ci-helper 20 | # 21 | # This script is for running CI builds. For Kokoro builds, we 22 | # set this script to `build_file` field in the Kokoro configuration. 23 | 24 | # This script does 3 things. 25 | # 26 | # 1. Prepare the Docker image for the test 27 | # 2. Run the Docker with appropriate flags to run the test 28 | # 3. Upload the newly built Docker image 29 | # 30 | # in a way that is somewhat compatible with trampoline_v1. 31 | # 32 | # These environment variables are required: 33 | # TRAMPOLINE_IMAGE: The docker image to use. 34 | # TRAMPOLINE_DOCKERFILE: The location of the Dockerfile. 35 | # 36 | # You can optionally change these environment variables: 37 | # TRAMPOLINE_IMAGE_UPLOAD: 38 | # (true|false): Whether to upload the Docker image after the 39 | # successful builds. 40 | # TRAMPOLINE_BUILD_FILE: The script to run in the docker container. 41 | # TRAMPOLINE_WORKSPACE: The workspace path in the docker container. 42 | # Defaults to /workspace. 43 | # Potentially there are some repo specific envvars in .trampolinerc in 44 | # the project root. 45 | # 46 | # Here is an example for running this script. 47 | # TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:10-user \ 48 | # TRAMPOLINE_BUILD_FILE=.kokoro/system-test.sh \ 49 | # .kokoro/trampoline_v2.sh 50 | 51 | set -euo pipefail 52 | 53 | TRAMPOLINE_VERSION="2.0.7" 54 | 55 | if command -v tput >/dev/null && [[ -n "${TERM:-}" ]]; then 56 | readonly IO_COLOR_RED="$(tput setaf 1)" 57 | readonly IO_COLOR_GREEN="$(tput setaf 2)" 58 | readonly IO_COLOR_YELLOW="$(tput setaf 3)" 59 | readonly IO_COLOR_RESET="$(tput sgr0)" 60 | else 61 | readonly IO_COLOR_RED="" 62 | readonly IO_COLOR_GREEN="" 63 | readonly IO_COLOR_YELLOW="" 64 | readonly IO_COLOR_RESET="" 65 | fi 66 | 67 | function function_exists { 68 | [ $(LC_ALL=C type -t $1)"" == "function" ] 69 | } 70 | 71 | # Logs a message using the given color. The first argument must be one 72 | # of the IO_COLOR_* variables defined above, such as 73 | # "${IO_COLOR_YELLOW}". The remaining arguments will be logged in the 74 | # given color. The log message will also have an RFC-3339 timestamp 75 | # prepended (in UTC). You can disable the color output by setting 76 | # TERM=vt100. 77 | function log_impl() { 78 | local color="$1" 79 | shift 80 | local timestamp="$(date -u "+%Y-%m-%dT%H:%M:%SZ")" 81 | echo "================================================================" 82 | echo "${color}${timestamp}:" "$@" "${IO_COLOR_RESET}" 83 | echo "================================================================" 84 | } 85 | 86 | # Logs the given message with normal coloring and a timestamp. 87 | function log() { 88 | log_impl "${IO_COLOR_RESET}" "$@" 89 | } 90 | 91 | # Logs the given message in green with a timestamp. 92 | function log_green() { 93 | log_impl "${IO_COLOR_GREEN}" "$@" 94 | } 95 | 96 | # Logs the given message in yellow with a timestamp. 97 | function log_yellow() { 98 | log_impl "${IO_COLOR_YELLOW}" "$@" 99 | } 100 | 101 | # Logs the given message in red with a timestamp. 102 | function log_red() { 103 | log_impl "${IO_COLOR_RED}" "$@" 104 | } 105 | 106 | readonly tmpdir=$(mktemp -d -t ci-XXXXXXXX) 107 | readonly tmphome="${tmpdir}/h" 108 | mkdir -p "${tmphome}" 109 | 110 | function cleanup() { 111 | rm -rf "${tmpdir}" 112 | } 113 | trap cleanup EXIT 114 | 115 | RUNNING_IN_CI="${RUNNING_IN_CI:-false}" 116 | 117 | # The workspace in the container, defaults to /workspace. 118 | TRAMPOLINE_WORKSPACE="${TRAMPOLINE_WORKSPACE:-/workspace}" 119 | 120 | pass_down_envvars=( 121 | # TRAMPOLINE_V2 variables. 122 | # Tells scripts whether they are running as part of CI or not. 123 | "RUNNING_IN_CI" 124 | # Indicates which CI system we're in. 125 | "TRAMPOLINE_CI" 126 | # Indicates the version of the script. 127 | "TRAMPOLINE_VERSION" 128 | # Contains path to build artifacts being executed. 129 | "KOKORO_BUILD_ARTIFACTS_SUBDIR" 130 | ) 131 | 132 | log_yellow "Building with Trampoline ${TRAMPOLINE_VERSION}" 133 | 134 | # Detect which CI systems we're in. If we're in any of the CI systems 135 | # we support, `RUNNING_IN_CI` will be true and `TRAMPOLINE_CI` will be 136 | # the name of the CI system. Both envvars will be passing down to the 137 | # container for telling which CI system we're in. 138 | if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then 139 | # descriptive env var for indicating it's on CI. 140 | RUNNING_IN_CI="true" 141 | TRAMPOLINE_CI="kokoro" 142 | if [[ "${TRAMPOLINE_USE_LEGACY_SERVICE_ACCOUNT:-}" == "true" ]]; then 143 | if [[ ! -f "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json" ]]; then 144 | log_red "${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json does not exist. Did you forget to mount cloud-devrel-kokoro-resources/trampoline? Aborting." 145 | exit 1 146 | fi 147 | # This service account will be activated later. 148 | TRAMPOLINE_SERVICE_ACCOUNT="${KOKORO_GFILE_DIR}/kokoro-trampoline.service-account.json" 149 | else 150 | if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then 151 | gcloud auth list 152 | fi 153 | log_yellow "Configuring Container Registry access" 154 | gcloud auth configure-docker --quiet 155 | fi 156 | pass_down_envvars+=( 157 | # KOKORO dynamic variables. 158 | "KOKORO_BUILD_NUMBER" 159 | "KOKORO_BUILD_ID" 160 | "KOKORO_JOB_NAME" 161 | "KOKORO_GIT_COMMIT" 162 | "KOKORO_GITHUB_COMMIT" 163 | "KOKORO_GITHUB_PULL_REQUEST_NUMBER" 164 | "KOKORO_GITHUB_PULL_REQUEST_COMMIT" 165 | # For flakybot 166 | "KOKORO_GITHUB_COMMIT_URL" 167 | "KOKORO_GITHUB_PULL_REQUEST_URL" 168 | ) 169 | elif [[ "${TRAVIS:-}" == "true" ]]; then 170 | RUNNING_IN_CI="true" 171 | TRAMPOLINE_CI="travis" 172 | pass_down_envvars+=( 173 | "TRAVIS_BRANCH" 174 | "TRAVIS_BUILD_ID" 175 | "TRAVIS_BUILD_NUMBER" 176 | "TRAVIS_BUILD_WEB_URL" 177 | "TRAVIS_COMMIT" 178 | "TRAVIS_COMMIT_MESSAGE" 179 | "TRAVIS_COMMIT_RANGE" 180 | "TRAVIS_JOB_NAME" 181 | "TRAVIS_JOB_NUMBER" 182 | "TRAVIS_JOB_WEB_URL" 183 | "TRAVIS_PULL_REQUEST" 184 | "TRAVIS_PULL_REQUEST_BRANCH" 185 | "TRAVIS_PULL_REQUEST_SHA" 186 | "TRAVIS_PULL_REQUEST_SLUG" 187 | "TRAVIS_REPO_SLUG" 188 | "TRAVIS_SECURE_ENV_VARS" 189 | "TRAVIS_TAG" 190 | ) 191 | elif [[ -n "${GITHUB_RUN_ID:-}" ]]; then 192 | RUNNING_IN_CI="true" 193 | TRAMPOLINE_CI="github-workflow" 194 | pass_down_envvars+=( 195 | "GITHUB_WORKFLOW" 196 | "GITHUB_RUN_ID" 197 | "GITHUB_RUN_NUMBER" 198 | "GITHUB_ACTION" 199 | "GITHUB_ACTIONS" 200 | "GITHUB_ACTOR" 201 | "GITHUB_REPOSITORY" 202 | "GITHUB_EVENT_NAME" 203 | "GITHUB_EVENT_PATH" 204 | "GITHUB_SHA" 205 | "GITHUB_REF" 206 | "GITHUB_HEAD_REF" 207 | "GITHUB_BASE_REF" 208 | ) 209 | elif [[ "${CIRCLECI:-}" == "true" ]]; then 210 | RUNNING_IN_CI="true" 211 | TRAMPOLINE_CI="circleci" 212 | pass_down_envvars+=( 213 | "CIRCLE_BRANCH" 214 | "CIRCLE_BUILD_NUM" 215 | "CIRCLE_BUILD_URL" 216 | "CIRCLE_COMPARE_URL" 217 | "CIRCLE_JOB" 218 | "CIRCLE_NODE_INDEX" 219 | "CIRCLE_NODE_TOTAL" 220 | "CIRCLE_PREVIOUS_BUILD_NUM" 221 | "CIRCLE_PROJECT_REPONAME" 222 | "CIRCLE_PROJECT_USERNAME" 223 | "CIRCLE_REPOSITORY_URL" 224 | "CIRCLE_SHA1" 225 | "CIRCLE_STAGE" 226 | "CIRCLE_USERNAME" 227 | "CIRCLE_WORKFLOW_ID" 228 | "CIRCLE_WORKFLOW_JOB_ID" 229 | "CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS" 230 | "CIRCLE_WORKFLOW_WORKSPACE_ID" 231 | ) 232 | fi 233 | 234 | # Configure the service account for pulling the docker image. 235 | function repo_root() { 236 | local dir="$1" 237 | while [[ ! -d "${dir}/.git" ]]; do 238 | dir="$(dirname "$dir")" 239 | done 240 | echo "${dir}" 241 | } 242 | 243 | # Detect the project root. In CI builds, we assume the script is in 244 | # the git tree and traverse from there, otherwise, traverse from `pwd` 245 | # to find `.git` directory. 246 | if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then 247 | PROGRAM_PATH="$(realpath "$0")" 248 | PROGRAM_DIR="$(dirname "${PROGRAM_PATH}")" 249 | PROJECT_ROOT="$(repo_root "${PROGRAM_DIR}")" 250 | else 251 | PROJECT_ROOT="$(repo_root $(pwd))" 252 | fi 253 | 254 | log_yellow "Changing to the project root: ${PROJECT_ROOT}." 255 | cd "${PROJECT_ROOT}" 256 | 257 | # To support relative path for `TRAMPOLINE_SERVICE_ACCOUNT`, we need 258 | # to use this environment variable in `PROJECT_ROOT`. 259 | if [[ -n "${TRAMPOLINE_SERVICE_ACCOUNT:-}" ]]; then 260 | 261 | mkdir -p "${tmpdir}/gcloud" 262 | gcloud_config_dir="${tmpdir}/gcloud" 263 | 264 | log_yellow "Using isolated gcloud config: ${gcloud_config_dir}." 265 | export CLOUDSDK_CONFIG="${gcloud_config_dir}" 266 | 267 | log_yellow "Using ${TRAMPOLINE_SERVICE_ACCOUNT} for authentication." 268 | gcloud auth activate-service-account \ 269 | --key-file "${TRAMPOLINE_SERVICE_ACCOUNT}" 270 | log_yellow "Configuring Container Registry access" 271 | gcloud auth configure-docker --quiet 272 | fi 273 | 274 | required_envvars=( 275 | # The basic trampoline configurations. 276 | "TRAMPOLINE_IMAGE" 277 | "TRAMPOLINE_BUILD_FILE" 278 | ) 279 | 280 | if [[ -f "${PROJECT_ROOT}/.trampolinerc" ]]; then 281 | source "${PROJECT_ROOT}/.trampolinerc" 282 | fi 283 | 284 | log_yellow "Checking environment variables." 285 | for e in "${required_envvars[@]}" 286 | do 287 | if [[ -z "${!e:-}" ]]; then 288 | log "Missing ${e} env var. Aborting." 289 | exit 1 290 | fi 291 | done 292 | 293 | # We want to support legacy style TRAMPOLINE_BUILD_FILE used with V1 294 | # script: e.g. "github/repo-name/.kokoro/run_tests.sh" 295 | TRAMPOLINE_BUILD_FILE="${TRAMPOLINE_BUILD_FILE#github/*/}" 296 | log_yellow "Using TRAMPOLINE_BUILD_FILE: ${TRAMPOLINE_BUILD_FILE}" 297 | 298 | # ignore error on docker operations and test execution 299 | set +e 300 | 301 | log_yellow "Preparing Docker image." 302 | # We only download the docker image in CI builds. 303 | if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then 304 | # Download the docker image specified by `TRAMPOLINE_IMAGE` 305 | 306 | # We may want to add --max-concurrent-downloads flag. 307 | 308 | log_yellow "Start pulling the Docker image: ${TRAMPOLINE_IMAGE}." 309 | if docker pull "${TRAMPOLINE_IMAGE}"; then 310 | log_green "Finished pulling the Docker image: ${TRAMPOLINE_IMAGE}." 311 | has_image="true" 312 | else 313 | log_red "Failed pulling the Docker image: ${TRAMPOLINE_IMAGE}." 314 | has_image="false" 315 | fi 316 | else 317 | # For local run, check if we have the image. 318 | if docker images "${TRAMPOLINE_IMAGE}" | grep "${TRAMPOLINE_IMAGE%:*}"; then 319 | has_image="true" 320 | else 321 | has_image="false" 322 | fi 323 | fi 324 | 325 | 326 | # The default user for a Docker container has uid 0 (root). To avoid 327 | # creating root-owned files in the build directory we tell docker to 328 | # use the current user ID. 329 | user_uid="$(id -u)" 330 | user_gid="$(id -g)" 331 | user_name="$(id -un)" 332 | 333 | # To allow docker in docker, we add the user to the docker group in 334 | # the host os. 335 | docker_gid=$(cut -d: -f3 < <(getent group docker)) 336 | 337 | update_cache="false" 338 | if [[ "${TRAMPOLINE_DOCKERFILE:-none}" != "none" ]]; then 339 | # Build the Docker image from the source. 340 | context_dir=$(dirname "${TRAMPOLINE_DOCKERFILE}") 341 | docker_build_flags=( 342 | "-f" "${TRAMPOLINE_DOCKERFILE}" 343 | "-t" "${TRAMPOLINE_IMAGE}" 344 | "--build-arg" "UID=${user_uid}" 345 | "--build-arg" "USERNAME=${user_name}" 346 | ) 347 | if [[ "${has_image}" == "true" ]]; then 348 | docker_build_flags+=("--cache-from" "${TRAMPOLINE_IMAGE}") 349 | fi 350 | 351 | log_yellow "Start building the docker image." 352 | if [[ "${TRAMPOLINE_VERBOSE:-false}" == "true" ]]; then 353 | echo "docker build" "${docker_build_flags[@]}" "${context_dir}" 354 | fi 355 | 356 | # ON CI systems, we want to suppress docker build logs, only 357 | # output the logs when it fails. 358 | if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then 359 | if docker build "${docker_build_flags[@]}" "${context_dir}" \ 360 | > "${tmpdir}/docker_build.log" 2>&1; then 361 | if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then 362 | cat "${tmpdir}/docker_build.log" 363 | fi 364 | 365 | log_green "Finished building the docker image." 366 | update_cache="true" 367 | else 368 | log_red "Failed to build the Docker image, aborting." 369 | log_yellow "Dumping the build logs:" 370 | cat "${tmpdir}/docker_build.log" 371 | exit 1 372 | fi 373 | else 374 | if docker build "${docker_build_flags[@]}" "${context_dir}"; then 375 | log_green "Finished building the docker image." 376 | update_cache="true" 377 | else 378 | log_red "Failed to build the Docker image, aborting." 379 | exit 1 380 | fi 381 | fi 382 | else 383 | if [[ "${has_image}" != "true" ]]; then 384 | log_red "We do not have ${TRAMPOLINE_IMAGE} locally, aborting." 385 | exit 1 386 | fi 387 | fi 388 | 389 | # We use an array for the flags so they are easier to document. 390 | docker_flags=( 391 | # Remove the container after it exists. 392 | "--rm" 393 | 394 | # Use the host network. 395 | "--network=host" 396 | 397 | # Run in priviledged mode. We are not using docker for sandboxing or 398 | # isolation, just for packaging our dev tools. 399 | "--privileged" 400 | 401 | # Run the docker script with the user id. Because the docker image gets to 402 | # write in ${PWD} you typically want this to be your user id. 403 | # To allow docker in docker, we need to use docker gid on the host. 404 | "--user" "${user_uid}:${docker_gid}" 405 | 406 | # Pass down the USER. 407 | "--env" "USER=${user_name}" 408 | 409 | # Mount the project directory inside the Docker container. 410 | "--volume" "${PROJECT_ROOT}:${TRAMPOLINE_WORKSPACE}" 411 | "--workdir" "${TRAMPOLINE_WORKSPACE}" 412 | "--env" "PROJECT_ROOT=${TRAMPOLINE_WORKSPACE}" 413 | 414 | # Mount the temporary home directory. 415 | "--volume" "${tmphome}:/h" 416 | "--env" "HOME=/h" 417 | 418 | # Allow docker in docker. 419 | "--volume" "/var/run/docker.sock:/var/run/docker.sock" 420 | 421 | # Mount the /tmp so that docker in docker can mount the files 422 | # there correctly. 423 | "--volume" "/tmp:/tmp" 424 | # Pass down the KOKORO_GFILE_DIR and KOKORO_KEYSTORE_DIR 425 | # TODO(tmatsuo): This part is not portable. 426 | "--env" "TRAMPOLINE_SECRET_DIR=/secrets" 427 | "--volume" "${KOKORO_GFILE_DIR:-/dev/shm}:/secrets/gfile" 428 | "--env" "KOKORO_GFILE_DIR=/secrets/gfile" 429 | "--volume" "${KOKORO_KEYSTORE_DIR:-/dev/shm}:/secrets/keystore" 430 | "--env" "KOKORO_KEYSTORE_DIR=/secrets/keystore" 431 | ) 432 | 433 | # Add an option for nicer output if the build gets a tty. 434 | if [[ -t 0 ]]; then 435 | docker_flags+=("-it") 436 | fi 437 | 438 | # Passing down env vars 439 | for e in "${pass_down_envvars[@]}" 440 | do 441 | if [[ -n "${!e:-}" ]]; then 442 | docker_flags+=("--env" "${e}=${!e}") 443 | fi 444 | done 445 | 446 | # If arguments are given, all arguments will become the commands run 447 | # in the container, otherwise run TRAMPOLINE_BUILD_FILE. 448 | if [[ $# -ge 1 ]]; then 449 | log_yellow "Running the given commands '" "${@:1}" "' in the container." 450 | readonly commands=("${@:1}") 451 | if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then 452 | echo docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" "${commands[@]}" 453 | fi 454 | docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" "${commands[@]}" 455 | else 456 | log_yellow "Running the tests in a Docker container." 457 | docker_flags+=("--entrypoint=${TRAMPOLINE_BUILD_FILE}") 458 | if [[ "${TRAMPOLINE_VERBOSE:-}" == "true" ]]; then 459 | echo docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" 460 | fi 461 | docker run "${docker_flags[@]}" "${TRAMPOLINE_IMAGE}" 462 | fi 463 | 464 | 465 | test_retval=$? 466 | 467 | if [[ ${test_retval} -eq 0 ]]; then 468 | log_green "Build finished with ${test_retval}" 469 | else 470 | log_red "Build finished with ${test_retval}" 471 | fi 472 | 473 | # Only upload it when the test passes. 474 | if [[ "${update_cache}" == "true" ]] && \ 475 | [[ $test_retval == 0 ]] && \ 476 | [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]]; then 477 | log_yellow "Uploading the Docker image." 478 | if docker push "${TRAMPOLINE_IMAGE}"; then 479 | log_green "Finished uploading the Docker image." 480 | else 481 | log_red "Failed uploading the Docker image." 482 | fi 483 | # Call trampoline_after_upload_hook if it's defined. 484 | if function_exists trampoline_after_upload_hook; then 485 | trampoline_after_upload_hook 486 | fi 487 | 488 | fi 489 | 490 | exit "${test_retval}" 491 | -------------------------------------------------------------------------------- /.mocharc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | const config = { 15 | "enable-source-maps": true, 16 | "throw-deprecation": true, 17 | "timeout": 10000, 18 | "recursive": true 19 | } 20 | if (process.env.MOCHA_THROW_DEPRECATION === 'false') { 21 | delete config['throw-deprecation']; 22 | } 23 | if (process.env.MOCHA_REPORTER) { 24 | config.reporter = process.env.MOCHA_REPORTER; 25 | } 26 | if (process.env.MOCHA_REPORTER_OUTPUT) { 27 | config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; 28 | } 29 | module.exports = config 30 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "report-dir": "./.coverage", 3 | "reporter": ["text", "lcov"], 4 | "exclude": [ 5 | "**/*-test", 6 | "**/.coverage", 7 | "**/apis", 8 | "**/benchmark", 9 | "**/conformance", 10 | "**/docs", 11 | "**/samples", 12 | "**/scripts", 13 | "**/protos", 14 | "**/test", 15 | "**/*.d.ts", 16 | ".jsdoc.js", 17 | "**/.jsdoc.js", 18 | "karma.conf.js", 19 | "webpack-tests.config.js", 20 | "webpack.config.js" 21 | ], 22 | "exclude-after-remap": false, 23 | "all": true 24 | } 25 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | test/fixtures 4 | build/ 5 | docs/ 6 | protos/ 7 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | module.exports = { 16 | ...require('gts/.prettierrc.json') 17 | } 18 | -------------------------------------------------------------------------------- /.readme-partials.yaml: -------------------------------------------------------------------------------- 1 | introduction: |- 2 | **_THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024_** 3 | 4 | Get a list of globally available Google Compute Engine images. 5 | -------------------------------------------------------------------------------- /.repo-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gce-images", 3 | "name_pretty": "GCE Images", 4 | "product_documentation": "https://cloud.google.com/compute/docs/images", 5 | "client_documentation": "https://cloud.google.com/nodejs/docs/reference/gce-images/latest", 6 | "issue_tracker": "https://github.com/googleapis/gce-images/issues", 7 | "release_level": "stable", 8 | "language": "nodejs", 9 | "repo": "googleapis/gce-images", 10 | "distribution_name": "gce-images", 11 | "library_type": "OTHER" 12 | } 13 | -------------------------------------------------------------------------------- /.trampolinerc: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Template for .trampolinerc 16 | 17 | # Add required env vars here. 18 | required_envvars+=( 19 | ) 20 | 21 | # Add env vars which are passed down into the container here. 22 | pass_down_envvars+=( 23 | "AUTORELEASE_PR" 24 | "VERSION" 25 | ) 26 | 27 | # Prevent unintentional override on the default image. 28 | if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \ 29 | [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then 30 | echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image." 31 | exit 1 32 | fi 33 | 34 | # Define the default value if it makes sense. 35 | if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then 36 | TRAMPOLINE_IMAGE_UPLOAD="" 37 | fi 38 | 39 | if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then 40 | TRAMPOLINE_IMAGE="" 41 | fi 42 | 43 | if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then 44 | TRAMPOLINE_DOCKERFILE="" 45 | fi 46 | 47 | if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then 48 | TRAMPOLINE_BUILD_FILE="" 49 | fi 50 | 51 | # Secret Manager secrets. 52 | source ${PROJECT_ROOT}/.kokoro/populate-secrets.sh 53 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | [npm history][1] 4 | 5 | [1]: https://www.npmjs.com/package/gce-images?activeTab=versions 6 | 7 | ## [5.0.0](https://github.com/googleapis/nodejs-gce-images/compare/v4.0.1...v5.0.0) (2024-02-06) 8 | 9 | 10 | ### ⚠ BREAKING CHANGES 11 | 12 | * upgrade to Node 14 ([#377](https://github.com/googleapis/nodejs-gce-images/issues/377)) 13 | 14 | ### Miscellaneous Chores 15 | 16 | * Upgrade to Node 14 ([#377](https://github.com/googleapis/nodejs-gce-images/issues/377)) ([cc9d6ba](https://github.com/googleapis/nodejs-gce-images/commit/cc9d6ba13e29730234676e603f000584b99fde06)) 17 | 18 | ## [4.0.1](https://github.com/googleapis/nodejs-gce-images/compare/v4.0.0...v4.0.1) (2022-08-23) 19 | 20 | 21 | ### Bug Fixes 22 | 23 | * remove pip install statements ([#1546](https://github.com/googleapis/nodejs-gce-images/issues/1546)) ([#350](https://github.com/googleapis/nodejs-gce-images/issues/350)) ([5b5384c](https://github.com/googleapis/nodejs-gce-images/commit/5b5384cd4e366b17c0c826d5d1b48331b0a5a198)) 24 | 25 | ## [4.0.0](https://github.com/googleapis/nodejs-gce-images/compare/v3.0.5...v4.0.0) (2022-05-20) 26 | 27 | 28 | ### ⚠ BREAKING CHANGES 29 | 30 | * update library to use Node 12 (#344) 31 | 32 | ### Build System 33 | 34 | * update library to use Node 12 ([#344](https://github.com/googleapis/nodejs-gce-images/issues/344)) ([9b30483](https://github.com/googleapis/nodejs-gce-images/commit/9b30483f472ecf61861b8abfbb009a5a062c9edf)) 35 | 36 | ### [3.0.5](https://github.com/googleapis/nodejs-gce-images/compare/v3.0.4...v3.0.5) (2022-04-13) 37 | 38 | 39 | ### Bug Fixes 40 | 41 | * **typescript:** address bug with GoogleAuth types ([#336](https://github.com/googleapis/nodejs-gce-images/issues/336)) ([c78f532](https://github.com/googleapis/nodejs-gce-images/commit/c78f532a95bf90f04b2628d536abf5f23c0e41ee)) 42 | 43 | ### [3.0.4](https://www.github.com/googleapis/nodejs-gce-images/compare/v3.0.3...v3.0.4) (2021-08-14) 44 | 45 | 46 | ### Bug Fixes 47 | 48 | * **build:** migrate to using main branch ([#310](https://www.github.com/googleapis/nodejs-gce-images/issues/310)) ([327a5a4](https://www.github.com/googleapis/nodejs-gce-images/commit/327a5a4645c5a766fa9f089d7b4dfba31f10db86)) 49 | 50 | ### [3.0.3](https://www.github.com/googleapis/nodejs-gce-images/compare/v3.0.2...v3.0.3) (2021-02-09) 51 | 52 | 53 | ### Bug Fixes 54 | 55 | * **deps:** update dependency google-auth-library to v7 ([#285](https://www.github.com/googleapis/nodejs-gce-images/issues/285)) ([913b976](https://www.github.com/googleapis/nodejs-gce-images/commit/913b97685ced8c5c05c9892be83d2a2dd5bca7b9)) 56 | 57 | ### [3.0.2](https://www.github.com/googleapis/nodejs-gce-images/compare/v3.0.1...v3.0.2) (2020-09-23) 58 | 59 | 60 | ### Bug Fixes 61 | 62 | * **coreos:** handle coreos deprecation ([#270](https://www.github.com/googleapis/nodejs-gce-images/issues/270)) ([38ec012](https://www.github.com/googleapis/nodejs-gce-images/commit/38ec012cb376083e20b1d3b726f7bc8044ba647e)) 63 | 64 | ### [3.0.1](https://www.github.com/googleapis/nodejs-gce-images/compare/v3.0.0...v3.0.1) (2020-07-10) 65 | 66 | 67 | ### Bug Fixes 68 | 69 | * typeo in nodejs .gitattribute ([#246](https://www.github.com/googleapis/nodejs-gce-images/issues/246)) ([8d690b1](https://www.github.com/googleapis/nodejs-gce-images/commit/8d690b1fd7570573765c842a3b3e4c6162535824)) 70 | 71 | ## [3.0.0](https://www.github.com/googleapis/nodejs-gce-images/compare/v2.1.4...v3.0.0) (2020-06-04) 72 | 73 | 74 | ### ⚠ BREAKING CHANGES 75 | 76 | * update to latest version of gts/typescript (#223) 77 | * drop Node 8 from engines field (#221) 78 | 79 | ### Features 80 | 81 | * drop Node 8 from engines field ([#221](https://www.github.com/googleapis/nodejs-gce-images/issues/221)) ([66f0265](https://www.github.com/googleapis/nodejs-gce-images/commit/66f0265bddeb93d8c612b70d0d3cf386f5ce56b2)) 82 | 83 | 84 | ### Bug Fixes 85 | 86 | * **deps:** update dependency google-auth-library to v6 ([#220](https://www.github.com/googleapis/nodejs-gce-images/issues/220)) ([be859ff](https://www.github.com/googleapis/nodejs-gce-images/commit/be859ffce2c12da117a844146d18521dbe67424e)) 87 | * apache license URL ([#468](https://www.github.com/googleapis/nodejs-gce-images/issues/468)) ([#227](https://www.github.com/googleapis/nodejs-gce-images/issues/227)) ([4a9744f](https://www.github.com/googleapis/nodejs-gce-images/commit/4a9744fb9a77801a3e2bf0b59fc38631dc402769)) 88 | 89 | 90 | ### Build System 91 | 92 | * update to latest version of gts/typescript ([#223](https://www.github.com/googleapis/nodejs-gce-images/issues/223)) ([df07287](https://www.github.com/googleapis/nodejs-gce-images/commit/df0728732054ad79c6ea2ac57a4eb0aec063c0dd)) 93 | 94 | ### [2.1.4](https://www.github.com/googleapis/nodejs-gce-images/compare/v2.1.3...v2.1.4) (2020-01-06) 95 | 96 | 97 | ### Bug Fixes 98 | 99 | * add repo metadata ([#183](https://www.github.com/googleapis/nodejs-gce-images/issues/183)) ([a85c7a8](https://www.github.com/googleapis/nodejs-gce-images/commit/a85c7a89b6dbfbfc432c4a298d7910add1dfa66d)) 100 | * **build:** run synthtool with new repo name ([#191](https://www.github.com/googleapis/nodejs-gce-images/issues/191)) ([a695c78](https://www.github.com/googleapis/nodejs-gce-images/commit/a695c7879329ebf4765c4b03e0bc4da3ea6a20df)) 101 | * **deps:** TypeScript 3.7.0 causes breaking change in typings ([#190](https://www.github.com/googleapis/nodejs-gce-images/issues/190)) ([4f15c1f](https://www.github.com/googleapis/nodejs-gce-images/commit/4f15c1f133346f20d388bf42728e2e91a8745831)) 102 | 103 | ### [2.1.3](https://www.github.com/googleapis/gce-images/compare/v2.1.2...v2.1.3) (2019-09-06) 104 | 105 | 106 | ### Bug Fixes 107 | 108 | * use `compute.googleapis.com` as base URI ([#168](https://www.github.com/googleapis/gce-images/issues/168)) ([98c45e5](https://www.github.com/googleapis/gce-images/commit/98c45e5)) 109 | 110 | ### [2.1.2](https://www.github.com/googleapis/gce-images/compare/v2.1.1...v2.1.2) (2019-07-29) 111 | 112 | 113 | ### Bug Fixes 114 | 115 | * **deps:** update dependency google-auth-library to v5 ([#161](https://www.github.com/googleapis/gce-images/issues/161)) ([21bc2ed](https://www.github.com/googleapis/gce-images/commit/21bc2ed)) 116 | 117 | ### [2.1.1](https://www.github.com/googleapis/gce-images/compare/v2.1.0...v2.1.1) (2019-06-26) 118 | 119 | 120 | ### Bug Fixes 121 | 122 | * **docs:** make anchors work in jsdoc ([#157](https://www.github.com/googleapis/gce-images/issues/157)) ([1312f48](https://www.github.com/googleapis/gce-images/commit/1312f48)) 123 | 124 | ## [2.1.0](https://www.github.com/googleapis/gce-images/compare/v2.0.0...v2.1.0) (2019-06-24) 125 | 126 | 127 | ### Features 128 | 129 | * support apiEndpoint override ([#155](https://www.github.com/googleapis/gce-images/issues/155)) ([bb4037f](https://www.github.com/googleapis/gce-images/commit/bb4037f)) 130 | 131 | ## [2.0.0](https://www.github.com/googleapis/gce-images/compare/v1.1.0...v2.0.0) (2019-05-09) 132 | 133 | 134 | ### Bug Fixes 135 | 136 | * **deps:** update dependency google-auth-library to v4 ([#143](https://www.github.com/googleapis/gce-images/issues/143)) ([e24ff51](https://www.github.com/googleapis/gce-images/commit/e24ff51)) 137 | * remove unused pify dependency ([#138](https://www.github.com/googleapis/gce-images/issues/138)) ([e189506](https://www.github.com/googleapis/gce-images/commit/e189506)) 138 | * **deps:** update dependency arrify to v2 ([#130](https://www.github.com/googleapis/gce-images/issues/130)) ([0d6cec3](https://www.github.com/googleapis/gce-images/commit/0d6cec3)) 139 | 140 | 141 | ### Build System 142 | 143 | * upgrade engines field to >=8.10.0 ([#135](https://www.github.com/googleapis/gce-images/issues/135)) ([5bace32](https://www.github.com/googleapis/gce-images/commit/5bace32)) 144 | 145 | 146 | ### BREAKING CHANGES 147 | 148 | * upgrade engines field to >=8.10.0 (#135) 149 | 150 | ## v1.1.0 151 | 152 | 02-05-2019 15:28 PST 153 | 154 | ### New Features 155 | - feat: introduce async methods ([#100](https://github.com/googleapis/gce-images/pull/100)) 156 | 157 | ### Dependencies 158 | - fix(deps): update dependency google-auth-library to v3 ([#103](https://github.com/googleapis/gce-images/pull/103)) 159 | 160 | ### Documentation 161 | - docs: add lint/fix example to contributing guide ([#107](https://github.com/googleapis/gce-images/pull/107)) 162 | - docs: add samples and sample tests ([#88](https://github.com/googleapis/gce-images/pull/88)) 163 | 164 | ## v1.0.0 165 | 166 | Welcome to 1.0! The big feature in this release is the availability of TypeScript types out of the box. To that end, there is a breaking change: 167 | 168 | **BREAKING CHANGE**: The `GCEImages` object must now be instantiated. 169 | 170 | #### Old Code 171 | ```js 172 | const images = require('gce-images')(); 173 | ``` 174 | 175 | #### New Code 176 | ```js 177 | const {GCEImages} = require('gce-images'); 178 | const images = new GCEImages(); 179 | ``` 180 | ====== 181 | 182 | ### New Features 183 | - feat: convert to TypeScript ([#21](https://github.com/GoogleCloudPlatform/gce-images/pull/21)) 184 | - fix: improve TypeScript types ([#72](https://github.com/GoogleCloudPlatform/gce-images/pull/72)) 185 | 186 | ### Dependencies 187 | - fix(deps): update dependency google-auth-library to v2 ([#33](https://github.com/GoogleCloudPlatform/gce-images/pull/33)) 188 | - chore: drop dependency on got and google-auto-auth ([#23](https://github.com/GoogleCloudPlatform/gce-images/pull/23)) 189 | 190 | ### Documentation 191 | 192 | ### Internal / Testing Changes 193 | - chore: update CircleCI config ([#71](https://github.com/GoogleCloudPlatform/gce-images/pull/71)) 194 | - chore: include build in eslintignore ([#68](https://github.com/GoogleCloudPlatform/gce-images/pull/68)) 195 | - chore(deps): update dependency eslint-plugin-node to v8 ([#64](https://github.com/GoogleCloudPlatform/gce-images/pull/64)) 196 | - chore: update issue templates ([#63](https://github.com/GoogleCloudPlatform/gce-images/pull/63)) 197 | - chore: remove old issue template ([#61](https://github.com/GoogleCloudPlatform/gce-images/pull/61)) 198 | - build: run tests on node11 ([#60](https://github.com/GoogleCloudPlatform/gce-images/pull/60)) 199 | - chores(build): run codecov on continuous builds ([#55](https://github.com/GoogleCloudPlatform/gce-images/pull/55)) 200 | - chore(deps): update dependency typescript to ~3.1.0 ([#57](https://github.com/GoogleCloudPlatform/gce-images/pull/57)) 201 | - chore(deps): update dependency eslint-plugin-prettier to v3 ([#58](https://github.com/GoogleCloudPlatform/gce-images/pull/58)) 202 | - chores(build): do not collect sponge.xml from windows builds ([#56](https://github.com/GoogleCloudPlatform/gce-images/pull/56)) 203 | - chore: update new issue template ([#54](https://github.com/GoogleCloudPlatform/gce-images/pull/54)) 204 | - chore: update build config ([#51](https://github.com/GoogleCloudPlatform/gce-images/pull/51)) 205 | - Update kokoro config ([#48](https://github.com/GoogleCloudPlatform/gce-images/pull/48)) 206 | - Re-generate library using /synth.py ([#45](https://github.com/GoogleCloudPlatform/gce-images/pull/45)) 207 | - Update kokoro config ([#44](https://github.com/GoogleCloudPlatform/gce-images/pull/44)) 208 | - test: remove appveyor config ([#43](https://github.com/GoogleCloudPlatform/gce-images/pull/43)) 209 | - Update CI config ([#42](https://github.com/GoogleCloudPlatform/gce-images/pull/42)) 210 | - Enable prefer-const in the eslint config ([#40](https://github.com/GoogleCloudPlatform/gce-images/pull/40)) 211 | - Enable no-var in eslint ([#39](https://github.com/GoogleCloudPlatform/gce-images/pull/39)) 212 | - Move to the new github org ([#38](https://github.com/GoogleCloudPlatform/gce-images/pull/38)) 213 | - Update CI config ([#37](https://github.com/GoogleCloudPlatform/gce-images/pull/37)) 214 | - Retry npm install in CI ([#35](https://github.com/GoogleCloudPlatform/gce-images/pull/35)) 215 | - Update CI config ([#32](https://github.com/GoogleCloudPlatform/gce-images/pull/32)) 216 | - chore(deps): update dependency nyc to v13 ([#31](https://github.com/GoogleCloudPlatform/gce-images/pull/31)) 217 | - remove the docs command 218 | - Update the CI config ([#30](https://github.com/GoogleCloudPlatform/gce-images/pull/30)) 219 | - test: add a key for CircleCI ([#29](https://github.com/GoogleCloudPlatform/gce-images/pull/29)) 220 | - Re-generate library using /synth.py ([#28](https://github.com/GoogleCloudPlatform/gce-images/pull/28)) 221 | - chore(deps): update dependency eslint-config-prettier to v3 ([#27](https://github.com/GoogleCloudPlatform/gce-images/pull/27)) 222 | - chore: ignore package-lock.json ([#26](https://github.com/GoogleCloudPlatform/gce-images/pull/26)) 223 | - chore(deps): lock file maintenance ([#25](https://github.com/GoogleCloudPlatform/gce-images/pull/25)) 224 | - chore: update renovate config ([#20](https://github.com/GoogleCloudPlatform/gce-images/pull/20)) 225 | - chore: upgrade to es6 ([#24](https://github.com/GoogleCloudPlatform/gce-images/pull/24)) 226 | - chore(deps): update dependency mocha to v5 ([#17](https://github.com/GoogleCloudPlatform/gce-images/pull/17)) 227 | - fix(deps): update dependency async to v2 ([#18](https://github.com/GoogleCloudPlatform/gce-images/pull/18)) 228 | - fix(deps): update dependency google-auto-auth to ^0.10.0 ([#16](https://github.com/GoogleCloudPlatform/gce-images/pull/16)) 229 | - Check in synth.py and conform to google node repo standards ([#14](https://github.com/GoogleCloudPlatform/gce-images/pull/14)) 230 | - Update renovate.json 231 | - Add renovate.json 232 | - chore: fix the directory structure ([#12](https://github.com/GoogleCloudPlatform/gce-images/pull/12)) 233 | - chore: make it OSPO compliant ([#10](https://github.com/GoogleCloudPlatform/gce-images/pull/10)) 234 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 2 | # Code of Conduct 3 | 4 | ## Our Pledge 5 | 6 | In the interest of fostering an open and welcoming environment, we as 7 | contributors and maintainers pledge to making participation in our project and 8 | our community a harassment-free experience for everyone, regardless of age, body 9 | size, disability, ethnicity, gender identity and expression, level of 10 | experience, education, socio-economic status, nationality, personal appearance, 11 | race, religion, or sexual identity and orientation. 12 | 13 | ## Our Standards 14 | 15 | Examples of behavior that contributes to creating a positive environment 16 | include: 17 | 18 | * Using welcoming and inclusive language 19 | * Being respectful of differing viewpoints and experiences 20 | * Gracefully accepting constructive criticism 21 | * Focusing on what is best for the community 22 | * Showing empathy towards other community members 23 | 24 | Examples of unacceptable behavior by participants include: 25 | 26 | * The use of sexualized language or imagery and unwelcome sexual attention or 27 | advances 28 | * Trolling, insulting/derogatory comments, and personal or political attacks 29 | * Public or private harassment 30 | * Publishing others' private information, such as a physical or electronic 31 | address, without explicit permission 32 | * Other conduct which could reasonably be considered inappropriate in a 33 | professional setting 34 | 35 | ## Our Responsibilities 36 | 37 | Project maintainers are responsible for clarifying the standards of acceptable 38 | behavior and are expected to take appropriate and fair corrective action in 39 | response to any instances of unacceptable behavior. 40 | 41 | Project maintainers have the right and responsibility to remove, edit, or reject 42 | comments, commits, code, wiki edits, issues, and other contributions that are 43 | not aligned to this Code of Conduct, or to ban temporarily or permanently any 44 | contributor for other behaviors that they deem inappropriate, threatening, 45 | offensive, or harmful. 46 | 47 | ## Scope 48 | 49 | This Code of Conduct applies both within project spaces and in public spaces 50 | when an individual is representing the project or its community. Examples of 51 | representing a project or community include using an official project e-mail 52 | address, posting via an official social media account, or acting as an appointed 53 | representative at an online or offline event. Representation of a project may be 54 | further defined and clarified by project maintainers. 55 | 56 | This Code of Conduct also applies outside the project spaces when the Project 57 | Steward has a reasonable belief that an individual's behavior may have a 58 | negative impact on the project or its community. 59 | 60 | ## Conflict Resolution 61 | 62 | We do not believe that all conflict is bad; healthy debate and disagreement 63 | often yield positive results. However, it is never okay to be disrespectful or 64 | to engage in behavior that violates the project’s code of conduct. 65 | 66 | If you see someone violating the code of conduct, you are encouraged to address 67 | the behavior directly with those involved. Many issues can be resolved quickly 68 | and easily, and this gives people more control over the outcome of their 69 | dispute. If you are unable to resolve the matter for any reason, or if the 70 | behavior is threatening or harassing, report it. We are dedicated to providing 71 | an environment where participants feel welcome and safe. 72 | 73 | Reports should be directed to *googleapis-stewards@google.com*, the 74 | Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to 75 | receive and address reported violations of the code of conduct. They will then 76 | work with a committee consisting of representatives from the Open Source 77 | Programs Office and the Google Open Source Strategy team. If for any reason you 78 | are uncomfortable reaching out to the Project Steward, please email 79 | opensource@google.com. 80 | 81 | We will investigate every complaint, but you may not receive a direct response. 82 | We will use our discretion in determining when and how to follow up on reported 83 | incidents, which may range from not taking action to permanent expulsion from 84 | the project and project-sponsored spaces. We will notify the accused of the 85 | report and provide them an opportunity to discuss it before any action is taken. 86 | The identity of the reporter will be omitted from the details of the report 87 | supplied to the accused. In potentially harmful situations, such as ongoing 88 | harassment or threats to anyone's safety, we may take action without notice. 89 | 90 | ## Attribution 91 | 92 | This Code of Conduct is adapted from the Contributor Covenant, version 1.4, 93 | available at 94 | https://www.contributor-covenant.org/version/1/4/code-of-conduct.html -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | **Table of contents** 4 | 5 | * [Contributor License Agreements](#contributor-license-agreements) 6 | * [Contributing a patch](#contributing-a-patch) 7 | * [Running the tests](#running-the-tests) 8 | * [Releasing the library](#releasing-the-library) 9 | 10 | ## Contributor License Agreements 11 | 12 | We'd love to accept your sample apps and patches! Before we can take them, we 13 | have to jump a couple of legal hurdles. 14 | 15 | Please fill out either the individual or corporate Contributor License Agreement 16 | (CLA). 17 | 18 | * If you are an individual writing original source code and you're sure you 19 | own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). 20 | * If you work for a company that wants to allow you to contribute your work, 21 | then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). 22 | 23 | Follow either of the two links above to access the appropriate CLA and 24 | instructions for how to sign and return it. Once we receive it, we'll be able to 25 | accept your pull requests. 26 | 27 | ## Contributing A Patch 28 | 29 | 1. Submit an issue describing your proposed change to the repo in question. 30 | 1. The repo owner will respond to your issue promptly. 31 | 1. If your proposed change is accepted, and you haven't already done so, sign a 32 | Contributor License Agreement (see details above). 33 | 1. Fork the desired repo, develop and test your code changes. 34 | 1. Ensure that your code adheres to the existing style in the code to which 35 | you are contributing. 36 | 1. Ensure that your code has an appropriate set of tests which all pass. 37 | 1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. 38 | 1. Submit a pull request. 39 | 40 | ### Before you begin 41 | 42 | 1. [Select or create a Cloud Platform project][projects]. 43 | 1. [Set up authentication with a service account][auth] so you can access the 44 | API from your local workstation. 45 | 46 | 47 | ## Running the tests 48 | 49 | 1. [Prepare your environment for Node.js setup][setup]. 50 | 51 | 1. Install dependencies: 52 | 53 | npm install 54 | 55 | 1. Run the tests: 56 | 57 | # Run unit tests. 58 | npm test 59 | 60 | # Run sample integration tests. 61 | npm run samples-test 62 | 63 | # Run all system tests. 64 | npm run system-test 65 | 66 | 1. Lint (and maybe fix) any changes: 67 | 68 | npm run fix 69 | 70 | [setup]: https://cloud.google.com/nodejs/docs/setup 71 | [projects]: https://console.cloud.google.com/project 72 | [billing]: https://support.google.com/cloud/answer/6293499#enable-billing 73 | 74 | [auth]: https://cloud.google.com/docs/authentication/getting-started -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Google LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **_THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024_** 2 | 3 | # gce-images 4 | > Get a list of globally available Google Compute Engine images 5 | 6 | ```sh 7 | $ npm install gce-images 8 | ``` 9 | ```js 10 | const {GCEImages} = require('gce-images'); 11 | 12 | // Create a client (see below for more about authorization) 13 | const images = new GCEImages(); 14 | 15 | images.getAll((err, images) => { 16 | /* 17 | images = { 18 | centos: { 19 | [ 20 | { 21 | kind: 'compute#image', 22 | selfLink: 'https://compute.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20150710', 23 | id: '2223645373384728207', 24 | creationTimestamp: '2015-07-13T13:32:32.483-07:00', 25 | name: 'centos-6-v20150710', 26 | description: 'CentOS, CentOS, 6.6, x86_64 built on 2015-07-10', 27 | sourceType: 'RAW', 28 | rawDisk: [Object], 29 | status: 'READY', 30 | archiveSizeBytes: '1133229966', 31 | diskSizeGb: '10' 32 | }, 33 | // ... 34 | }, 35 | coreos: { 36 | // ... 37 | }, 38 | debian: { 39 | // ... 40 | }, 41 | redhat: { 42 | // ... 43 | }, 44 | opensuse: { 45 | // ... 46 | }, 47 | suse: { 48 | // ... 49 | }, 50 | ubuntu: { 51 | // ... 52 | } 53 | }; 54 | */ 55 | }); 56 | ``` 57 | 58 | #### Get the latest image for a specific OS 59 | 60 | ```js 61 | images.getLatest('ubuntu', (err, image) => { 62 | /* 63 | image = { 64 | kind: 'compute#image', 65 | selfLink: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1504-vivid-v20150616a', 66 | id: '6610082300127119636', 67 | creationTimestamp: '2015-06-17T02:03:55.825-07:00', 68 | name: 'ubuntu-1504-vivid-v20150616a', 69 | description: 'Canonical, Ubuntu, 15.04, amd64 vivid image built on 2015-06-16', 70 | sourceType: 'RAW', 71 | rawDisk: { source: '', containerType: 'TAR' }, 72 | status: 'READY', 73 | archiveSizeBytes: '806558757', 74 | diskSizeGb: '10', 75 | licenses: [ 76 | 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid' 77 | ] 78 | } 79 | */ 80 | }); 81 | ``` 82 | 83 | #### Get the latest image for a specific OS from your project 84 | 85 | ```js 86 | images.getLatest('your-project-id-or-name/ubuntu', (err, image) => { 87 | /* 88 | image = { 89 | kind: 'compute#image', 90 | selfLink: 'https://compute.googleapis.com/compute/v1/projects/your-project-id-or-name/global/images/ubuntu-1504-vivid-v20150616a', 91 | id: '6610082300127119636', 92 | creationTimestamp: '2015-06-17T02:03:55.825-07:00', 93 | name: 'ubuntu-1504-vivid-v20150616a', 94 | description: 'Canonical, Ubuntu, 15.04, amd64 vivid image built on 2015-06-16', 95 | sourceType: 'RAW', 96 | rawDisk: { source: '', containerType: 'TAR' }, 97 | status: 'READY', 98 | archiveSizeBytes: '806558757', 99 | diskSizeGb: '10', 100 | licenses: [ 101 | 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid' 102 | ] 103 | } 104 | */ 105 | }); 106 | ``` 107 | 108 | #### Get the latest image for a specific version of an OS 109 | 110 | ```js 111 | images.getLatest('ubuntu-1404', (err, image) => { 112 | /* 113 | image = { 114 | kind: 'compute#image', 115 | selfLink: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1410-utopic-v20150625', 116 | id: '7075003915689987469', 117 | creationTimestamp: '2015-07-09T10:46:10.424-07:00', 118 | name: 'ubuntu-1410-utopic-v20150625', 119 | description: 'Canonical, Ubuntu, 14.10, amd64 utopic image built on 2015-06-25', 120 | sourceType: 'RAW', 121 | rawDisk: { source: '', containerType: 'TAR' }, 122 | status: 'READY', 123 | archiveSizeBytes: '752874399', 124 | diskSizeGb: '10', 125 | licenses: [ 126 | 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1410-utopic' 127 | ] 128 | } 129 | */ 130 | }); 131 | ``` 132 | 133 | #### Get a map of OS names to their project's api URL 134 | 135 | ```js 136 | images.OS_URLS; // also available on require('gce-images').OS_URLS; 137 | /* 138 | { 139 | centos: 'https://compute.googleapis.com/compute/v1/projects/centos-cloud/global/images', 140 | 'container-vm': 'https://compute.googleapis.com/compute/v1/projects/cos-cloud/global/images', 141 | coreos: 'https://compute.googleapis.com/compute/v1/projects/coreos-cloud/global/images', 142 | debian: 'https://compute.googleapis.com/compute/v1/projects/debian-cloud/global/images', 143 | redhat: 'https://compute.googleapis.com/compute/v1/projects/rhel-cloud/global/images', 144 | opensuse: 'https://compute.googleapis.com/compute/v1/projects/opensuse-cloud/global/images', 145 | suse: 'https://compute.googleapis.com/compute/v1/projects/suse-cloud/global/images', 146 | ubuntu: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images', 147 | windows: 'https://compute.googleapis.com/compute/v1/projects/windows-cloud/global/images' 148 | } 149 | */ 150 | ``` 151 | 152 | #### Authorization 153 | 154 | This module uses [google-auth-library](https://github.com/googleapis/google-auth-library-nodejs) to get the required access token. If you don't meet the **[requirements for automatic authentication](https://github.com/stephenplusplus/google-auto-auth#automatic-if)**, you will need to provide the same configuration object detailed in that readme. 155 | 156 | ```js 157 | const {GCEImages} = require('gce-images'); 158 | const images = new GCEImages({ keyFile: '/Users/stephen/dev/key.json' }); 159 | 160 | images.getAll((err, images) => {}); 161 | images.getLatest('ubuntu', (err, image) => {}); 162 | ``` 163 | 164 | 165 | #### Accepted OS names 166 | 167 | - `centos` (also `centos-cloud`) 168 | - `container-vm` (also `google-containers`) 169 | - `coreos` (also `coreos-cloud`) 170 | - `debian` (also `debian-cloud`) 171 | - `redhat` (also `rhel`, `rhel-cloud`) 172 | - `opensuse` (also `opensuse-cloud`) 173 | - `suse` (also `suse-cloud`) 174 | - `ubuntu` (also `ubuntu-cloud`, `ubuntu-os-cloud`) 175 | - `windows` (also `windows-cloud`) 176 | 177 | All accepted names may be suffixed with a version, e.g. `ubuntu-1404`. 178 | 179 | ### API 180 | 181 | #### {GCEImages} = require('gce-images') 182 | 183 | ##### gceImages.OS_URLS 184 | 185 | - Type: `Object` 186 | 187 | A map of OS names to their Google APIs public image URL. 188 | 189 | #### images = gceImages([authConfig]) 190 | 191 | ##### authConfig 192 | 193 | - Type: `Object` 194 | 195 | See the above section on Authorization. This object is only necessary if automatic authentication is not available in your environment. See the [google-auto-auth](https://github.com/stephenplusplus/google-auto-auth#authconfig) documentation for the accepted properties. 196 | 197 | ###### authConfig.authClient 198 | 199 | - Type: [`GoogleAuthConfig`](https://github.com/googleapis/google-auth-library-nodejs) 200 | - *Optional* 201 | 202 | If you want to re-use an auth client from [google-auto-auth](https://github.com/stephenplusplus/google-auto-auth), pass an instance here. 203 | 204 | #### images.getAll([options], callback) 205 | #### images.getLatest([options], callback) 206 | 207 | ##### options 208 | 209 | - Optional 210 | - Type: `String` or `Object` 211 | 212 | If a string, it is expanded to: `options = { osNames: [**string input**] }`. 213 | 214 | If not provided, the default `options` detailed below are used. 215 | 216 | ###### options.osNames 217 | 218 | - Type: `String[]` 219 | - Default: [All](#os-names) 220 | 221 | All operating systems you wish to receive image metadata for. See [Accepted OS names](#os-names). 222 | 223 | ###### options.deprecated 224 | 225 | - Type: `Boolean` 226 | - Default: `false` 227 | 228 | Include deprecated image metadata in results. 229 | 230 | ##### callback(err, images) 231 | 232 | ###### callback.err 233 | 234 | - Type: `Error` 235 | 236 | An error that occurred during an API request or if no results match the provided OS name or version. 237 | 238 | ###### callback.images 239 | 240 | - Type: `Object` or `Array` 241 | 242 | With `getAll`: 243 | 244 | If only a single OS is being looked up, you will receive an array of all image metadata objects for that OS. 245 | 246 | If multiple OS names were given, you will receive an object keyed by the [OS name](#os-names). Each key will reference an array of metadata objects for that OS. 247 | 248 | With `getLatest`: 249 | 250 | If only a single OS is being looked up, you will receive its metadata object back. 251 | 252 | If multiple OS names were given, you will receive an object keyed by the [OS name](#os-names). Each key will reference a metadata object. 253 | 254 | ## Disclaimer 255 | 256 | This is not an officially supported Google product. 257 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /linkinator.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "recurse": true, 3 | "skip": [ 4 | "https://codecov.io/gh/googleapis/", 5 | "www.googleapis.com", 6 | "img.shields.io" 7 | ], 8 | "silent": true, 9 | "concurrency": 10 10 | } 11 | -------------------------------------------------------------------------------- /owlbot.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import synthtool.languages.node as node 16 | 17 | node.owlbot_main(templates_excludes=['LICENSE', 'README.md']) 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gce-images", 3 | "version": "5.0.0", 4 | "description": "Get a list of globally available Google Compute Engine images", 5 | "main": "./build/src/index.js", 6 | "types": "./build/src/index.d.ts", 7 | "files": [ 8 | "build/src" 9 | ], 10 | "scripts": { 11 | "docs": "compodoc src/", 12 | "lint": "gts check", 13 | "test": "c8 mocha build/test", 14 | "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", 15 | "system-test": "echo 'no system tests'", 16 | "presystem-test": "npm run compile", 17 | "clean": "gts clean", 18 | "compile": "tsc -p .", 19 | "fix": "gts fix", 20 | "prepare": "npm run compile", 21 | "pretest": "npm run compile", 22 | "docs-test": "linkinator docs", 23 | "predocs-test": "npm run docs", 24 | "prelint": "cd samples; npm link ../; npm install", 25 | "precompile": "gts clean" 26 | }, 27 | "keywords": [ 28 | "gce", 29 | "google", 30 | "compute", 31 | "engine", 32 | "cloud", 33 | "images", 34 | "ubuntu", 35 | "linux", 36 | "redhat", 37 | "rhel", 38 | "opensuse", 39 | "suse", 40 | "debian", 41 | "coreos", 42 | "centos" 43 | ], 44 | "repository": "googleapis/nodejs-gce-images", 45 | "author": "Stephen Sawchuk ", 46 | "license": "MIT", 47 | "dependencies": { 48 | "arrify": "^2.0.0", 49 | "google-auth-library": "^9.0.0" 50 | }, 51 | "devDependencies": { 52 | "@compodoc/compodoc": "1.1.19", 53 | "@types/chai": "^4.1.7", 54 | "@types/mocha": "^9.0.0", 55 | "@types/node": "^20.4.9", 56 | "c8": "^9.0.0", 57 | "chai": "^4.2.0", 58 | "codecov": "^3.0.4", 59 | "gts": "^5.0.0", 60 | "intelli-espower-loader": "^1.0.1", 61 | "linkinator": "^3.0.0", 62 | "mocha": "^9.2.2", 63 | "source-map-support": "^0.5.6", 64 | "typescript": "^5.1.6" 65 | }, 66 | "engines": { 67 | "node": ">=14.0.0" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "docker:disable", 5 | ":disableDependencyDashboard" 6 | ], 7 | "pinVersions": false, 8 | "rebaseStalePrs": true, 9 | "schedule": [ 10 | "after 9am and before 3pm" 11 | ], 12 | "gitAuthor": null, 13 | "packageRules": [ 14 | { 15 | "extends": "packages:linters", 16 | "groupName": "linters" 17 | } 18 | ], 19 | "ignoreDeps": ["typescript"] 20 | } 21 | -------------------------------------------------------------------------------- /samples/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | rules: 3 | no-console: off 4 | node/no-missing-require: off 5 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | [//]: # "This README.md file is auto-generated, all changes to this file will be lost." 2 | [//]: # "To regenerate it, use `python -m synthtool`." 3 | Google Cloud Platform logo 4 | 5 | # [GCE Images: Node.js Samples](https://github.com/googleapis/gce-images) 6 | 7 | [![Open in Cloud Shell][shell_img]][shell_link] 8 | 9 | **_THIS REPOSITORY AND PACKAGE WILL BE DEPRECATED IN JULY 2024_** 10 | 11 | Get a list of globally available Google Compute Engine images. 12 | 13 | ## Table of Contents 14 | 15 | * [Before you begin](#before-you-begin) 16 | * [Samples](#samples) 17 | * [From Project](#from-project) 18 | * [Latest Specific OS](#latest-specific-os) 19 | * [Quickstart](#quickstart) 20 | * [Specific OS](#specific-os) 21 | 22 | ## Before you begin 23 | 24 | Before running the samples, make sure you've followed the steps outlined in 25 | [Using the client library](https://github.com/googleapis/gce-images#using-the-client-library). 26 | 27 | `cd samples` 28 | 29 | `npm install` 30 | 31 | `cd ..` 32 | 33 | ## Samples 34 | 35 | 36 | 37 | ### From Project 38 | 39 | View the [source code](https://github.com/googleapis/gce-images/blob/main/samples/fromProject.js). 40 | 41 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/gce-images&page=editor&open_in_editor=samples/fromProject.js,samples/README.md) 42 | 43 | __Usage:__ 44 | 45 | 46 | `node samples/fromProject.js` 47 | 48 | 49 | ----- 50 | 51 | 52 | 53 | 54 | ### Latest Specific OS 55 | 56 | View the [source code](https://github.com/googleapis/gce-images/blob/main/samples/latestSpecificOS.js). 57 | 58 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/gce-images&page=editor&open_in_editor=samples/latestSpecificOS.js,samples/README.md) 59 | 60 | __Usage:__ 61 | 62 | 63 | `node samples/latestSpecificOS.js` 64 | 65 | 66 | ----- 67 | 68 | 69 | 70 | 71 | ### Quickstart 72 | 73 | View the [source code](https://github.com/googleapis/gce-images/blob/main/samples/quickstart.js). 74 | 75 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/gce-images&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) 76 | 77 | __Usage:__ 78 | 79 | 80 | `node samples/quickstart.js` 81 | 82 | 83 | ----- 84 | 85 | 86 | 87 | 88 | ### Specific OS 89 | 90 | View the [source code](https://github.com/googleapis/gce-images/blob/main/samples/specificOS.js). 91 | 92 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/gce-images&page=editor&open_in_editor=samples/specificOS.js,samples/README.md) 93 | 94 | __Usage:__ 95 | 96 | 97 | `node samples/specificOS.js` 98 | 99 | 100 | 101 | 102 | 103 | 104 | [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png 105 | [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/gce-images&page=editor&open_in_editor=samples/README.md 106 | [product-docs]: https://cloud.google.com/compute/docs/images 107 | -------------------------------------------------------------------------------- /samples/fromProject.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // [START gceimages_latest_os_from_project] 18 | const {GCEImages} = require('gce-images'); 19 | 20 | async function getLatest() { 21 | const gceImages = new GCEImages(); 22 | const projectId = await gceImages.getProjectId(); 23 | const result = await gceImages.getLatest(`${projectId}/my-ubuntu-image`); 24 | console.log(result); 25 | } 26 | 27 | getLatest(); 28 | // [END gceimages_latest_os_from_project] 29 | -------------------------------------------------------------------------------- /samples/latestSpecificOS.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // [START gceimages_latest_os_specific_version] 18 | const {GCEImages} = require('gce-images'); 19 | 20 | async function getLatest() { 21 | const gceImages = new GCEImages(); 22 | const result = await gceImages.getLatest({ 23 | osNames: ['ubuntu-1404'], 24 | deprecated: true, 25 | }); 26 | console.log(result); 27 | } 28 | 29 | getLatest(); 30 | // [START gceimages_latest_os_specific_version] 31 | -------------------------------------------------------------------------------- /samples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Samples for the gce-image npm module.", 3 | "license": "MIT", 4 | "author": "Google LLC", 5 | "engines": { 6 | "node": ">=14.0.0" 7 | }, 8 | "files": [ 9 | "*.js" 10 | ], 11 | "repository": "googleapis/gce-images", 12 | "private": true, 13 | "scripts": { 14 | "test": "mocha" 15 | }, 16 | "dependencies": { 17 | "gce-images": "^5.0.0" 18 | }, 19 | "devDependencies": { 20 | "chai": "^4.2.0", 21 | "mocha": "^8.0.0" 22 | } 23 | } -------------------------------------------------------------------------------- /samples/quickstart.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // [START gceimages_quickstart] 18 | const {GCEImages} = require('gce-images'); 19 | 20 | async function getLatest() { 21 | const gceImages = new GCEImages(); 22 | const result = await gceImages.getLatest({ 23 | osNames: ['ubuntu-1404'], 24 | deprecated: true, 25 | }); 26 | console.log(result); 27 | } 28 | 29 | getLatest(); 30 | // [END gceimages_quickstart] 31 | -------------------------------------------------------------------------------- /samples/specificOS.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // [START gceimages_latest_os] 18 | const {GCEImages} = require('gce-images'); 19 | 20 | async function getLatest() { 21 | const gceImages = new GCEImages(); 22 | const result = await gceImages.getLatest({ 23 | osNames: ['ubuntu'], 24 | deprecated: true, 25 | }); 26 | console.log(result); 27 | } 28 | 29 | getLatest(); 30 | // [END gceimages_latest_os] 31 | -------------------------------------------------------------------------------- /samples/test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | mocha : true 4 | -------------------------------------------------------------------------------- /samples/test/samples.js: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const {assert} = require('chai'); 18 | const cp = require('child_process'); 19 | 20 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); 21 | 22 | describe('quickstart', () => { 23 | it('should return a list of images', () => { 24 | const stdout = execSync('node quickstart.js'); 25 | assert.match(stdout, /^{/); 26 | }); 27 | }); 28 | 29 | describe('from project', () => { 30 | it('should return an image', () => { 31 | const stdout = execSync('node fromProject.js'); 32 | assert.match(stdout, /^{/); 33 | }); 34 | }); 35 | 36 | describe('latestSpecificOS', () => { 37 | it('should return an image', () => { 38 | const stdout = execSync('node latestSpecificOS.js'); 39 | assert.match(stdout, /^{/); 40 | }); 41 | }); 42 | 43 | describe('specificOS', () => { 44 | it('should return an image', () => { 45 | const stdout = execSync('node specificOS.js'); 46 | assert.match(stdout, /^{/); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import arrify = require('arrify'); 16 | import {GoogleAuth, GoogleAuthOptions} from 'google-auth-library'; 17 | 18 | interface AuthOptions extends GoogleAuthOptions { 19 | /** 20 | * The host name used to access the compute API. 21 | * Defaults to `compute.googleapis.com`. 22 | */ 23 | apiEndpoint?: string; 24 | } 25 | 26 | export type GCEImagesConfig = Omit & { 27 | authClient?: GoogleAuth; 28 | }; 29 | 30 | export interface GetOptions { 31 | deprecated?: boolean; 32 | osNames?: string[]; 33 | } 34 | 35 | export interface Image { 36 | creationTimestamp: string; 37 | deprecated: { 38 | state: 'ACTIVE' | 'DEPRECATED' | 'OBSOLETE' | 'DELETED'; 39 | replacement: string; 40 | deprecated: string; 41 | obsolete: string; 42 | deleted: string; 43 | }; 44 | kind: 'compute#image'; 45 | selfLink: string; 46 | id: string; 47 | name: string; 48 | description: string; 49 | sourceType: string; 50 | rawDisk: {source: string; containerType: string}; 51 | status: string; 52 | archiveSizeBytes: number; 53 | diskSizeGb: number; 54 | licenses: string[]; 55 | family: string; 56 | labelFingerprint: string; 57 | guestOsFeatures: { 58 | type: 59 | | 'MULTI_IP_SUBNET' 60 | | 'UEFI_COMPATIBLE' 61 | | 'VIRTIO_SCSI_MULTIQUEUE' 62 | | 'WINDOWS'; 63 | }[]; 64 | licenseCodes: string[]; 65 | storageLocations: string[]; 66 | } 67 | 68 | export interface GetAllCallback { 69 | (err: Error | null, images?: Image[] | ImagesMap): void; 70 | } 71 | 72 | export interface GetLatestCallback { 73 | (err: Error | null, images?: Image | ImageMap): void; 74 | } 75 | 76 | export interface ImagesMap { 77 | [index: string]: Image[]; 78 | } 79 | export interface ImageMap { 80 | [index: string]: Image; 81 | } 82 | 83 | interface ParsedArguments { 84 | options: O; 85 | callback: C; 86 | } 87 | 88 | export interface OSUrls { 89 | centos: string; 90 | 'container-vm': string; 91 | coreos: string; 92 | debian: string; 93 | redhat: string; 94 | opensuse: string; 95 | suse: string; 96 | ubuntu: string; 97 | windows: string; 98 | } 99 | 100 | function isGoogleAuthOptions( 101 | config: GoogleAuthOptions | GCEImagesConfig 102 | ): config is GoogleAuthOptions { 103 | return !config.authClient; 104 | } 105 | 106 | export class GCEImages { 107 | private _auth: GoogleAuth; 108 | private apiEndpoint: string; 109 | OS_URLS: OSUrls; 110 | OS_TO_URL: {[index: string]: string}; 111 | constructor(config: GCEImagesConfig | AuthOptions = {}) { 112 | this.apiEndpoint = config.apiEndpoint || 'compute.googleapis.com'; 113 | config.scopes = ['https://www.googleapis.com/auth/compute']; 114 | this._auth = isGoogleAuthOptions(config) 115 | ? new GoogleAuth(config) 116 | : config.authClient!; 117 | const projectsPath = `https://${this.apiEndpoint}/compute/v1/projects`; 118 | this.OS_URLS = { 119 | centos: `${projectsPath}/centos-cloud/global/images`, 120 | 'container-vm': `${projectsPath}/cos-cloud/global/images`, 121 | coreos: `${projectsPath}/coreos-cloud/global/images`, 122 | debian: `${projectsPath}/debian-cloud/global/images`, 123 | redhat: `${projectsPath}/rhel-cloud/global/images`, 124 | opensuse: `${projectsPath}/opensuse-cloud/global/images`, 125 | suse: `${projectsPath}/suse-cloud/global/images`, 126 | ubuntu: `${projectsPath}/ubuntu-os-cloud/global/images`, 127 | windows: `${projectsPath}/windows-cloud/global/images`, 128 | }; 129 | this.OS_TO_URL = { 130 | centos: this.OS_URLS.centos, 131 | 'centos-cloud': this.OS_URLS.centos, 132 | 'container-vm': this.OS_URLS['container-vm'], 133 | 'google-containers': this.OS_URLS['container-vm'], 134 | cos: this.OS_URLS['container-vm'], 135 | coreos: this.OS_URLS.coreos, 136 | 'coreos-cloud': this.OS_URLS.coreos, 137 | debian: this.OS_URLS.debian, 138 | 'debian-cloud': this.OS_URLS.debian, 139 | rhel: this.OS_URLS.redhat, 140 | 'rhel-cloud': this.OS_URLS.redhat, 141 | redhat: this.OS_URLS.redhat, 142 | opensuse: this.OS_URLS.opensuse, 143 | 'opensuse-cloud': this.OS_URLS.opensuse, 144 | suse: this.OS_URLS.suse, 145 | 'suse-cloud': this.OS_URLS.suse, 146 | ubuntu: this.OS_URLS.ubuntu, 147 | 'ubuntu-cloud': this.OS_URLS.ubuntu, 148 | 'ubuntu-os-cloud': this.OS_URLS.ubuntu, 149 | windows: this.OS_URLS.windows, 150 | 'windows-cloud': this.OS_URLS.windows, 151 | }; 152 | } 153 | 154 | async getProjectId() { 155 | return this._auth.getProjectId(); 156 | } 157 | 158 | /** 159 | * Get all available images. 160 | * 161 | * @param {string=|object=} options - If a string, treat as an OS to fetch images for. 162 | * @param {boolean} options.deprecated [false] - Include deprecated results. 163 | * @param {array} options.osNames [all] - OS names to include in the results. 164 | * @param {function} callback - Callback function. 165 | * @returns {Promise} if callback is omitted. 166 | */ 167 | getAll(cb: GetAllCallback): void; 168 | getAll(opts?: GetOptions | string): Promise; 169 | getAll(opts: GetOptions | string, cb: GetAllCallback): void; 170 | getAll( 171 | optsOrCb?: GetOptions | string | GetAllCallback, 172 | cb?: GetAllCallback 173 | ): Promise | void { 174 | const {options, callback} = this._parseArguments< 175 | GetOptions, 176 | GetAllCallback 177 | >(optsOrCb, cb); 178 | if (callback) { 179 | this.getAllAsync(options).then( 180 | r => callback(null, r as Image[]), 181 | callback 182 | ); 183 | } else { 184 | return this.getAllAsync(options); 185 | } 186 | } 187 | 188 | private async getAllAsync(opts: GetOptions): Promise { 189 | const osNamesToImages = new Map(); 190 | await Promise.all( 191 | opts.osNames!.map(async name => { 192 | const singleOsOptions = Object.assign({}, opts, {osNames: [name]}); 193 | osNamesToImages.set( 194 | name, 195 | (await this._getAllByOS(singleOsOptions)) || [] 196 | ); 197 | }) 198 | ); 199 | const result = 200 | opts.osNames!.length === 1 201 | ? (osNamesToImages.get(opts.osNames![0]) as Image[]) 202 | : Array.from(osNamesToImages).reduce((obj: ImagesMap, [key, value]) => { 203 | obj[key] = value; 204 | return obj; 205 | }, {} as ImagesMap); 206 | return result as Image[]; 207 | } 208 | 209 | /** 210 | * Get all available images, but only return the newest one. 211 | * 212 | * @param {string=|object=} options - If a string, treat as an OS to fetch 213 | * images for. 214 | * @param {boolean} options.deprecated [false] - Include deprecated results. 215 | * @param {array} options.osNames [all] - OS names to include in the results. 216 | * @param {function} callback - Callback function. 217 | * @returns {Promise} if callback is omitted. 218 | */ 219 | getLatest(cb: GetLatestCallback): void; 220 | getLatest(opts?: GetOptions | string): Promise; 221 | getLatest(opts: GetOptions | string, cb: GetLatestCallback): void; 222 | getLatest( 223 | optsOrCb?: GetOptions | string | GetLatestCallback, 224 | cb?: GetLatestCallback 225 | ): Promise | void { 226 | const {options, callback} = this._parseArguments< 227 | GetOptions, 228 | GetLatestCallback 229 | >(optsOrCb, cb); 230 | if (callback) { 231 | this.getLatestAsync(options).then(r => callback(null, r), callback); 232 | } else { 233 | return this.getLatestAsync(options); 234 | } 235 | } 236 | 237 | private async getLatestAsync(opts: GetOptions): Promise { 238 | const images = await this.getAllAsync(opts); 239 | let image: Image | ImageMap | undefined; 240 | if (Array.isArray(images)) { 241 | [image] = images.sort(this._sortNewestFirst); 242 | } else { 243 | image = {} as ImageMap; 244 | for (const name in images) { 245 | if (images[name]) { 246 | image[name] = images[name].sort(this._sortNewestFirst)[0]; 247 | } 248 | } 249 | } 250 | return image; 251 | } 252 | 253 | async _getAllByOS( 254 | options: GetOptions & {osNames: string[]} 255 | ): Promise { 256 | const osParts = this._parseOsInput(options.osNames![0]); 257 | const reqOpts = { 258 | url: osParts.url, 259 | params: {} as { 260 | [index: string]: string; 261 | }, 262 | }; 263 | if (osParts.version.length > 0) { 264 | reqOpts.params.filter = 265 | 'name eq ' + [osParts.name, osParts.version].join('-') + '.*'; 266 | } 267 | const resp = await this._auth.request(reqOpts); 268 | let images = resp.data.items || []; 269 | if (!options.deprecated) { 270 | images = images.filter(this._filterDeprecated); 271 | } 272 | 273 | // All CoreOS images are now deprecated, See: 274 | // https://cloud.google.com/compute/docs/eol/coreOS 275 | if (images.length === 0 && !osParts.name.startsWith('coreos')) { 276 | throw new Error('Could not find a suitable image.'); 277 | } 278 | return images; 279 | } 280 | 281 | // tslint:disable-next-line no-any 282 | _parseArguments(options: any, callback: any): ParsedArguments { 283 | const defaultOptions = { 284 | deprecated: false, 285 | osNames: Object.keys(this.OS_URLS), 286 | }; 287 | 288 | const parsedArguments = { 289 | options, 290 | callback, 291 | }; 292 | 293 | if (typeof options === 'string') { 294 | parsedArguments.options = { 295 | osNames: [options], 296 | }; 297 | } 298 | 299 | if (typeof options === 'function') { 300 | parsedArguments.callback = options; 301 | } 302 | 303 | parsedArguments.options = Object.assign( 304 | defaultOptions, 305 | parsedArguments.options 306 | ); 307 | parsedArguments.options.osNames = arrify(parsedArguments.options.osNames); 308 | 309 | return parsedArguments; 310 | } 311 | 312 | _parseOsInput(os: string) { 313 | const osParts = { 314 | name: '', 315 | version: '', 316 | url: '', 317 | }; 318 | 319 | let project: string; 320 | let hasProject = false; 321 | 322 | if (this.OS_TO_URL[os]) { 323 | osParts.name = os; 324 | } else { 325 | hasProject = /\//.test(os); 326 | if (hasProject) { 327 | const projectAndOs = os.split('/'); 328 | project = projectAndOs[0]; 329 | os = projectAndOs[1]; 330 | } 331 | os.split('-').forEach(part => { 332 | const hasName = osParts.name.length > 0; 333 | const hasVersion = osParts.version.length > 0; 334 | 335 | // Basically, if one of the parts of this name isn't 'cloud' or 'os', 336 | // consider it part of the version. 337 | switch (part) { 338 | case 'cloud': 339 | case 'os': 340 | if (!hasVersion) { 341 | osParts.name += !hasName ? part : '-' + part; 342 | break; 343 | } 344 | /* falls through */ 345 | default: 346 | if (!hasName) { 347 | osParts.name = part; 348 | } else { 349 | osParts.version += !hasVersion ? part : '-' + part; 350 | } 351 | break; 352 | } 353 | }); 354 | } 355 | 356 | if (hasProject) { 357 | osParts.url = `https://compute.googleapis.com/compute/v1/projects/${project!}/global/images`; 358 | } else { 359 | osParts.url = this.OS_TO_URL[osParts.name]; 360 | } 361 | 362 | if (!osParts.url) { 363 | throw new Error( 364 | [ 365 | 'Cannot find ' + os, 366 | 'Expected one of: ' + Object.keys(this.OS_URLS).join(', '), 367 | ].join('. ') 368 | ); 369 | } 370 | 371 | return osParts; 372 | } 373 | 374 | _filterDeprecated(image: Image) { 375 | return !image.deprecated; 376 | } 377 | 378 | _sortNewestFirst(imageA: Image, imageB: Image) { 379 | return imageA.creationTimestamp < imageB.creationTimestamp 380 | ? 1 381 | : imageA.creationTimestamp > imageB.creationTimestamp 382 | ? -1 383 | : 0; 384 | } 385 | } 386 | -------------------------------------------------------------------------------- /test/test.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | import {describe, it} from 'mocha'; 16 | import * as assert from 'assert'; 17 | import {GCEImages, Image} from '../src'; 18 | 19 | const gceImages = new GCEImages(); 20 | 21 | describe('gce-images', () => { 22 | it('should use the configured apiEndpoint', () => { 23 | const apiEndpoint = 'fake.local'; 24 | const images = new GCEImages({apiEndpoint}); 25 | const expectedPath = `https://${apiEndpoint}/compute/v1/projects/centos-cloud/global/images`; 26 | assert.strictEqual(images.OS_URLS.centos, expectedPath); 27 | }); 28 | 29 | describe('_sortNewestFirst', () => { 30 | describe('when imageA.creationTimestamp is newer than imageB.creationTimestamp', () => { 31 | it('should return -1', () => { 32 | const imageA = { 33 | creationTimestamp: '2016-10-22T13:06:19.143-08:00', 34 | } as Image; 35 | const imageB = { 36 | creationTimestamp: '2016-09-25T07:31:52.339-07:00', 37 | } as Image; 38 | assert.strictEqual(gceImages._sortNewestFirst(imageA, imageB), -1); 39 | }); 40 | }); 41 | 42 | describe('when imageA.creationTimestamp is older than imageB.creationTimestamp', () => { 43 | it('should return 1', () => { 44 | const imageA = { 45 | creationTimestamp: '2016-10-22T13:06:19.143-08:00', 46 | } as Image; 47 | const imageB = { 48 | creationTimestamp: '2016-11-17T14:37:55.828-08:00', 49 | } as Image; 50 | assert.strictEqual(gceImages._sortNewestFirst(imageA, imageB), 1); 51 | }); 52 | }); 53 | 54 | describe('when imageA.creationTimestamp is equal to imageB.creationTimestamp', () => { 55 | it('should return 0', () => { 56 | const imageA = { 57 | creationTimestamp: '2016-08-25T07:14:24.426-07:00', 58 | } as Image; 59 | const imageB = { 60 | creationTimestamp: '2016-08-25T07:14:24.426-07:00', 61 | } as Image; 62 | assert.strictEqual(gceImages._sortNewestFirst(imageA, imageB), 0); 63 | }); 64 | }); 65 | }); 66 | }); 67 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts/tsconfig-google.json", 3 | "compilerOptions": { 4 | "lib": ["es2018", "dom"], 5 | "rootDir": ".", 6 | "outDir": "build", 7 | "noFallthroughCasesInSwitch": false 8 | }, 9 | "include": [ 10 | "src/*.ts", 11 | "test/*.ts", 12 | "system-test/*.ts" 13 | ] 14 | } 15 | --------------------------------------------------------------------------------