Skip to content

Commit f5871ec

Browse files
committed
chore: Cleanup of download command
1 parent d1442ef commit f5871ec

File tree

3 files changed

+11
-34
lines changed

3 files changed

+11
-34
lines changed

docs/command/atlas-streams-instances-download.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Syntax
2222
.. code-block::
2323
:caption: Command Syntax
2424

25-
atlas streams instances download <tenantName> <auditLogs.gz> [options]
25+
atlas streams instances download <tenantName> [options]
2626

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

@@ -41,10 +41,6 @@ Arguments
4141
- string
4242
- true
4343
- Label that identifies the tenant that stores the log files that you want to download.
44-
* - auditLogs.gz
45-
- string
46-
- true
47-
- Log file that you want to return.
4844

4945
Options
5046
-------
@@ -71,7 +67,7 @@ Options
7167
- help for download
7268
* - --out
7369
- string
74-
- false
70+
- true
7571
- Output file name. This value defaults to the log name.
7672
* - --projectId
7773
- string
@@ -114,4 +110,4 @@ Examples
114110
.. code-block::
115111

116112
# Download the audit log file from the instance myProcessor for the project with the ID 5e2211c17a3e5a48f5497de3:
117-
atlas streams instance logs myProcessor auditLogs.gz --projectId 5e2211c17a3e5a48f5497de3
113+
atlas streams instance download myProcessor --projectId 5e2211c17a3e5a48f5497de3

internal/cli/atlas/streams/instance/download.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"context"
1919
"fmt"
2020
"io"
21-
"slices"
2221

2322
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
2423
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
@@ -37,7 +36,6 @@ type DownloadOpts struct {
3736
cli.GlobalOpts
3837
cli.DownloaderOpts
3938
tenantName string
40-
fileName string
4139
start int64
4240
end int64
4341
store store.StreamsDownloader
@@ -51,13 +49,6 @@ func (opts *DownloadOpts) initStore(ctx context.Context) func() error {
5149
}
5250
}
5351

54-
func (opts *DownloadOpts) initDefaultOut() error {
55-
if opts.Out == "" {
56-
opts.Out = opts.fileName
57-
}
58-
return nil
59-
}
60-
6152
func (opts *DownloadOpts) Run() error {
6253
params := atlasv2.DownloadStreamTenantAuditLogsApiParams{
6354
GroupId: opts.ProjectID,
@@ -90,41 +81,31 @@ func (opts *DownloadOpts) Run() error {
9081
}
9182

9283
// DownloadBuilder
93-
// atlas streams download [tenantName] audit.gz --projectId [projectID].
84+
// atlas streams download [tenantName] --projectId [projectID].
9485
func DownloadBuilder() *cobra.Command {
95-
const argsN = 2
86+
const argsN = 1
9687
opts := &DownloadOpts{}
9788
opts.Fs = afero.NewOsFs()
9889
cmd := &cobra.Command{
99-
Use: "download <tenantName> <auditLogs.gz>",
90+
Use: "download <tenantName>",
10091
Short: "Download a compressed file that contains the logs for the specified Atlas Stream Processing instance.",
10192
Long: `This command downloads a file with a .gz extension.` + fmt.Sprintf(usage.RequiredRole, "Project Data Access Read/Write"),
10293
Args: cobra.MatchAll(
10394
require.ExactArgs(argsN),
104-
func(cmd *cobra.Command, args []string) error {
105-
if !slices.Contains(cmd.ValidArgs, args[1]) {
106-
return fmt.Errorf("<logname> must be one of %s", cmd.ValidArgs)
107-
}
108-
return nil
109-
},
11095
),
11196
Example: ` # Download the audit log file from the instance myProcessor for the project with the ID 5e2211c17a3e5a48f5497de3:
112-
atlas streams instance logs myProcessor auditLogs.gz --projectId 5e2211c17a3e5a48f5497de3`,
97+
atlas streams instance download myProcessor --projectId 5e2211c17a3e5a48f5497de3`,
11398
Annotations: map[string]string{
114-
"tenantNameDesc": "Label that identifies the tenant that stores the log files that you want to download.",
115-
"auditLogs.gzDesc": "Log file that you want to return.",
116-
"output": downloadMessage,
99+
"tenantNameDesc": "Label that identifies the tenant that stores the log files that you want to download.",
100+
"output": downloadMessage,
117101
},
118102
PreRunE: func(cmd *cobra.Command, args []string) error {
119103
opts.tenantName = args[0]
120-
opts.fileName = args[1]
121-
return opts.PreRunE(opts.ValidateProjectID, opts.initStore(cmd.Context()), opts.initDefaultOut)
104+
return opts.PreRunE(opts.ValidateProjectID, opts.initStore(cmd.Context()))
122105
},
123106
RunE: func(_ *cobra.Command, _ []string) error {
124107
return opts.Run()
125108
},
126-
127-
ValidArgs: []string{"auditLogs.gz"},
128109
}
129110

130111
cmd.Flags().StringVar(&opts.Out, flag.Out, "", usage.LogOut)
@@ -134,6 +115,7 @@ func DownloadBuilder() *cobra.Command {
134115

135116
cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID)
136117

118+
_ = cmd.MarkFlagRequired(flag.Out)
137119
_ = cmd.MarkFlagFilename(flag.Out)
138120

139121
return cmd

test/e2e/atlas/streams_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func TestStreams(t *testing.T) {
100100
"instance",
101101
"download",
102102
instanceName,
103-
"auditLogs.gz",
104103
"--out",
105104
"-",
106105
"--start",

0 commit comments

Comments
 (0)