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

Commit 205995e

Browse files
Adding Model File, Example and Server Code
**Why:** * This enabled creation of SQS resources with the operator **This change addresses the need by:** * closes #7 Signed-off-by: Christopher Hein <[email protected]>
1 parent 8665f5a commit 205995e

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

examples/sqs.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: SQS
3+
metadata:
4+
name: chrishein-test-sqs-1
5+
spec:
6+
contentBasedDeduplication: false
7+
delaySeconds: 1
8+
usedeadletterQueue: false

models/sqsqueue.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: ModelDefinition
3+
metadata:
4+
name: SQSResource
5+
spec:
6+
kind: SQSQueue
7+
type: Spec # can be Spec or Data
8+
queue: true
9+
useCloudFormation: true
10+
resource:
11+
name: sqsqueue
12+
plural: sqsqueues
13+
shortNames:
14+
- name: sqs
15+
- name: queue
16+
- name: queues
17+
body:
18+
schema:
19+
type: object
20+
properties:
21+
- key: contentBasedDeduplication
22+
type: bool
23+
description: |
24+
ContentBasedDeduplication enables content deduping on the queue
25+
structKey: ContentBasedDeduplication
26+
templateKey: ContentBasedDeduplication
27+
- key: delaySeconds
28+
type: int
29+
description: |
30+
DelaySeconds is how long the message should delay on recieving.
31+
structKey: DelaySeconds
32+
templateKey: DelaySeconds
33+
- key: maximumMessageSize
34+
type: int
35+
description: |
36+
MaximumMessageSize the maximum size a message should be and int
37+
structKey: MaximumMessageSize
38+
templateKey: MaximumMessageSize
39+
- key: messageRetentionPeriod
40+
type: int
41+
description: |
42+
MaximumMessageSize the maximum size a message should be
43+
MessageRetentionPeriod determines how long to keep a message
44+
structKey: MessageRetentionPeriod
45+
templateKey: MessageRetentionPeriod
46+
- key: receiveMessageWaitTimeSeconds
47+
type: int
48+
description: |
49+
Time it will wait until it tries to find another message to process.
50+
structKey: ReceiveMessageWaitTimeSeconds
51+
templateKey: ReceiveMessageWaitTimeSeconds
52+
- key: usedeadletterQueue
53+
type: bool
54+
description: |
55+
Queue specifically made for messages that cannot be processed
56+
structKey: UsedeadletterQueue
57+
templateKey: UsedeadletterQueue
58+
- key: visibilityTimeout
59+
type: int
60+
description: |
61+
Timeout for processing a message.
62+
structKey: VisibilityTimeout
63+
templateKey: VisibilityTimeout
64+
- key: fifoQueue
65+
type: bool
66+
description: |
67+
Should this queue process messages in a first in first out manner
68+
structKey: FifoQueue
69+
templateKey: FifoQueue
70+
output:
71+
schema:
72+
type: object
73+
properties:
74+
- key: queueURL
75+
type: string
76+
description: |
77+
URL of newly created SQS Queue
78+
structKey: QueueURL
79+
templateKey: QueueURL
80+
- key: queueARN
81+
type: string
82+
description: |
83+
ARN of newly created SQS Queue
84+
structKey: QueueARN
85+
templateKey: QueueARN
86+
- key: queueName
87+
type: string
88+
description: |
89+
Name newly created SQS Queue
90+
structKey: QueueName
91+
templateKey: QueueName
92+
- key: deadLetterQueueURL
93+
type: string
94+
description: |
95+
URL of newly created SQS Queue
96+
structKey: DeadLetterQueueURL
97+
templateKey: DeadLetterQueueURL
98+
- key: deadLetterQueueARN
99+
type: string
100+
description: |
101+
ARN of newly created SQS Queue
102+
structKey: DeadLetterQueueARN
103+
templateKey: DeadLetterQueueARN
104+
- key: deadLetterQueueName
105+
type: string
106+
description: |
107+
Name newly created SQS Queue
108+
structKey: DeadLetterQueueName
109+
templateKey: DeadLetterQueueName

pkg/server/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/christopherhein/aws-operator/pkg/operator/cloudformationtemplate"
1313
"github.com/christopherhein/aws-operator/pkg/operator/dynamodb"
1414
"github.com/christopherhein/aws-operator/pkg/operator/s3bucket"
15+
"github.com/christopherhein/aws-operator/pkg/operator/sqsqueue"
1516
opkit "github.com/christopherhein/operator-kit"
1617
"k8s.io/api/core/v1"
1718
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
@@ -46,6 +47,7 @@ func (c *Server) Run(stopChan chan struct{}) {
4647
cloudformationtemplate.Resource,
4748
s3bucket.Resource,
4849
dynamodb.Resource,
50+
sqsqueue.Resource,
4951
}
5052
err = opkit.CreateCustomResources(*context, resources)
5153
if err != nil {
@@ -86,6 +88,9 @@ func (c *Server) Run(stopChan chan struct{}) {
8688

8789
ddbcontroller := dynamodb.NewController(config, context, awsClientset)
8890
ddbcontroller.StartWatch(v1.NamespaceAll, stopChan)
91+
92+
sqscontroller := sqsqueue.NewController(config, context, awsClientset)
93+
sqscontroller.StartWatch(v1.NamespaceAll, stopChan)
8994
}
9095

9196
func getClientConfig(kubeconfig string) (*rest.Config, error) {

0 commit comments

Comments
 (0)