Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
Merge pull request #24 from christopherhein/feature/7-adding-sqs
Browse files Browse the repository at this point in the history
Adding SQS resource
  • Loading branch information
Christopher Hein authored Aug 2, 2018
2 parents 655b5e5 + 205995e commit 50c238b
Show file tree
Hide file tree
Showing 17 changed files with 1,243 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/sqs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: operator.aws/v1alpha1
kind: SQS
metadata:
name: chrishein-test-sqs-1
spec:
contentBasedDeduplication: false
delaySeconds: 1
usedeadletterQueue: false
109 changes: 109 additions & 0 deletions models/sqsqueue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apiVersion: operator.aws/v1alpha1
kind: ModelDefinition
metadata:
name: SQSResource
spec:
kind: SQSQueue
type: Spec # can be Spec or Data
queue: true
useCloudFormation: true
resource:
name: sqsqueue
plural: sqsqueues
shortNames:
- name: sqs
- name: queue
- name: queues
body:
schema:
type: object
properties:
- key: contentBasedDeduplication
type: bool
description: |
ContentBasedDeduplication enables content deduping on the queue
structKey: ContentBasedDeduplication
templateKey: ContentBasedDeduplication
- key: delaySeconds
type: int
description: |
DelaySeconds is how long the message should delay on recieving.
structKey: DelaySeconds
templateKey: DelaySeconds
- key: maximumMessageSize
type: int
description: |
MaximumMessageSize the maximum size a message should be and int
structKey: MaximumMessageSize
templateKey: MaximumMessageSize
- key: messageRetentionPeriod
type: int
description: |
MaximumMessageSize the maximum size a message should be
MessageRetentionPeriod determines how long to keep a message
structKey: MessageRetentionPeriod
templateKey: MessageRetentionPeriod
- key: receiveMessageWaitTimeSeconds
type: int
description: |
Time it will wait until it tries to find another message to process.
structKey: ReceiveMessageWaitTimeSeconds
templateKey: ReceiveMessageWaitTimeSeconds
- key: usedeadletterQueue
type: bool
description: |
Queue specifically made for messages that cannot be processed
structKey: UsedeadletterQueue
templateKey: UsedeadletterQueue
- key: visibilityTimeout
type: int
description: |
Timeout for processing a message.
structKey: VisibilityTimeout
templateKey: VisibilityTimeout
- key: fifoQueue
type: bool
description: |
Should this queue process messages in a first in first out manner
structKey: FifoQueue
templateKey: FifoQueue
output:
schema:
type: object
properties:
- key: queueURL
type: string
description: |
URL of newly created SQS Queue
structKey: QueueURL
templateKey: QueueURL
- key: queueARN
type: string
description: |
ARN of newly created SQS Queue
structKey: QueueARN
templateKey: QueueARN
- key: queueName
type: string
description: |
Name newly created SQS Queue
structKey: QueueName
templateKey: QueueName
- key: deadLetterQueueURL
type: string
description: |
URL of newly created SQS Queue
structKey: DeadLetterQueueURL
templateKey: DeadLetterQueueURL
- key: deadLetterQueueARN
type: string
description: |
ARN of newly created SQS Queue
structKey: DeadLetterQueueARN
templateKey: DeadLetterQueueARN
- key: deadLetterQueueName
type: string
description: |
Name newly created SQS Queue
structKey: DeadLetterQueueName
templateKey: DeadLetterQueueName
77 changes: 77 additions & 0 deletions pkg/apis/operator.aws/v1alpha1/sqsqueue.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// SQSQueue defines the base resource
type SQSQueue struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec SQSQueueSpec `json:"spec"`
Status SQSQueueStatus `json:"status"`
Output SQSQueueOutput `json:"output"`
AdditionalResources SQSQueueAdditionalResources `json:"additionalResources"`
}
// SQSQueueSpec defines the Spec resource for SQSQueue
type SQSQueueSpec struct {
CloudFormationTemplateName string `json:"cloudFormationTemplateName"`
CloudFormationTemplateNamespace string `json:"cloudFormationTemplateNamespace"`
ContentBasedDeduplication bool `json:"contentBasedDeduplication"`
DelaySeconds int `json:"delaySeconds"`
MaximumMessageSize int `json:"maximumMessageSize"`
MessageRetentionPeriod int `json:"messageRetentionPeriod"`
ReceiveMessageWaitTimeSeconds int `json:"receiveMessageWaitTimeSeconds"`
UsedeadletterQueue bool `json:"usedeadletterQueue"`
VisibilityTimeout int `json:"visibilityTimeout"`
FifoQueue bool `json:"fifoQueue"`
}


// SQSQueueOutput defines the output resource for SQSQueue
type SQSQueueOutput struct {
QueueURL string `json:"queueURL"`
QueueARN string `json:"queueARN"`
QueueName string `json:"queueName"`
DeadLetterQueueURL string `json:"deadLetterQueueURL"`
DeadLetterQueueARN string `json:"deadLetterQueueARN"`
DeadLetterQueueName string `json:"deadLetterQueueName"`
}

// SQSQueueStatus holds the status of the Cloudformation template
type SQSQueueStatus struct {
ResourceStatus string `json:"resourceStatus"`
ResourceStatusReason string `json:"resourceStatusReason"`
StackID string `json:"stackID"`
}

// SQSQueueAdditionalResources holds the additional resources
type SQSQueueAdditionalResources struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// SQSQueueList defines the list attribute for the SQSQueue type
type SQSQueueList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []SQSQueue `json:"items"`
}

func init() {
localSchemeBuilder.Register(addSQSQueueTypes)
}

func addSQSQueueTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&SQSQueue{},
&SQSQueueList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
127 changes: 127 additions & 0 deletions pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go

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

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

Loading

0 comments on commit 50c238b

Please sign in to comment.