Skip to content

Commit

Permalink
Moving API to a versioned common/integration folder
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>
  • Loading branch information
matzew committed Nov 13, 2024
1 parent e1c6af6 commit 84c5911
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 831 deletions.
580 changes: 4 additions & 576 deletions docs/eventing-api.md

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions pkg/apis/common/integration/v1alpha1/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2024 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

type Auth struct {
// Auth Secret
Secret *Secret `json:"secret,omitempty"`

// AccessKey is the AWS access key ID.
AccessKey string `json:"accessKey,omitempty"`

// SecretKey is the AWS secret access key.
SecretKey string `json:"secretKey,omitempty"`
}

func (a *Auth) HasAuth() bool {
return a != nil && a.Secret != nil &&
a.Secret.Ref != nil && a.Secret.Ref.Name != ""
}

type Secret struct {
// Secret reference for SASL and SSL configurations.
Ref *SecretReference `json:"ref,omitempty"`
}

type SecretReference struct {
// Secret name.
Name string `json:"name"`
}
64 changes: 64 additions & 0 deletions pkg/apis/common/integration/v1alpha1/aws.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2024 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

type AWSCommon struct {
// Auth is the S3 authentication (accessKey/secretKey) configuration.
Region string `json:"region,omitempty"` // AWS region
ProfileCredentialsName string `json:"profileCredentialsName,omitempty"` // Profile name for profile credentials provider
SessionToken string `json:"sessionToken,omitempty"` // Session token
URIEndpointOverride string `json:"uriEndpointOverride,omitempty"` // Override endpoint URI
OverrideEndpoint bool `json:"overrideEndpoint" default:"false"` // Override endpoint flag
}

type AWSS3 struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Arn string `json:"arn,omitempty" camel:"CAMEL_KAMELET_AWS_S3_SOURCE_BUCKETNAMEORARN"` // S3 ARN
DeleteAfterRead bool `json:"deleteAfterRead" default:"true"` // Auto-delete objects after reading
MoveAfterRead bool `json:"moveAfterRead" default:"false"` // Move objects after reading
DestinationBucket string `json:"destinationBucket,omitempty"` // Destination bucket for moved objects
DestinationBucketPrefix string `json:"destinationBucketPrefix,omitempty"` // Prefix for moved objects
DestinationBucketSuffix string `json:"destinationBucketSuffix,omitempty"` // Suffix for moved objects
AutoCreateBucket bool `json:"autoCreateBucket" default:"false"` // Auto-create S3 bucket
Prefix string `json:"prefix,omitempty"` // S3 bucket prefix for search
IgnoreBody bool `json:"ignoreBody" default:"false"` // Ignore object body
ForcePathStyle bool `json:"forcePathStyle" default:"false"` // Force path style for bucket access
Delay int `json:"delay" default:"500"` // Delay between polls in milliseconds
MaxMessagesPerPoll int `json:"maxMessagesPerPoll" default:"10"` // Max messages to poll per request
}

type AWSSQS struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Arn string `json:"arn,omitempty" camel:"CAMEL_KAMELET_AWS_SQS_SOURCE_QUEUENAMEORARN"` // SQS ARN
DeleteAfterRead bool `json:"deleteAfterRead" default:"true"` // Auto-delete messages after reading
AutoCreateQueue bool `json:"autoCreateQueue" default:"false"` // Auto-create SQS queue
Host string `json:"host" camel:"CAMEL_KAMELET_AWS_SQS_SOURCE_AMAZONAWSHOST" default:"amazonaws.com"` // AWS host
Protocol string `json:"protocol" default:"https"` // Communication protocol (http/https)
QueueURL string `json:"queueURL,omitempty"` // Full SQS queue URL
Greedy bool `json:"greedy" default:"false"` // Greedy scheduler
Delay int `json:"delay" default:"500"` // Delay between polls in milliseconds
MaxMessagesPerPoll int `json:"maxMessagesPerPoll" default:"1"` // Max messages to return (1-10)
WaitTimeSeconds int `json:"waitTimeSeconds,omitempty"` // Wait time for messages
VisibilityTimeout int `json:"visibilityTimeout,omitempty"` // Visibility timeout in seconds
}

type AWSDDBStreams struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Table string `json:"table,omitempty"` // The name of the DynamoDB table
StreamIteratorType string `json:"streamIteratorType,omitempty" default:"FROM_LATEST"` // Defines where in the DynamoDB stream to start getting records
Delay int `json:"delay,omitempty" default:"500"` // Delay in milliseconds before the next poll from the database
}
19 changes: 19 additions & 0 deletions pkg/apis/common/integration/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2024 The Knative Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package

package v1alpha1
147 changes: 147 additions & 0 deletions pkg/apis/common/integration/v1alpha1/zz_generated.deepcopy.go

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

82 changes: 5 additions & 77 deletions pkg/apis/sources/v1alpha1/integration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +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/integration/v1alpha1"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/kmeta"
Expand Down Expand Up @@ -68,84 +69,11 @@ type Timer struct {
RepeatCount int `json:"repeatCount,omitempty"` // Max number of fires (optional)
}

