Skip to content

Commit

Permalink
Updates, latest conflicts and formatting
Browse files Browse the repository at this point in the history
Clean ups
Adding tests for reconciler

Signed-off-by: Matthias Wessendorf <[email protected]>
  • Loading branch information
matzew committed Nov 21, 2024
1 parent 22be4dd commit b6fd865
Show file tree
Hide file tree
Showing 24 changed files with 485 additions and 236 deletions.
6 changes: 3 additions & 3 deletions docs/eventing-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6354,7 +6354,7 @@ JobSinkStatus
<td>
<code>s3</code><br/>
<em>
knative.dev/eventing/pkg/apis/common.AWSS3
knative.dev/eventing/pkg/apis/common/integration/v1alpha1.AWSS3
</em>
</td>
<td>
Expand All @@ -6364,7 +6364,7 @@ knative.dev/eventing/pkg/apis/common.AWSS3
<td>
<code>sqs</code><br/>
<em>
knative.dev/eventing/pkg/apis/common.AWSSQS
knative.dev/eventing/pkg/apis/common/integration/v1alpha1.AWSSQS
</em>
</td>
<td>
Expand All @@ -6375,7 +6375,7 @@ knative.dev/eventing/pkg/apis/common.AWSSQS
<td>
<code>auth</code><br/>
<em>
knative.dev/eventing/pkg/apis/common.Auth
knative.dev/eventing/pkg/apis/common/integration/v1alpha1.Auth
</em>
</td>
<td>
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/sinks/v1alpha1/integration_sink_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package v1alpha1

import (
"context"
"github.com/google/go-cmp/cmp"
"testing"

"github.com/google/go-cmp/cmp"
)

