@@ -18,7 +18,6 @@ import (
18
18
"context"
19
19
"fmt"
20
20
"io"
21
- "slices"
22
21
23
22
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
24
23
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
@@ -37,7 +36,6 @@ type DownloadOpts struct {
37
36
cli.GlobalOpts
38
37
cli.DownloaderOpts
39
38
tenantName string
40
- fileName string
41
39
start int64
42
40
end int64
43
41
store store.StreamsDownloader
@@ -51,13 +49,6 @@ func (opts *DownloadOpts) initStore(ctx context.Context) func() error {
51
49
}
52
50
}
53
51
54
- func (opts * DownloadOpts ) initDefaultOut () error {
55
- if opts .Out == "" {
56
- opts .Out = opts .fileName
57
- }
58
- return nil
59
- }
60
-
61
52
func (opts * DownloadOpts ) Run () error {
62
53
params := atlasv2.DownloadStreamTenantAuditLogsApiParams {
63
54
GroupId : opts .ProjectID ,
@@ -90,41 +81,31 @@ func (opts *DownloadOpts) Run() error {
90
81
}
91
82
92
83
// DownloadBuilder
93
- // atlas streams download [tenantName] audit.gz --projectId [projectID].
84
+ // atlas streams download [tenantName] --projectId [projectID].
94
85
func DownloadBuilder () * cobra.Command {
95
- const argsN = 2
86
+ const argsN = 1
96
87
opts := & DownloadOpts {}
97
88
opts .Fs = afero .NewOsFs ()
98
89
cmd := & cobra.Command {
99
- Use : "download <tenantName> <auditLogs.gz> " ,
90
+ Use : "download <tenantName>" ,
100
91
Short : "Download a compressed file that contains the logs for the specified Atlas Stream Processing instance." ,
101
92
Long : `This command downloads a file with a .gz extension.` + fmt .Sprintf (usage .RequiredRole , "Project Data Access Read/Write" ),
102
93
Args : cobra .MatchAll (
103
94
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
- },
110
95
),
111
96
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` ,
113
98
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 ,
117
101
},
118
102
PreRunE : func (cmd * cobra.Command , args []string ) error {
119
103
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 ()))
122
105
},
123
106
RunE : func (_ * cobra.Command , _ []string ) error {
124
107
return opts .Run ()
125
108
},
126
-
127
- ValidArgs : []string {"auditLogs.gz" },
128
109
}
129
110
130
111
cmd .Flags ().StringVar (& opts .Out , flag .Out , "" , usage .LogOut )
@@ -134,6 +115,7 @@ func DownloadBuilder() *cobra.Command {
134
115
135
116
cmd .Flags ().StringVar (& opts .ProjectID , flag .ProjectID , "" , usage .ProjectID )
136
117
118
+ _ = cmd .MarkFlagRequired (flag .Out )
137
119
_ = cmd .MarkFlagFilename (flag .Out )
138
120
139
121
return cmd
0 commit comments