|
| 1 | +/* |
| 2 | +Copyright 2018 The Doctl Authors All rights reserved. |
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +Unless required by applicable law or agreed to in writing, software |
| 8 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +*/ |
| 13 | + |
| 14 | +package displayers |
| 15 | + |
| 16 | +import ( |
| 17 | + "io" |
| 18 | + |
| 19 | + "github.com/digitalocean/doctl/do" |
| 20 | +) |
| 21 | + |
| 22 | +type SpacesKey struct { |
| 23 | + SpacesKeys []do.SpacesKey |
| 24 | +} |
| 25 | + |
| 26 | +var _ Displayable = &SpacesKey{} |
| 27 | + |
| 28 | +// ColMap implements Displayable. |
| 29 | +func (s *SpacesKey) ColMap() map[string]string { |
| 30 | + return map[string]string{ |
| 31 | + "Name": "Name", |
| 32 | + "AccessKey": "Access Key", |
| 33 | + "SecretKey": "Secret Key", |
| 34 | + "Grants": "Grants", |
| 35 | + "CreatedAt": "Created At", |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +// Cols implements Displayable. |
| 40 | +func (s *SpacesKey) Cols() []string { |
| 41 | + return []string{ |
| 42 | + "Name", |
| 43 | + "AccessKey", |
| 44 | + "SecretKey", |
| 45 | + "Grants", |
| 46 | + "CreatedAt", |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +// JSON implements Displayable. |
| 51 | +func (s *SpacesKey) JSON(out io.Writer) error { |
| 52 | + return writeJSON(s.SpacesKeys, out) |
| 53 | +} |
| 54 | + |
| 55 | +// KV implements Displayable. |
| 56 | +func (s *SpacesKey) KV() []map[string]any { |
| 57 | + out := make([]map[string]any, 0, len(s.SpacesKeys)) |
| 58 | + |
| 59 | + for _, key := range s.SpacesKeys { |
| 60 | + m := map[string]any{ |
| 61 | + "Name": key.Name, |
| 62 | + "AccessKey": key.AccessKey, |
| 63 | + "SecretKey": key.SecretKey, |
| 64 | + "Grants": key.GrantString(), |
| 65 | + "CreatedAt": key.CreatedAt, |
| 66 | + } |
| 67 | + |
| 68 | + out = append(out, m) |
| 69 | + } |
| 70 | + |
| 71 | + return out |
| 72 | +} |
0 commit comments