Compare commits

...

4 Commits

Author SHA1 Message Date
Nic Cope fce75e1aed
Merge pull request #24 from negz/thetwosweetestwords
Accomodate providers with default deletion policies and provider configs
2021-06-14 11:16:31 -07:00
Nic Cope 085421f910
Merge pull request #25 from negz/action
Propagate handy GitHub Actions
2021-06-12 15:55:29 -07:00
Nic Cope 309f2468be Propagate handy GitHub Actions
Signed-off-by: Nic Cope <negz@rk0n.org>
2021-06-12 02:15:44 +00:00
Nic Cope aa8cbd1093 Accomodate providers with default deletion policies and provider configs
https://github.com/crossplane/crossplane-runtime/pull/255

The defaulting of these fields will be introduced in crossplane-runtime v0.14
per the above PR. We'd like to support a transition period during which a
provider may either specify the default or not. Unfortunately it's not easy to
use cmp to test for "must be unset or value X" so I've just ignored the field
for the time being.

Signed-off-by: Nic Cope <negz@rk0n.org>
2021-06-12 02:10:18 +00:00
5 changed files with 158 additions and 7 deletions

34
.github/workflows/backport.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Backport
on:
# NOTE(negz): This is a risky target, but we run this action only when and if
# a PR is closed, then filter down to specifically merged PRs. We also don't
# invoke any scripts, etc from within the repo. I believe the fact that we'll
# be able to review PRs before this runs makes this fairly safe.
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
pull_request_target:
types: [closed]
# See also commands.yml for the /backport triggered variant of this workflow.
jobs:
# NOTE(negz): I tested many backport GitHub actions before landing on this
# one. Many do not support merge commits, or do not support pull requests with
# more than one commit. This one does. It also handily links backport PRs with
# new PRs, and provides commentary and instructions when it can't backport.
# The main gotchas with this action are that it _only_ supports merge commits,
# and that PRs _must_ be labelled before they're merged to trigger a backport.
open-pr:
runs-on: ubuntu-18.04
if: github.event.pull_request.merged
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Open Backport PR
uses: zeebe-io/backport-action@v0.0.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_workspace: ${{ github.workspace }}
version: v0.0.4

92
.github/workflows/commands.yml vendored Normal file
View File

@ -0,0 +1,92 @@
name: Comment Commands
on: issue_comment
jobs:
points:
runs-on: ubuntu-18.04
if: startsWith(github.event.comment.body, '/points')
steps:
- name: Extract Command
id: command
uses: xt0rted/slash-command-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
command: points
reaction: "true"
reaction-type: "eyes"
allow-edits: "false"
permission-level: write
- name: Handle Command
uses: actions/github-script@v4
env:
POINTS: ${{ steps.command.outputs.command-arguments }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const points = process.env.POINTS
if (isNaN(parseInt(points))) {
console.log("Malformed command - expected '/points <int>'")
github.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: "confused"
})
return
}
const label = "points/" + points
// Delete our needs-points-label label.
try {
await github.issues.deleteLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['needs-points-label']
})
console.log("Deleted 'needs-points-label' label.")
}
catch(e) {
console.log("Label 'needs-points-label' probably didn't exist.")
}
// Add our points label.
github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
})
console.log("Added '" + label + "' label.")
# NOTE(negz): See also backport.yml, which is the variant that triggers on PR
# merge rather than on comment.
backport:
runs-on: ubuntu-18.04
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport')
steps:
- name: Extract Command
id: command
uses: xt0rted/slash-command-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
command: backport
reaction: "true"
reaction-type: "eyes"
allow-edits: "false"
permission-level: write
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Open Backport PR
uses: zeebe-io/backport-action@v0.0.4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_workspace: ${{ github.workspace }}
version: v0.0.4

21
.github/workflows/labels.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Labels
on:
workflow_dispatch: {}
schedule:
- cron: '0 0 * * *'
jobs:
create-labels:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create Default Labels
uses: crazy-max/ghaction-github-labeler@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/default-labels.yml
skip-delete: true

View File

@ -4,10 +4,10 @@ on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v0.1.0)"
description: 'Release version (e.g. v0.1.0)'
required: true
message:
description: "Tag message"
description: 'Tag message'
required: true
jobs:

View File

@ -368,10 +368,6 @@ func SubtestForManagedResourceCRD(crd *kextv1.CustomResourceDefinition) func(t *
{Raw: []byte(`"Delete"`)},
},
},
// TODO(negz): Ensure that 'name' defaults to 'default'
// once we expect providers to be built against
// crossplane-runtime v0.14+, which will includ3
// https://github.com/crossplane/crossplane-runtime/pull/255
"providerConfigRef": {
Type: "object",
Required: []string{"name"},
@ -419,6 +415,14 @@ func SubtestForManagedResourceCRD(crd *kextv1.CustomResourceDefinition) func(t *
// often are.
internal.IgnoreFieldsOfMapKey("spec", "Required"),
// TODO(negz): Verify that provider config and deletion
// policy defaulting is in place once providers have had
// enough time to update to runtime v0.14 (which is not
// yet released at the time of writing).
// https://github.com/crossplane/crossplane-runtime/pull/255
internal.IgnoreFieldsOfMapKey("providerConfigRef", "Default"),
internal.IgnoreFieldsOfMapKey("deletionPolicy", "Default"),
// We're only concerned with the spec and status fields that we expect
// all managed resources to include.
internal.OnlySubproperties("spec", "deletionPolicy", "providerConfigRef", "writeConnectionSecretToRef"),