-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate code from googleapis/nodejs-org-policy #2806
Merged
Merged
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f906ff8
feat!: initial stub of library
sofisl f333d53
feat: add tests and samples to library
sofisl 7540483
chore: release 1.0.0
release-please[bot] 1c04140
chore: release 1.0.1 (#23)
release-please[bot] 88029da
chore: release 1.0.2 (#31)
release-please[bot] c3eec17
chore: release 1.0.3 (#38)
release-please[bot] e80f285
chore: release 1.0.4 (#43)
release-please[bot] 3f405f8
chore: release 1.0.5 (#45)
release-please[bot] 61bf1e8
chore: release 1.0.6 (#47)
release-please[bot] cc1c488
chore: release 1.0.7 (#55)
release-please[bot] adaa370
chore: release 1.1.0 (#57)
release-please[bot] 90301a4
fix(build): switch primary branch to main (#60)
bcoe eb68f35
chore: release 1.1.1 (#61)
release-please[bot] 193ef3d
chore(main): release 1.1.2 (#91)
release-please[bot] 2229978
build!: update library to use Node 12 (#108)
sofisl 5c9aaa8
chore(main): release 2.0.0 (#110)
release-please[bot] ab62c9c
chore(main): release 2.0.1 (#116)
release-please[bot] ecf5cd2
chore(main): release 2.0.2 (#123)
release-please[bot] 7ad8630
Merge remote-tracking branch 'migration/main' into nodejs-org-policy-…
kweinmeister 8d4ba48
add workflow, update README and CODEOWNERS
kweinmeister c644abb
update workflow
kweinmeister 10918b5
update README typo
kweinmeister ecc1e38
update path to orgpolicy
kweinmeister d47dc20
changed filename to orgpolicy
kweinmeister 45d9293
Merge branch 'main' into nodejs-org-policy-migration
kweinmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: orgpolicy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "orgpolicy/**" | ||
pull_request: | ||
paths: | ||
- "orgpolicy/**" | ||
pull_request_target: | ||
types: [labeled] | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
jobs: | ||
test: | ||
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
permissions: | ||
contents: "write" | ||
pull-requests: "write" | ||
id-token: "write" | ||
steps: | ||
- uses: actions/checkout@v3.1.0 | ||
with: | ||
ref: ${{github.event.pull_request.head.ref}} | ||
repository: ${{github.event.pull_request.head.repo.full_name}} | ||
- uses: "google-github-actions/auth@v0.8.3" | ||
with: | ||
workload_identity_provider: "projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider" | ||
service_account: "kokoro-system-test@long-door-651.iam.gserviceaccount.com" | ||
create_credentials_file: "true" | ||
access_token_lifetime: 600s | ||
- uses: actions/setup-node@v3.5.1 | ||
with: | ||
node-version: 16 | ||
- run: npm install | ||
working-directory: orgpolicy | ||
- run: npm test | ||
working-directory: orgpolicy | ||
env: | ||
MOCHA_REPORTER_SUITENAME: org_policy | ||
MOCHA_REPORTER_OUTPUT: org_policy_sponge_log.xml | ||
MOCHA_REPORTER: xunit | ||
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
try { | ||
await github.rest.issues.removeLabel({ | ||
name: 'actions:force-run', | ||
owner: 'GoogleCloudPlatform', | ||
repo: 'nodejs-docs-samples', | ||
issue_number: context.payload.pull_request.number | ||
}); | ||
} catch (e) { | ||
if (!e.message.includes('Label does not exist')) { | ||
throw e; | ||
} | ||
} | ||
- if: ${{ github.event_name == 'schedule'}} | ||
run: | | ||
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L | ||
chmod +x ./flakybot | ||
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> | ||
|
||
# [Organization Policy: Node.js Samples](https://github.com/GoogleCloudPlatform/nodejs-docs-samples) | ||
|
||
[![Open in Cloud Shell][shell_img]][shell_link] | ||
|
||
|
||
|
||
## Table of Contents | ||
|
||
- [Organization Policy: Node.js Samples](#organization-policy-nodejs-samples) | ||
- [Table of Contents](#table-of-contents) | ||
- [Before you begin](#before-you-begin) | ||
- [Samples](#samples) | ||
- [Quickstart](#quickstart) | ||
|
||
## Before you begin | ||
|
||
Before running the samples, make sure you've followed the steps outlined in | ||
[Using the client library](https://github.com/googleapis/nodejs-org-policy#using-the-client-library). | ||
|
||
`npm install` | ||
|
||
`cd ..` | ||
|
||
## Samples | ||
|
||
|
||
|
||
### Quickstart | ||
|
||
View the [source code](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/main/orgpolicy/quickstart.js). | ||
|
||
[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/nodejs-docs-samples&page=editor&open_in_editor=orgpolicy/quickstart.js,orgpolicy/README.md) | ||
|
||
__Usage:__ | ||
|
||
|
||
`node quickstart.js` | ||
|
||
|
||
|
||
|
||
|
||
|
||
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png | ||
[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/nodejs-docs-samples&page=editor&open_in_editor=orgpolicy/README.md | ||
[product-docs]: https://cloud.google.com/resource-manager/docs/organization-policy/overview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "nodejs-org-policy", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"author": "Google LLC", | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"files": [ | ||
"*.js" | ||
], | ||
"scripts": { | ||
"test": "c8 mocha --timeout 600000 test/*.js" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/org-policy": "^2.0.2" | ||
}, | ||
"devDependencies": { | ||
"c8": "^7.1.0", | ||
"chai": "^4.2.0", | ||
"mocha": "^8.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
'use strict'; | ||
|
||
async function main(projectId) { | ||
// [START nodejs_org_policy_quickstart] | ||
// Imports the Google Cloud client library | ||
|
||
// remove this line after package is released | ||
// eslint-disable-next-line node/no-missing-require | ||
const {OrgPolicyClient} = require('@google-cloud/org-policy'); | ||
|
||
// TODO(developer): replace with your prefered project ID. | ||
// const projectId = 'my-project' | ||
|
||
// Creates a client | ||
// eslint-disable-next-line no-unused-vars | ||
const client = new OrgPolicyClient(); | ||
|
||
//TODO(library generator): write the actual function you will be testing | ||
async function listConstraints() { | ||
const constraints = await client.listConstraints({ | ||
parent: `projects/${projectId}`, | ||
}); | ||
console.info(constraints); | ||
} | ||
listConstraints(); | ||
// [END nodejs_org_policy_quickstart] | ||
} | ||
|
||
main(...process.argv.slice(2)).catch(err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// ** This file is automatically generated by gapic-generator-typescript. ** | ||
// ** https://github.com/googleapis/gapic-generator-typescript ** | ||
// ** All changes to this file may be overwritten. ** | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const cp = require('child_process'); | ||
const {before, describe, it} = require('mocha'); | ||
const {OrgPolicyClient} = require('@google-cloud/org-policy'); | ||
const {assert} = require('chai'); | ||
|
||
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); | ||
|
||
const cwd = path.join(__dirname, '..'); | ||
|
||
const client = new OrgPolicyClient(); | ||
|
||
describe('Quickstart', () => { | ||
let projectId; | ||
|
||
before(async () => { | ||
projectId = await client.getProjectId(); | ||
}); | ||
|
||
it('should run quickstart', async () => { | ||
const stdout = execSync(`node ./quickstart.js ${projectId}`, {cwd}); | ||
assert.match(stdout, /\[[\s\S]*\]/); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-blocking: should we standardize the use of hyphen or no hyphen in org-policy?