Skip to content

Commit

Permalink
Merge pull request #4 from turkenh/readme-installation
Browse files Browse the repository at this point in the history
Add marketplace link to the readme
  • Loading branch information
turkenh authored Feb 27, 2024
2 parents 39145b7 + 672676d commit 98696eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 43 deletions.
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,4 @@ See `example/composition.yaml` for a complete example.

## Installation

Currently it could be installed as follows:

```
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-sequencer
spec:
package: xpkg.upbound.io/hasan/function-sequencer:v0.0.3
```


It can be installed as follows from the Upbound marketplace: https://marketplace.upbound.io/functions/crossplane-contrib/function-sequencer
4 changes: 2 additions & 2 deletions fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package main
import (
"context"
"fmt"
"github.com/crossplane/function-sdk-go/resource"

"github.com/crossplane/crossplane-runtime/pkg/errors"
"github.com/crossplane/crossplane-runtime/pkg/logging"
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/function-sequencer/input/v1beta1"
)
Expand All @@ -21,7 +21,7 @@ type Function struct {
}

// RunFunction runs the Function.
func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequest) (*fnv1beta1.RunFunctionResponse, error) {
func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequest) (*fnv1beta1.RunFunctionResponse, error) { //nolint:gocyclo // This function is unavoidably complex.
f.log.Info("Running function", "tag", req.GetMeta().GetTag())

rsp := response.To(req, response.DefaultTTL)
Expand Down
28 changes: 1 addition & 27 deletions fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/durationpb"

"github.com/crossplane/crossplane-runtime/pkg/logging"
fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1"
"github.com/crossplane/function-sdk-go/resource"
"github.com/crossplane/function-sdk-go/response"
)

func TestRunFunction(t *testing.T) {
Expand All @@ -31,30 +28,7 @@ func TestRunFunction(t *testing.T) {
args args
want want
}{
"ResponseIsReturned": {
reason: "The Function should return a fatal result if no input was specified",
args: args{
req: &fnv1beta1.RunFunctionRequest{
Meta: &fnv1beta1.RequestMeta{Tag: "hello"},
Input: resource.MustStructJSON(`{
"apiVersion": "template.fn.crossplane.io/v1beta1",
"kind": "Input",
"example": "Hello, world"
}`),
},
},
want: want{
rsp: &fnv1beta1.RunFunctionResponse{
Meta: &fnv1beta1.ResponseMeta{Tag: "hello", Ttl: durationpb.New(response.DefaultTTL)},
Results: []*fnv1beta1.Result{
{
Severity: fnv1beta1.Severity_SEVERITY_NORMAL,
Message: "I was run with input \"Hello, world\"!",
},
},
},
},
},
// TODO: Add test cases.
}

for name, tc := range cases {
Expand Down
7 changes: 5 additions & 2 deletions input/v1beta1/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
package v1beta1

import (
"github.com/crossplane/function-sdk-go/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/crossplane/function-sdk-go/resource"
)

// This isn't a custom resource, in the sense that we never install its CRD.
// It is a KRM-like object, so we generate a CRD to describe its schema.

// SequencingRule is a rule that describes a sequence of resources.
type SequencingRule struct {
// TODO: InferFromUsages
// TODO: Should we add a way to infer sequencing from usages? e.g. InferFromUsages: true
// InferFromUsages bool `json:"inferFromUsages,omitempty"`
Sequence []resource.Name `json:"sequence,omitempty"`
}
Expand All @@ -26,5 +28,6 @@ type Input struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Rules is a list of rules that describe sequences of resources.
Rules []SequencingRule `json:"rules"`
}

0 comments on commit 98696eb

Please sign in to comment.