type AWSCommon struct {
// Auth is the S3 authentication (accessKey/secretKey) configuration.
Region string `json:"region,omitempty"` // AWS region
ProfileCredentialsName string `json:"profileCredentialsName,omitempty"` // Profile name for profile credentials provider
SessionToken string `json:"sessionToken,omitempty"` // Session token
URIEndpointOverride string `json:"uriEndpointOverride,omitempty"` // Override endpoint URI
OverrideEndpoint bool `json:"overrideEndpoint" default:"false"` // Override endpoint flag
}

type AWSS3 struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Arn string `json:"arn,omitempty" camel:"CAMEL_KAMELET_AWS_S3_SOURCE_BUCKETNAMEORARN"` // S3 ARN
DeleteAfterRead bool `json:"deleteAfterRead" default:"true"` // Auto-delete objects after reading
MoveAfterRead bool `json:"moveAfterRead" default:"false"` // Move objects after reading
DestinationBucket string `json:"destinationBucket,omitempty"` // Destination bucket for moved objects
DestinationBucketPrefix string `json:"destinationBucketPrefix,omitempty"` // Prefix for moved objects
DestinationBucketSuffix string `json:"destinationBucketSuffix,omitempty"` // Suffix for moved objects
AutoCreateBucket bool `json:"autoCreateBucket" default:"false"` // Auto-create S3 bucket
Prefix string `json:"prefix,omitempty"` // S3 bucket prefix for search
IgnoreBody bool `json:"ignoreBody" default:"false"` // Ignore object body
ForcePathStyle bool `json:"forcePathStyle" default:"false"` // Force path style for bucket access
Delay int `json:"delay" default:"500"` // Delay between polls in milliseconds
MaxMessagesPerPoll int `json:"maxMessagesPerPoll" default:"10"` // Max messages to poll per request
}

type AWSSQS struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Arn string `json:"arn,omitempty" camel:"CAMEL_KAMELET_AWS_SQS_SOURCE_QUEUENAMEORARN"` // SQS ARN
DeleteAfterRead bool `json:"deleteAfterRead" default:"true"` // Auto-delete messages after reading
AutoCreateQueue bool `json:"autoCreateQueue" default:"false"` // Auto-create SQS queue
Host string `json:"host" camel:"CAMEL_KAMELET_AWS_SQS_SOURCE_AMAZONAWSHOST" default:"amazonaws.com"` // AWS host
Protocol string `json:"protocol" default:"https"` // Communication protocol (http/https)
QueueURL string `json:"queueURL,omitempty"` // Full SQS queue URL
Greedy bool `json:"greedy" default:"false"` // Greedy scheduler
Delay int `json:"delay" default:"500"` // Delay between polls in milliseconds
MaxMessagesPerPoll int `json:"maxMessagesPerPoll" default:"1"` // Max messages to return (1-10)
WaitTimeSeconds int `json:"waitTimeSeconds,omitempty"` // Wait time for messages
VisibilityTimeout int `json:"visibilityTimeout,omitempty"` // Visibility timeout in seconds
}

type AWSDDBStreams struct {
AWSCommon `json:",inline"` // Embeds AWSCommon to inherit its fields in JSON
Table string `json:"table,omitempty"` // The name of the DynamoDB table
StreamIteratorType string `json:"streamIteratorType,omitempty" default:"FROM_LATEST"` // Defines where in the DynamoDB stream to start getting records
Delay int `json:"delay,omitempty" default:"500"` // Delay in milliseconds before the next poll from the database
}

type Aws struct {
S3 *AWSS3 `json:"s3,omitempty"` // S3 source configuration
SQS *AWSSQS `json:"sqs,omitempty"` // SQS source configuration
DDBStreams *AWSDDBStreams `json:"ddbStreams,omitempty"` // DynamoDB Streams source configuration
Auth *Auth `json:"auth,omitempty"`
}

type Auth struct {
// Auth Secret
Secret *Secret `json:"secret,omitempty"`

// AccessKey is the AWS access key ID.
AccessKey string `json:"accessKey,omitempty"`

// SecretKey is the AWS secret access key.
SecretKey string `json:"secretKey,omitempty"`
}

func (a *Auth) HasAuth() bool {
return a != nil && a.Secret != nil &&
a.Secret.Ref != nil && a.Secret.Ref.Name != ""
}

type Secret struct {
// Secret reference for SASL and SSL configurations.
Ref *SecretReference `json:"ref,omitempty"`
}

type SecretReference struct {
// Secret name.
Name string `json:"name"`
S3 *v1alpha1.AWSS3 `json:"s3,omitempty"` // S3 source configuration
SQS *v1alpha1.AWSSQS `json:"sqs,omitempty"` // SQS source configuration
DDBStreams *v1alpha1.AWSDDBStreams `json:"ddbStreams,omitempty"` // DynamoDB Streams source configuration
Auth *v1alpha1.Auth `json:"auth,omitempty"`
}

// GetGroupVersionKind returns the GroupVersionKind.
Expand Down
Loading

0 comments on commit 84c5911

Please sign in to comment.