Skip to content

Commit 2898433

Browse files
committed
use setters, rename privateLinks subcommand to use plurals, compare against empty string
1 parent 5ec1d8f commit 2898433

File tree

6 files changed

+30
-35
lines changed

6 files changed

+30
-35
lines changed

docs/command/atlas-streams-privateLink-create.txt renamed to docs/command/atlas-streams-privateLinks-create.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. _atlas-streams-privateLink-create:
1+
.. _atlas-streams-privateLinks-create:
22

3-
================================
4-
atlas streams privateLink create
5-
================================
3+
=================================
4+
atlas streams privateLinks create
5+
=================================
66

77
.. default-domain:: mongodb
88

@@ -22,7 +22,7 @@ Syntax
2222
.. code-block::
2323
:caption: Command Syntax
2424

25-
atlas streams privateLink create [options]
25+
atlas streams privateLinks create [options]
2626

2727
.. Code end marker, please don't delete this comment
2828

docs/command/atlas-streams-privateLink.txt renamed to docs/command/atlas-streams-privateLinks.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. _atlas-streams-privateLink:
1+
.. _atlas-streams-privateLinks:
22

3-
=========================
4-
atlas streams privateLink
5-
=========================
3+
==========================
4+
atlas streams privateLinks
5+
==========================
66

77
.. default-domain:: mongodb
88

@@ -30,7 +30,7 @@ Options
3030
* - -h, --help
3131
-
3232
- false
33-
- help for privateLink
33+
- help for privateLinks
3434

3535
Inherited Options
3636
-----------------
@@ -51,11 +51,11 @@ Inherited Options
5151
Related Commands
5252
----------------
5353

54-
* :ref:`atlas-streams-privateLink-create` - Creates a PrivateLink endpoint that can be used as an Atlas Stream Processor connection.
54+
* :ref:`atlas-streams-privateLinks-create` - Creates a PrivateLink endpoint that can be used as an Atlas Stream Processor connection.
5555

5656

5757
.. toctree::
5858
:titlesonly:
5959

60-
create </command/atlas-streams-privateLink-create>
60+
create </command/atlas-streams-privateLinks-create>
6161

docs/command/atlas-streams.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ Related Commands
5353

5454
* :ref:`atlas-streams-connections` - Manage Atlas Stream Processing connections.
5555
* :ref:`atlas-streams-instances` - Manage Atlas Stream Processing instances.
56-
* :ref:`atlas-streams-privateLink` - Manage Atlas Stream Processing PrivateLink endpoints.
56+
* :ref:`atlas-streams-privateLinks` - Manage Atlas Stream Processing PrivateLink endpoints.
5757

5858

5959
.. toctree::
6060
:titlesonly:
6161

6262
connections </command/atlas-streams-connections>
6363
instances </command/atlas-streams-instances>
64-
privateLink </command/atlas-streams-privateLink>
64+
privateLinks </command/atlas-streams-privateLinks>
6565

internal/cli/streams/privatelink/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (opts *CreateOpts) Run() error {
4848
}
4949

5050
// Remaining validation will be done by the API
51-
if len(privateLinkEndpoint.GetProvider()) == 0 {
51+
if privateLinkEndpoint.GetProvider() == "" {
5252
return errors.New("provider missing")
5353
}
5454

internal/cli/streams/privatelink/create_test.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ import (
3030
const fileName = "test-privateLink.json"
3131

3232
func TestCreateOpts_Run(t *testing.T) {
33-
validPrivateLinkConfigFileContents := `
34-
{
35-
"provider": "Azure",
36-
"region": "US_EAST_2",
37-
"serviceEndpointId": "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace",
38-
"dnsDomain": "test-namespace.servicebus.windows.net"
39-
}
40-
`
41-
4233
testCases := []struct {
4334
name string
4435
fileContents string
@@ -68,7 +59,7 @@ func TestCreateOpts_Run(t *testing.T) {
6859
t.Run(tc.name, func(t *testing.T) {
6960
fs := afero.NewMemMapFs()
7061

71-
if len(tc.fileContents) > 0 {
62+
if tc.fileContents != "" {
7263
require.NoError(t, afero.WriteFile(fs, fileName, []byte(tc.fileContents), 0600))
7364
}
7465

@@ -81,6 +72,15 @@ func TestCreateOpts_Run(t *testing.T) {
8172
})
8273
}
8374

75+
validPrivateLinkConfigFileContents := `
76+
{
77+
"provider": "Azure",
78+
"region": "US_EAST_2",
79+
"serviceEndpointId": "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace",
80+
"dnsDomain": "test-namespace.servicebus.windows.net"
81+
}
82+
`
83+
8484
t.Run("should call the store create privateLink method with the correct parameters", func(t *testing.T) {
8585
fs := afero.NewMemMapFs()
8686
require.NoError(t, afero.WriteFile(fs, fileName, []byte(validPrivateLinkConfigFileContents), 0600))
@@ -94,16 +94,11 @@ func TestCreateOpts_Run(t *testing.T) {
9494
filename: fileName,
9595
}
9696

97-
expectedProvider := "Azure"
98-
expectedRegion := "US_EAST_2"
99-
expectedServiceEndpointID := "/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace"
100-
expectedDNSDomain := "test-namespace.servicebus.windows.net"
101-
10297
expected := atlasv2.NewStreamsPrivateLinkConnection()
103-
expected.Provider = &expectedProvider
104-
expected.Region = &expectedRegion
105-
expected.ServiceEndpointId = &expectedServiceEndpointID
106-
expected.DnsDomain = &expectedDNSDomain
98+
expected.SetProvider("Azure")
99+
expected.SetRegion("US_EAST_2")
100+
expected.SetServiceEndpointId("/subscriptions/fd01adff-b37e-4693-8497-83ecf183a145/resourceGroups/test-rg/providers/Microsoft.EventHub/namespaces/test-namespace")
101+
expected.SetDnsDomain("test-namespace.servicebus.windows.net")
107102

108103
mockStore.
109104
EXPECT().

internal/cli/streams/privatelink/privatelink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
var commandRoles = strings.Join([]string{"Project Owner", "Project Stream Processing Owner"}, ", ")
2525

2626
func Builder() *cobra.Command {
27-
const use = "privateLink"
27+
const use = "privateLinks"
2828
cmd := &cobra.Command{
2929
Use: use,
3030
Aliases: cli.GenerateAliases(use),

0 commit comments

Comments
 (0)