Skip to content

Commit 013d2ce

Browse files
CLOUDP-368426-Stream-Workspace Removing Connections from stream workspace
1 parent e3a8c9e commit 013d2ce

7 files changed

Lines changed: 6 additions & 293 deletions

File tree

cfn-resources/stream-workspace/cmd/resource/mappings.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -78,51 +78,6 @@ func newModelStreamConfig(streamConfig *admin.StreamConfig) *StreamConfig {
7878
return modelConfig
7979
}
8080

81-
func newModelDBRoleToExecute(dbRole *admin.DBRoleToExecute) *DBRoleToExecute {
82-
return &DBRoleToExecute{
83-
Role: dbRole.Role,
84-
Type: dbRole.Type,
85-
}
86-
}
87-
88-
func newModelAuthentication(authentication *admin.StreamsKafkaAuthentication) *StreamsKafkaAuthentication {
89-
return &StreamsKafkaAuthentication{
90-
Mechanism: authentication.Mechanism,
91-
Username: authentication.Username,
92-
}
93-
}
94-
95-
func newModelSecurity(security *admin.StreamsKafkaSecurity) *StreamsKafkaSecurity {
96-
return &StreamsKafkaSecurity{
97-
BrokerPublicCertificate: security.BrokerPublicCertificate,
98-
Protocol: security.Protocol,
99-
}
100-
}
101-
102-
func NewModelConnections(streamConfig *[]admin.StreamsConnection) []StreamsConnection {
103-
if streamConfig == nil || len(*streamConfig) == 0 {
104-
return nil
105-
}
106-
107-
connections := make([]StreamsConnection, 0)
108-
for _, connection := range *streamConfig {
109-
modelConnection := StreamsConnection{
110-
Name: connection.Name,
111-
Type: connection.Type,
112-
}
113-
if connection.GetType() == Kafka {
114-
modelConnection.BootstrapServers = connection.BootstrapServers
115-
modelConnection.Authentication = newModelAuthentication(connection.Authentication)
116-
modelConnection.Security = newModelSecurity(connection.Security)
117-
} else if connection.GetType() == Cluster {
118-
modelConnection.ClusterName = connection.ClusterName
119-
modelConnection.DbRoleToExecute = newModelDBRoleToExecute(connection.DbRoleToExecute)
120-
}
121-
connections = append(connections, modelConnection)
122-
}
123-
return connections
124-
}
125-
12681
func GetStreamWorkspaceModel(streamTenant *admin.StreamsTenant, currentModel *Model) *Model {
12782
model := new(Model)
12883

@@ -137,7 +92,6 @@ func GetStreamWorkspaceModel(streamTenant *admin.StreamsTenant, currentModel *Mo
13792
model.ProjectId = streamTenant.GroupId
13893
model.Id = streamTenant.Id
13994
model.Hostnames = streamTenant.GetHostnames()
140-
model.Connections = NewModelConnections(streamTenant.Connections)
14195
}
14296

14397
return model

cfn-resources/stream-workspace/cmd/resource/mappings_test.go

Lines changed: 6 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,17 @@ import (
1818
"testing"
1919

2020
"github.com/mongodb/mongodbatlas-cloudformation-resources/stream-workspace/cmd/resource"
21-
"github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2221
"github.com/stretchr/testify/assert"
2322
"go.mongodb.org/atlas-sdk/v20250312012/admin"
2423
)
2524

2625
var (
27-
workspaceName = "name"
28-
projectID = "projectId"
29-
cloudProvider = "AWS"
30-
region = "VIRGINIA_USA"
31-
tier = "SP30"
32-
maxTierSize = "SP50"
33-
name = "name"
34-
bootstrapServers = "bootstrapServers"
35-
clusterName = "clusterName"
26+
workspaceName = "name"
27+
projectID = "projectId"
28+
cloudProvider = "AWS"
29+
region = "VIRGINIA_USA"
30+
tier = "SP30"
31+
maxTierSize = "SP50"
3632
)
3733

3834
func TestNewStreamWorkspaceCreateReq(t *testing.T) {
@@ -122,72 +118,6 @@ func TestNewStreamWorkspaceCreateReq(t *testing.T) {
122118
}
123119
}
124120

125-
func TestNewModelConnections(t *testing.T) {
126-
testCases := []struct {
127-
name string
128-
input *[]admin.StreamsConnection
129-
expected []resource.StreamsConnection
130-
}{
131-
{
132-
name: "StreamConfig is nil",
133-
input: nil,
134-
expected: nil,
135-
},
136-
{
137-
name: "StreamConfig is empty",
138-
input: &[]admin.StreamsConnection{},
139-
expected: nil,
140-
},
141-
{
142-
name: "Connection type Kafka",
143-
input: &[]admin.StreamsConnection{
144-
{
145-
Name: &name,
146-
Type: util.Pointer(resource.Kafka),
147-
BootstrapServers: &bootstrapServers,
148-
Authentication: &admin.StreamsKafkaAuthentication{},
149-
Security: &admin.StreamsKafkaSecurity{},
150-
},
151-
},
152-
expected: []resource.StreamsConnection{
153-
{
154-
Name: &name,
155-
Type: util.Pointer(resource.Kafka),
156-
BootstrapServers: &bootstrapServers,
157-
Authentication: &resource.StreamsKafkaAuthentication{},
158-
Security: &resource.StreamsKafkaSecurity{},
159-
},
160-
},
161-
},
162-
{
163-
name: "Connection type Cluster",
164-
input: &[]admin.StreamsConnection{
165-
{
166-
Name: &name,
167-
Type: util.Pointer(resource.Cluster),
168-
ClusterName: &clusterName,
169-
DbRoleToExecute: &admin.DBRoleToExecute{},
170-
},
171-
},
172-
expected: []resource.StreamsConnection{
173-
{
174-
Name: &name,
175-
Type: util.Pointer(resource.Cluster),
176-
ClusterName: &clusterName,
177-
DbRoleToExecute: &resource.DBRoleToExecute{},
178-
},
179-
},
180-
},
181-
}
182-
183-
for _, tc := range testCases {
184-
t.Run(tc.name, func(t *testing.T) {
185-
result := resource.NewModelConnections(tc.input)
186-
assert.Equal(t, tc.expected, result, "created model did not match expected output")
187-
})
188-
}
189-
}
190-
191121
func TestNewStreamWorkspaceUpdateReq(t *testing.T) {
192122
newRegion := "OREGON_USA"
193123
awsProvider := "AWS"

cfn-resources/stream-workspace/cmd/resource/model.go

Lines changed: 0 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cfn-resources/stream-workspace/cmd/resource/resource.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ var UpdateRequiredFields = []string{"WorkspaceName", constants.ProjectID, consta
3535
var DeleteRequiredFields = []string{"WorkspaceName", constants.ProjectID}
3636
var ListRequiredFields = []string{constants.ProjectID}
3737

38-
const Kafka = "Kafka"
39-
const Cluster = "Cluster"
4038
const DefaultItemsPerPage = 100
4139

4240
var InitEnvWithLatestClient = func(req handler.Request, currentModel *Model, requiredFields []string) (*admin.APIClient, *handler.ProgressEvent) {

cfn-resources/stream-workspace/docs/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::G
9797

9898
Unique 24-hexadecimal character string that identifies the stream workspace.
9999

100-
#### Connections
101-
102-
Returns the <code>Connections</code> value.
103-
104100
#### Hostnames
105101

106102
List that contains the hostnames assigned to the stream workspace.

cfn-resources/stream-workspace/docs/dbroletoexecute.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

cfn-resources/stream-workspace/mongodb-atlas-streamworkspace.json

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -43,85 +43,6 @@
4343
},
4444
"required": ["Tier"],
4545
"additionalProperties": false
46-
},
47-
"StreamsKafkaAuthentication": {
48-
"type": "object",
49-
"description": "User credentials required to connect to a Kafka Cluster. Includes the authentication type, as well as the parameters for that authentication mode.",
50-
"properties": {
51-
"Mechanism": {
52-
"type": "string",
53-
"description": "Style of authentication. Can be one of PLAIN, SCRAM-256, or SCRAM-512."
54-
},
55-
"Username": {
56-
"type": "string",
57-
"description": "Username of the account to connect to the Kafka cluster."
58-
}
59-
},
60-
"additionalProperties": false
61-
},
62-
"DBRoleToExecute": {
63-
"type": "object",
64-
"description": "The name of a Built in or Custom DB Role to connect to an Atlas Cluster.",
65-
"properties": {
66-
"Role": {
67-
"type": "string",
68-
"description": "The name of the role to use. Can be a built in role or a custom role."
69-
},
70-
"Type": {
71-
"type": "string",
72-
"description": "Type of the DB role. Can be either BuiltIn or Custom.",
73-
"enum": ["BUILT_IN", "CUSTOM"]
74-
}
75-
},
76-
"additionalProperties": false
77-
},
78-
"StreamsKafkaSecurity": {
79-
"type": "object",
80-
"description": "Properties for the secure transport connection to Kafka. For SSL, this can include the trusted certificate to use.",
81-
"properties": {
82-
"BrokerPublicCertificate": {
83-
"type": "string",
84-
"description": "A trusted, public x509 certificate for connecting to Kafka over SSL."
85-
},
86-
"Protocol": {
87-
"type": "string",
88-
"description": "Describes the transport type. Can be either PLAINTEXT or SSL."
89-
}
90-
},
91-
"additionalProperties": false
92-
},
93-
"StreamsConnection": {
94-
"type": "object",
95-
"description": "Settings that define a connection to an external data store.",
96-
"properties": {
97-
"Name": {
98-
"type": "string",
99-
"description": "Human-readable label that identifies the stream connection."
100-
},
101-
"Type": {
102-
"type": "string",
103-
"description": "Type of the connection. Can be either Cluster or Kafka.",
104-
"enum": ["Kafka", "Cluster", "Sample"]
105-
},
106-
"Authentication": {
107-
"$ref": "#/definitions/StreamsKafkaAuthentication"
108-
},
109-
"BootstrapServers": {
110-
"type": "string",
111-
"description": "Comma separated list of server addresses."
112-
},
113-
"Security": {
114-
"$ref": "#/definitions/StreamsKafkaSecurity"
115-
},
116-
"ClusterName": {
117-
"type": "string",
118-
"description": "Name of the cluster configured for this connection."
119-
},
120-
"DbRoleToExecute": {
121-
"$ref": "#/definitions/DBRoleToExecute"
122-
}
123-
},
124-
"additionalProperties": false
12546
}
12647
},
12748
"properties": {
@@ -144,13 +65,6 @@
14465
"description": "Unique 24-hexadecimal character string that identifies the stream workspace.",
14566
"type": "string"
14667
},
147-
"Connections": {
148-
"type": "array",
149-
"items": {
150-
"$ref": "#/definitions/StreamsConnection"
151-
},
152-
"insertionOrder": false
153-
},
15468
"ProjectId": {
15569
"description": "Unique 24-hexadecimal character string that identifies the project.",
15670
"type": "string"
@@ -168,7 +82,6 @@
16882
"required": ["ProjectId", "WorkspaceName", "DataProcessRegion"],
16983
"readOnlyProperties": [
17084
"/properties/Id",
171-
"/properties/Connections",
17285
"/properties/Hostnames"
17386
],
17487
"primaryIdentifier": [

0 commit comments

Comments
 (0)