func TestIntegrationSinkSetDefaults(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/sinks/v1alpha1/integration_sink_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (s *IntegrationSinkStatus) MarkEventPoliciesTrueWithReason(reason, messageF
IntegrationSinkCondSet.Manage(s).MarkTrueWithReason(IntegrationSinkConditionEventPoliciesReady, reason, messageFormat, messageA...)
}

func (s *IntegrationSinkStatus) PropagateDeploymentAvailability(d *appsv1.DeploymentStatus) {
func (s *IntegrationSinkStatus) PropagateDeploymentStatus(d *appsv1.DeploymentStatus) {
deploymentAvailableFound := false
for _, cond := range d.Conditions {
if cond.Type == appsv1.DeploymentAvailable {
Expand Down
12 changes: 11 additions & 1 deletion pkg/apis/sinks/v1alpha1/integration_sink_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ limitations under the License.
package v1alpha1

import (
"testing"

"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
"testing"
)

func TestIntegrationSinkGetConditionSet(t *testing.T) {
Expand All @@ -45,6 +46,9 @@ func TestIntegrationSinkInitializeConditions(t *testing.T) {
Conditions: []apis.Condition{{
Type: IntegrationSinkConditionAddressable,
Status: corev1.ConditionUnknown,
}, {
Type: IntegrationSinkConditionDeploymentReady,
Status: corev1.ConditionUnknown,
}, {
Type: IntegrationSinkConditionEventPoliciesReady,
Status: corev1.ConditionUnknown,
Expand All @@ -69,6 +73,9 @@ func TestIntegrationSinkInitializeConditions(t *testing.T) {
Conditions: []apis.Condition{{
Type: IntegrationSinkConditionAddressable,
Status: corev1.ConditionFalse,
}, {
Type: IntegrationSinkConditionDeploymentReady,
Status: corev1.ConditionUnknown,
}, {
Type: IntegrationSinkConditionEventPoliciesReady,
Status: corev1.ConditionUnknown,
Expand All @@ -93,6 +100,9 @@ func TestIntegrationSinkInitializeConditions(t *testing.T) {
Conditions: []apis.Condition{{
Type: IntegrationSinkConditionAddressable,
Status: corev1.ConditionTrue,
}, {
Type: IntegrationSinkConditionDeploymentReady,
Status: corev1.ConditionUnknown,
}, {
Type: IntegrationSinkConditionEventPoliciesReady,
Status: corev1.ConditionUnknown,
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/sinks/v1alpha1/integration_sink_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/eventing/pkg/apis/common"
"knative.dev/eventing/pkg/apis/common/integration/v1alpha1"
eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
Expand Down Expand Up @@ -74,9 +74,9 @@ type Log struct {
}

type Aws struct {
S3 *common.AWSS3 `json:"s3,omitempty"` // S3 source configuration
SQS *common.AWSSQS `json:"sqs,omitempty"` // SQS source configuration
Auth *common.Auth `json:"auth,omitempty"`
S3 *v1alpha1.AWSS3 `json:"s3,omitempty"` // S3 source configuration
SQS *v1alpha1.AWSSQS `json:"sqs,omitempty"` // SQS source configuration
Auth *v1alpha1.Auth `json:"auth,omitempty"`
}

type IntegrationSinkStatus struct {
Expand Down
25 changes: 13 additions & 12 deletions pkg/apis/sinks/v1alpha1/integration_sink_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package v1alpha1

import (
"knative.dev/eventing/pkg/apis/common"
"testing"

"knative.dev/eventing/pkg/apis/common/integration/v1alpha1"
)

func TestIntegrationSink_GetStatus(t *testing.T) {
Expand Down Expand Up @@ -54,30 +55,30 @@ func TestLog(t *testing.T) {
}

func TestAWS(t *testing.T) {
s3 := common.AWSS3{
AWSCommon: common.AWSCommon{
s3 := v1alpha1.AWSS3{
AWSCommon: v1alpha1.AWSCommon{
Region: "eu-north-1",
},
BucketNameOrArn: "example-bucket",
Arn: "example-bucket",
}

if s3.Region != "eu-north-1" {
t.Errorf("AWSS3.Region = %v, want 'eu-north-1'", s3.Region)
}

sqs := common.AWSSQS{
AWSCommon: common.AWSCommon{
sqs := v1alpha1.AWSSQS{
AWSCommon: v1alpha1.AWSCommon{
Region: "eu-north-1",
},
QueueNameOrArn: "example-queue",
Arn: "example-queue",
}

if sqs.Region != "eu-north-1" {
t.Errorf("AWSSQS.Region = %v, want 'eu-north-1'", sqs.Region)
}

ddbStreams := common.AWSDDBStreams{
AWSCommon: common.AWSCommon{
ddbStreams := v1alpha1.AWSDDBStreams{
AWSCommon: v1alpha1.AWSCommon{
Region: "eu-north-1",
},
Table: "example-table",
Expand All @@ -90,9 +91,9 @@ func TestAWS(t *testing.T) {

// TestAuthFieldAccess tests the HasAuth method and field access in Auth struct
func TestAuthFieldAccess(t *testing.T) {
auth := common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
auth := v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/sinks/v1alpha1/integration_sink_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
"context"

"knative.dev/pkg/apis"
)

Expand Down Expand Up @@ -61,7 +62,7 @@ func (spec *IntegrationSinkSpec) Validate(ctx context.Context) *apis.FieldError

// Additional validation for AWS S3 required fields
if spec.Aws.S3 != nil {
if spec.Aws.S3.BucketNameOrArn == "" {
if spec.Aws.S3.Arn == "" {
errs = errs.Also(apis.ErrMissingField("aws.s3.bucketNameOrArn"))
}
if spec.Aws.S3.Region == "" {
Expand All @@ -71,7 +72,7 @@ func (spec *IntegrationSinkSpec) Validate(ctx context.Context) *apis.FieldError

// Additional validation for AWS SQS required fields
if spec.Aws.SQS != nil {
if spec.Aws.SQS.QueueNameOrArn == "" {
if spec.Aws.SQS.Arn == "" {
errs = errs.Also(apis.ErrMissingField("aws.sqs.queueNameOrArn"))
}
if spec.Aws.SQS.Region == "" {
Expand Down
77 changes: 39 additions & 38 deletions pkg/apis/sinks/v1alpha1/integration_sink_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package v1alpha1

import (
"context"
"knative.dev/eventing/pkg/apis/common"
"testing"

"knative.dev/eventing/pkg/apis/common/integration/v1alpha1"

"github.com/google/go-cmp/cmp"
"knative.dev/pkg/apis"
)
Expand All @@ -45,15 +46,15 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "valid AWS S3 sink with auth and region",
spec: IntegrationSinkSpec{
Aws: &Aws{
S3: &common.AWSS3{
AWSCommon: common.AWSCommon{
S3: &v1alpha1.AWSS3{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
BucketNameOrArn: "example-bucket",
Arn: "example-bucket",
},
Auth: &common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
Auth: &v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand All @@ -66,15 +67,15 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "valid AWS SQS sink with auth and region",
spec: IntegrationSinkSpec{
Aws: &Aws{
SQS: &common.AWSSQS{
AWSCommon: common.AWSCommon{
SQS: &v1alpha1.AWSSQS{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
QueueNameOrArn: "example-queue",
Arn: "example-queue",
},
Auth: &common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
Auth: &v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand All @@ -91,11 +92,11 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
ShowHeaders: true,
},
Aws: &Aws{
S3: &common.AWSS3{
AWSCommon: common.AWSCommon{
S3: &v1alpha1.AWSS3{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
BucketNameOrArn: "example-bucket",
Arn: "example-bucket",
},
},
},
Expand All @@ -105,21 +106,21 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "multiple AWS sinks set (invalid)",
spec: IntegrationSinkSpec{
Aws: &Aws{
S3: &common.AWSS3{
AWSCommon: common.AWSCommon{
S3: &v1alpha1.AWSS3{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
BucketNameOrArn: "example-bucket",
Arn: "example-bucket",
},
SQS: &common.AWSSQS{
AWSCommon: common.AWSCommon{
SQS: &v1alpha1.AWSSQS{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
QueueNameOrArn: "example-queue",
Arn: "example-queue",
},
Auth: &common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
Auth: &v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand All @@ -132,14 +133,14 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "AWS SQS sink without QueueNameOrArn (invalid)",
spec: IntegrationSinkSpec{
Aws: &Aws{
SQS: &common.AWSSQS{
AWSCommon: common.AWSCommon{
SQS: &v1alpha1.AWSSQS{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
},
Auth: &common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
Auth: &v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand All @@ -157,11 +158,11 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "AWS sink without auth (invalid)",
spec: IntegrationSinkSpec{
Aws: &Aws{
S3: &common.AWSS3{
AWSCommon: common.AWSCommon{
S3: &v1alpha1.AWSS3{
AWSCommon: v1alpha1.AWSCommon{
Region: "us-east-1",
},
BucketNameOrArn: "example-bucket",
Arn: "example-bucket",
},
},
},
Expand All @@ -171,12 +172,12 @@ func TestIntegrationSinkSpecValidation(t *testing.T) {
name: "AWS S3 sink without region (invalid)",
spec: IntegrationSinkSpec{
Aws: &Aws{
S3: &common.AWSS3{
BucketNameOrArn: "example-bucket",
S3: &v1alpha1.AWSS3{
Arn: "example-bucket",
},
Auth: &common.Auth{
Secret: &common.Secret{
Ref: &common.SecretReference{
Auth: &v1alpha1.Auth{
Secret: &v1alpha1.Secret{
Ref: &v1alpha1.SecretReference{
Name: "aws-secret",
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/sinks/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func ExternalService(namespace, service string) K8sServiceOption {
}

// NewK8sService creates a new Service for a Channel resource. It also sets the appropriate

// OwnerReferences on the resource so handleObject can discover the Channel resource that 'owns' it.
// As well as being garbage collected when the Channel is deleted.
func NewK8sService(imc *v1.InMemoryChannel, opts ...K8sServiceOption) (*corev1.Service, error) {
Expand Down
Loading

0 comments on commit b6fd865

Please sign in to comment.