This repository has been archived by the owner on Nov 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from christopherhein/feature/6-dynamo-resource
Add DynamoDB resource
- Loading branch information
Showing
17 changed files
with
1,268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: operator.aws/v1alpha1 | ||
kind: DynamoDB | ||
metadata: | ||
name: dynamodb-table | ||
spec: | ||
tableName: dynamodb-table | ||
hashAttribute: | ||
name: user_id | ||
type: S | ||
rangeAttribute: | ||
name: created_at | ||
type: S | ||
readCapacityUnits: 5 | ||
writeCapacityUnits: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
apiVersion: operator.aws/v1alpha1 | ||
kind: ModelDefinition | ||
metadata: | ||
name: DynamoDBResource | ||
spec: | ||
kind: DynamoDB | ||
type: Spec # can be Spec or Data | ||
queue: true | ||
useCloudFormation: true | ||
resource: | ||
name: dynamodb | ||
plural: dynamodbs | ||
shortNames: | ||
- name: ddb | ||
- name: ddbs | ||
- name: dynamo | ||
- name: dynamotable | ||
- name: dynamotables | ||
body: | ||
schema: | ||
title: DynamoDB | ||
type: object | ||
properties: | ||
- key: tableName | ||
type: string | ||
description: | | ||
TableName is the name of the DynamoDB Table to be created. | ||
structKey: TableName | ||
templateKey: TableName | ||
- key: rangeAttribute | ||
type: object | ||
description: | | ||
RangeAttribute is the configuration for the range attribute. | ||
structKey: RangeAttribute | ||
templateKey: RangeAttribute | ||
properties: | ||
- key: Name | ||
type: string | ||
description: | | ||
Name is the name of the range attribute on the table. | ||
structKey: Name | ||
templateKey: RangeAttributeName | ||
- key: Type | ||
type: string | ||
description: | | ||
Type is the kind of range attribute that should be used. | ||
structKey: Type | ||
templateKey: RangeAttributeType | ||
- key: readCapacityUnits | ||
type: int | ||
description: | | ||
ReadCapacityUnits specifies the read capacity of the table. | ||
structKey: ReadCapacityUnits | ||
templateKey: ReadCapacityUnits | ||
- key: writeCapacityUnits | ||
type: int | ||
description: | | ||
WriteCapacityUnits specifies the write capacity of the table. | ||
structKey: WriteCapacityUnits | ||
templateKey: WriteCapacityUnits | ||
- key: hashAttribute | ||
type: object | ||
description: | | ||
HashAttribute is the configuration for the hash attribute on the table. | ||
structKey: HashAttribute | ||
templateKey: HashAttribute | ||
properties: | ||
- key: Name | ||
type: string | ||
description: | | ||
Name is the name of the hashing attribute on the table. | ||
structKey: Name | ||
templateKey: HashAttributeName | ||
- key: Type | ||
type: string | ||
description: | | ||
Type is the kind of hash attribute that should be used. | ||
structKey: Type | ||
templateKey: HashAttributeType | ||
output: | ||
schema: | ||
type: object | ||
properties: | ||
- key: tableName | ||
type: string | ||
description: | | ||
TableName is the output tablename incase it changed | ||
structKey: TableName | ||
templateKey: TableName | ||
- key: tableARN | ||
type: string | ||
description: | | ||
TableARN is the full Amazon ARN for the table created | ||
structKey: TableARN | ||
templateKey: TableArn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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 | ||
|
||
// DynamoDB defines the base resource | ||
type DynamoDB struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata"` | ||
Spec DynamoDBSpec `json:"spec"` | ||
Status DynamoDBStatus `json:"status"` | ||
Output DynamoDBOutput `json:"output"` | ||
AdditionalResources DynamoDBAdditionalResources `json:"additionalResources"` | ||
} | ||
// DynamoDBHashAttribute defines the HashAttribute resource for DynamoDB | ||
type DynamoDBHashAttribute struct { | ||
Name string `json:"Name"` | ||
Type string `json:"Type"` | ||
} | ||
|
||
// DynamoDBRangeAttribute defines the RangeAttribute resource for DynamoDB | ||
type DynamoDBRangeAttribute struct { | ||
Name string `json:"Name"` | ||
Type string `json:"Type"` | ||
} | ||
|
||
// DynamoDBSpec defines the Spec resource for DynamoDB | ||
type DynamoDBSpec struct { | ||
CloudFormationTemplateName string `json:"cloudFormationTemplateName"` | ||
CloudFormationTemplateNamespace string `json:"cloudFormationTemplateNamespace"` | ||
TableName string `json:"tableName"` | ||
RangeAttribute DynamoDBRangeAttribute `json:"rangeAttribute"` | ||
ReadCapacityUnits int `json:"readCapacityUnits"` | ||
WriteCapacityUnits int `json:"writeCapacityUnits"` | ||
HashAttribute DynamoDBHashAttribute `json:"hashAttribute"` | ||
} | ||
|
||
|
||
// DynamoDBOutput defines the output resource for DynamoDB | ||
type DynamoDBOutput struct { | ||
TableName string `json:"tableName"` | ||
TableARN string `json:"tableARN"` | ||
} | ||
|
||
// DynamoDBStatus holds the status of the Cloudformation template | ||
type DynamoDBStatus struct { | ||
ResourceStatus string `json:"resourceStatus"` | ||
ResourceStatusReason string `json:"resourceStatusReason"` | ||
StackID string `json:"stackID"` | ||
} | ||
|
||
// DynamoDBAdditionalResources holds the additional resources | ||
type DynamoDBAdditionalResources struct { | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// DynamoDBList defines the list attribute for the DynamoDB type | ||
type DynamoDBList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata"` | ||
Items []DynamoDB `json:"items"` | ||
} | ||
|
||
func init() { | ||
localSchemeBuilder.Register(addDynamoDBTypes) | ||
} | ||
|
||
func addDynamoDBTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&DynamoDB{}, | ||
&DynamoDBList{}, | ||
) | ||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion) | ||
return nil | ||
} |
161 changes: 161 additions & 0 deletions
161
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.
Oops, something went wrong.
Oops, something went wrong.