-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathview.go
53 lines (45 loc) · 1.39 KB
/
view.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: Apache-2.0
package settings
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/go-vela/cli/internal/output"
"github.com/go-vela/sdk-go/vela"
)
// View inspects settings based off the provided configuration.
func (c *Config) View(client *vela.Client) error {
logrus.Debug("executing view for settings configuration")
logrus.Trace("inspecting settings")
response, _, err := client.Admin.Settings.Get()
if err != nil {
return fmt.Errorf("unable to retrieve settings: %w", err)
}
// handle the output based off the provided configuration
switch c.Output {
case output.DriverDump:
// output in dump format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Dump
return output.Dump(response)
case output.DriverJSON:
// output in JSON format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#JSON
return output.JSON(response)
case output.DriverSpew:
// output in spew format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Spew
return output.Spew(response)
case output.DriverYAML:
// output in YAML format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#YAML
return output.YAML(response)
default:
// output in stdout format
//
// https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stdout
return output.Stdout(response)
}
}