Skip to content

Commit

Permalink
Merge pull request #6 from phisco/before-release
Browse files Browse the repository at this point in the history
chore: pre-release touch-ups
  • Loading branch information
phisco authored Mar 25, 2024
2 parents 3714d8c + 7a4ef28 commit 2113eec
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:

# The package to push, without a version tag. The default matches GitHub. For
# example xpkg.upbound.io/crossplane/function-template-go.
XPKG: xpkg.upbound.io/${{ github.repository}}
XPKG: xpkg.upbound.io/crossplane-contrib/function-extra-resources

# The package version to push. The default is 0.0.0-gitsha.
XPKG_VERSION: ${{ inputs.version }}
Expand Down
3 changes: 2 additions & 1 deletion fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/errors"
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
"github.com/crossplane/crossplane-runtime/pkg/logging"
"github.com/crossplane/function-extra-resources/input/v1beta1"
fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1"
"github.com/crossplane/function-sdk-go/request"
"github.com/crossplane/function-sdk-go/resource"
"github.com/crossplane/function-sdk-go/response"

"github.com/crossplane-contrib/function-extra-resources/input/v1beta1"
)

// Key to retrieve extras at.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/crossplane/function-extra-resources
module github.com/crossplane-contrib/function-extra-resources

go 1.21

Expand Down
18 changes: 14 additions & 4 deletions input/v1beta1/resource_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ type InputSpec struct {
// `spec.extraResourceRefs` and is only updated if it is null.
ExtraResources []ResourceSource `json:"extraResources"`

// Policy represents the Resolve and Resolution policies which apply to
// all ResourceSourceReferences in ExtraResources list.
// Policy represents the Resolution policies which apply to all
// ResourceSourceReferences in ExtraResources list.
// +optional
Policy *xpv1.Policy `json:"policy,omitempty"`
Policy *Policy `json:"policy,omitempty"`
}

// Policy represents the Resolve and Resolution policies of Reference instance.
// Policy represents the Resolution policy of Reference instance.
type Policy struct {
// Resolution specifies whether resolution of this reference is required.
// The default is 'Required', which means the reconcile will fail if the
Expand All @@ -45,6 +45,16 @@ type Policy struct {
Resolution *xpv1.ResolutionPolicy `json:"resolution,omitempty"`
}

// IsResolutionPolicyOptional checks whether the resolution policy of relevant
// reference is Optional.
func (p *Policy) IsResolutionPolicyOptional() bool {
if p == nil || p.Resolution == nil {
return false
}

return *p.Resolution == xpv1.ResolutionPolicyOptional
}

// ResourceSourceType specifies the way the ExtraResource is selected.
type ResourceSourceType string

Expand Down
2 changes: 1 addition & 1 deletion input/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ func (c *CLI) Run() error {
}

func main() {
ctx := kong.Parse(&CLI{}, kong.Description("A Crossplane Composition Function."))
ctx := kong.Parse(&CLI{}, kong.Description("A Crossplane Composition Function to retrieve extra resources to the context."))
ctx.FatalIfErrorf(ctx.Run())
}
17 changes: 15 additions & 2 deletions package/crossplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,18 @@
apiVersion: meta.pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-template-go
spec: {}
name: function-extra-resources
annotations:
meta.crossplane.io/maintainer: Crossplane Maintainers <info@crossplane.io>
meta.crossplane.io/source: github.com/crossplane-contrib/function-extra-resources
meta.crossplane.io/license: Apache-2.0
meta.crossplane.io/description: |
A composition function that can retrieve arbitrary cluster-scoped extra resources and add them to the context.
meta.crossplane.io/readme: |
This composition function retrives arbitrary cluster-scoped extra
resources and add them in the specified order into the Context at a
well-known key, apiextensions.crossplane.io/extra-resources, so that they
can be used by other functions.
spec:
crossplane:
version: ">=v1.15.0"
14 changes: 2 additions & 12 deletions package/input/extra-resources.fn.crossplane.io_inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ spec:
type: array
policy:
description: |-
Policy represents the Resolve and Resolution policies which apply to
all ResourceSourceReferences in ExtraResources list.
Policy represents the Resolution policies which apply to all
ResourceSourceReferences in ExtraResources list.
properties:
resolution:
default: Required
Expand All @@ -164,16 +164,6 @@ spec:
- Required
- Optional
type: string
resolve:
description: |-
Resolve specifies when this reference should be resolved. The default
is 'IfNotPresent', which will attempt to resolve the reference only when
the corresponding field is not present. Use 'Always' to resolve the
reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- extraResources
Expand Down

0 comments on commit 2113eec

Please sign in to comment.