1+ //go:build darwin || linux || windows
2+
13package object
24
35import (
@@ -11,66 +13,9 @@ import (
1113 "github.com/aws/aws-sdk-go-v2/service/s3"
1214 "github.com/aws/aws-sdk-go-v2/service/s3/types"
1315 "github.com/scaleway/scaleway-cli/v2/core"
14- "github.com/scaleway/scaleway-cli/v2/internal/human"
1516 "github.com/scaleway/scaleway-sdk-go/scw"
1617)
1718
18- type bucketInfo struct {
19- ID string
20- Region scw.Region
21- APIEndpoint string
22- BucketEndpoint string
23- EnableVersioning bool
24- Tags []types.Tag
25- ACL []CustomS3ACLGrant
26- Owner string
27- }
28-
29- func bucketInfoMarshalerFunc (i interface {}, opt * human.MarshalOpt ) (string , error ) {
30- // To avoid recursion of human.Marshal we create a dummy type
31- type tmp bucketInfo
32- info := tmp (i .(bucketInfo ))
33-
34- opt .Sections = []* human.MarshalSection {
35- {
36- FieldName : "Tags" ,
37- HideIfEmpty : true ,
38- },
39- {
40- FieldName : "ACL" ,
41- HideIfEmpty : true ,
42- },
43- }
44- str , err := human .Marshal (info , opt )
45- if err != nil {
46- return "" , err
47- }
48- return str , nil
49- }
50-
51- type BucketResponse struct {
52- SuccessResult * core.SuccessResult
53- BucketInfo * bucketInfo
54- }
55-
56- func bucketResponseMarshalerFunc (i interface {}, opt * human.MarshalOpt ) (string , error ) {
57- resp := i .(BucketResponse )
58-
59- messageStr , err := resp .SuccessResult .MarshalHuman ()
60- if err != nil {
61- return "" , err
62- }
63- bucketStr , err := bucketInfoMarshalerFunc (* resp .BucketInfo , opt )
64- if err != nil {
65- return "" , err
66- }
67-
68- return strings .Join ([]string {
69- messageStr ,
70- bucketStr ,
71- }, "\n " ), nil
72- }
73-
7419type bucketConfigArgs struct {
7520 Region scw.Region
7621 Name string
@@ -205,59 +150,6 @@ func bucketDeleteCommand() *core.Command {
205150 }
206151}
207152
208- type bucketGetArgs struct {
209- Region scw.Region
210- Name string
211- WithSize bool `json:"with-size"`
212- }
213-
214- type BucketGetResult struct {
215- * bucketInfo
216- Size * scw.Size
217- NbObjects * int64
218- NbParts * int64
219- }
220-
221- func bucketGetResultMarshalerFunc (i interface {}, opt * human.MarshalOpt ) (string , error ) {
222- type tmp BucketGetResult
223- result := tmp (i .(BucketGetResult ))
224- opt .Sections = []* human.MarshalSection {
225- {
226- FieldName : "Tags" ,
227- HideIfEmpty : true ,
228- },
229- {
230- FieldName : "ACL" ,
231- HideIfEmpty : true ,
232- },
233- }
234- str , err := human .Marshal (result , opt )
235- if err != nil {
236- return "" , err
237- }
238- return str , nil
239- }
240-
241- func bucketMarshalerFunc (i interface {}, opt * human.MarshalOpt ) (string , error ) {
242- type tmp []types.Bucket
243- result := tmp (i .([]types.Bucket ))
244- opt .Fields = []* human.MarshalFieldOpt {
245- {
246- FieldName : "Name" ,
247- Label : "Name" ,
248- },
249- {
250- FieldName : "CreationDate" ,
251- Label : "Creation Date" ,
252- },
253- }
254- str , err := human .Marshal (result , opt )
255- if err != nil {
256- return "" , err
257- }
258- return str , nil
259- }
260-
261153func bucketGetCommand () * core.Command {
262154 return & core.Command {
263155 Namespace : "object" ,
0 commit comments