Skip to content

Commit

Permalink
updates proto to match crossplane
Browse files Browse the repository at this point in the history
  • Loading branch information
dalton-hill-0 committed Apr 2, 2024
1 parent 454fb81 commit 154df9c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 68 deletions.
102 changes: 52 additions & 50 deletions proto/v1beta1/run_function.pb.go

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

28 changes: 18 additions & 10 deletions proto/v1beta1/run_function.proto
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,16 @@ message Result {
// Human-readable details about the result.
string message = 2;

// Determines who should receive any Events or Status Conditions that are
// generated as part of this result
// The resources this result targets.
Target target = 3;

// Optionally update the supplied status condition on all targets.
// The result's reason and message will be used in the condition.
optional Condition condition = 4;
// Optional PascalCase, machine-readable reason for this result.
optional string reason = 4;

// A result can optionally indicate the condition of the target resources.
// Crossplane will consider the resources to be in the supplied condition
// until another result changes it.
optional Condition condition = 5;
}

// Severity of Function results.
Expand All @@ -252,8 +255,15 @@ enum Severity {

// Target of Function results.
enum Target {
// If the target is unspecified, the result targets the composite resource.
TARGET_UNSPECIFIED = 0;

// Target the composite resource. Results that target the composite resource
// should include detailed, advanced information.
TARGET_COMPOSITE = 1;

// Target the composite and the claim. Results that target the composite and
// the claim should include only end-user friendly information.
TARGET_COMPOSITE_AND_CLAIM = 2;
}

Expand All @@ -262,17 +272,15 @@ enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_FALSE = 1;
STATUS_TRUE = 2;
STATUS_UNKNOWN = 3;
}

// A Condition
message Condition {
// Type of the condition, e.g. DatabaseReady.
// 'Ready' and 'Synced' are reserved for use by Crossplane.
// Ready and Synced are reserved for use by Crossplane.
string type = 1;

// Status of the condition.
Status status = 2;

// Machine-readable PascalCase reason.
string reason = 3;
}

8 changes: 4 additions & 4 deletions response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,32 +178,32 @@ func (o *Result) TargetCompositeAndClaim() *Result {
// ConditionTrue configures the result to create a condition on the targeted
// objects with the status set to true.
func (o *Result) ConditionTrue(t string, r string) *Result {
o.result.Reason = &r
o.result.Condition = &v1beta1.Condition{
Type: t,
Status: v1beta1.Status_STATUS_TRUE,
Reason: r,
}
return o
}

// ConditionFalse configures the result to create a condition on the targeted
// objects with the status set to false.
func (o *Result) ConditionFalse(t string, r string) *Result {
o.result.Reason = &r
o.result.Condition = &v1beta1.Condition{
Type: t,
Status: v1beta1.Status_STATUS_FALSE,
Reason: r,
}
return o
}

// ConditionUnknown configures the result to create a condition on the targeted
// objects with the status set to unknown.
func (o *Result) ConditionUnknown(t string, r string) *Result {
o.result.Reason = &r
o.result.Condition = &v1beta1.Condition{
Type: t,
Status: v1beta1.Status_STATUS_UNKNOWN,
Reason: r,
Status: v1beta1.Status_STATUS_UNSPECIFIED,
}
return o
}
11 changes: 7 additions & 4 deletions response/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
)

func TestResult(t *testing.T) {
reasonAvailable := "Available"
reasonStale := "Stale"
reasonUnauthorized := "Unauthorized"
type testFn func(*v1beta1.RunFunctionResponse)
type args struct {
fns []testFn
Expand Down Expand Up @@ -123,30 +126,30 @@ func TestResult(t *testing.T) {
Severity: v1beta1.Severity_SEVERITY_NORMAL,
Message: "some-message",
Target: v1beta1.Target_TARGET_COMPOSITE,
Reason: &reasonAvailable,
Condition: &v1beta1.Condition{
Type: "DatabaseReady",
Status: v1beta1.Status_STATUS_TRUE,
Reason: "Available",
},
},
{
Severity: v1beta1.Severity_SEVERITY_WARNING,
Message: "some-error",
Target: v1beta1.Target_TARGET_COMPOSITE,
Reason: &reasonStale,
Condition: &v1beta1.Condition{
Type: "DatabaseReady",
Status: v1beta1.Status_STATUS_UNKNOWN,
Reason: "Stale",
Status: v1beta1.Status_STATUS_UNSPECIFIED,
},
},
{
Severity: v1beta1.Severity_SEVERITY_FATAL,
Message: "some-error",
Target: v1beta1.Target_TARGET_COMPOSITE,
Reason: &reasonUnauthorized,
Condition: &v1beta1.Condition{
Type: "DatabaseReady",
Status: v1beta1.Status_STATUS_FALSE,
Reason: "Unauthorized",
},
},
},
Expand Down

0 comments on commit 154df9c

Please sign in to comment.