-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Initial dynamodb-ns implementation #800
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,56 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# | ||
# 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. | ||
--- | ||
version: 1 | ||
name: csb-aws-dynamodb-namespace | ||
id: 07d06aeb-f87a-4e06-90ae-0b07a8c21a02 | ||
description: CSB Amazon DynamoDB Namespace | ||
display_name: CSB Amazon DynamoDB Namespace | ||
image_url: file://service-images/csb.png | ||
documentation_url: https://docs.vmware.com/en/Tanzu-Cloud-Service-Broker-for-AWS/1.5/csb-aws/GUID-reference-aws-dynamodb-namespace.html | ||
provider_display_name: VMware | ||
support_url: https://aws.amazon.com/dynamodb/ | ||
tags: [aws, dynamodb, namespace] | ||
plan_updateable: true | ||
plans: | ||
- name: default | ||
id: 73b55e9a-4cdd-4d6f-81bd-c34d5c27a086 | ||
description: "A DynamoDB Namespace" | ||
display_name: "dynamodb namespace" | ||
provision: | ||
template_refs: | ||
outputs: terraform/dynamodb-namespace/provision/outputs.tf | ||
variables: terraform/dynamodb-namespace/provision/variables.tf | ||
computed_inputs: | ||
- name: prefix | ||
type: string | ||
details: Prefix for the DynamoDB table names | ||
default: csb-${request.instance_id} | ||
- name: region | ||
type: string | ||
details: Region for the DynamoDB tables | ||
default: ${region} | ||
outputs: | ||
- field_name: prefix | ||
type: string | ||
details: Prefix for the DynamoDB table names | ||
- field_name: region | ||
type: string | ||
details: Region for the DynamoDB tables | ||
bind: | ||
plan_inputs: [] | ||
user_inputs: [] | ||
computed_inputs: [] | ||
template_refs: {} | ||
outputs: [] |
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
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,45 @@ | ||
package terraformtests | ||
|
||
import ( | ||
"path" | ||
|
||
tfjson "github.com/hashicorp/terraform-json" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
. "csbbrokerpakaws/terraform-tests/helpers" | ||
) | ||
|
||
var _ = Describe("dynamodb-namespace", Label("dynamodb-ns-terraform"), Ordered, func() { | ||
var ( | ||
plan tfjson.Plan | ||
terraformProvisionDir string | ||
) | ||
|
||
defaultVars := map[string]any{ | ||
"region": "fake-region", | ||
"prefix": "csb-fake-5368-489c-9f18-b53140316fb2", | ||
} | ||
|
||
BeforeAll(func() { | ||
terraformProvisionDir = path.Join(workingDir, "dynamodb-namespace/provision") | ||
Init(terraformProvisionDir) | ||
}) | ||
|
||
Context("default provisioning", func() { | ||
BeforeAll(func() { | ||
plan = ShowPlan(terraformProvisionDir, buildVars(defaultVars, map[string]any{})) | ||
}) | ||
|
||
It("should not create any resources", func() { | ||
Expect(plan.ResourceChanges).To(BeEmpty()) | ||
}) | ||
|
||
It("should pass through the parameters", func() { | ||
Expect(plan.OutputChanges).To(HaveKeyWithValue("region", BeAssignableToTypeOf(&tfjson.Change{}))) | ||
Expect(plan.OutputChanges).To(HaveKeyWithValue("prefix", BeAssignableToTypeOf(&tfjson.Change{}))) | ||
Expect(plan.OutputChanges["region"].After).To(Equal("fake-region")) | ||
Expect(plan.OutputChanges["prefix"].After).To(Equal("csb-fake-5368-489c-9f18-b53140316fb2")) | ||
}) | ||
}) | ||
}) |
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,16 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# | ||
# 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. | ||
|
||
output "region" { value = var.region } | ||
output "prefix" { value = var.prefix } |
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,16 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# | ||
# 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. | ||
|
||
variable "prefix" { type = string } | ||
variable "region" { type = string } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the Ginkgo docs:
Initialising a non-const outside of a BeforeEach() can lead to subtle issues that are hard to debug as if one testcase alters the value, another testcase will the the altered value and not the original (expected) value. Because testcases run in random order, these issues take ages to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On seconds thoughts, this is an ordered test with a BeforeAll() rather than a BeforeEach(), so while the above point is true, the risk is lower as the tests are not randomised.