• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

UiPath / uipathcli / 15180300709

22 May 2025 07:04AM UTC coverage: 90.76% (-0.05%) from 90.808%
15180300709

push

github

thschmitt
Improve configure command by providing tenant list

410 of 448 new or added lines in 17 files covered. (91.52%)

14 existing lines in 3 files now uncovered.

6915 of 7619 relevant lines covered (90.76%)

1.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.29
/commandline/config_set_command_handler.go
1
package commandline
2

3
import (
4
        "fmt"
5
        "io"
6
        "strings"
7

8
        "github.com/UiPath/uipathcli/config"
9
)
10

11
// configSetCommandHandler implements command for setting config values.
12
//
13
// Example:
14
// uipath config set --key uri --value https://myserver
15
//
16
// The command also supports setting values in different profiles.
17
//
18
// Example:
19
// uipath config set --key uri --value https://myserver --profile onprem
20
type configSetCommandHandler struct {
21
        StdOut         io.Writer
22
        ConfigProvider config.ConfigProvider
23
}
24

25
func (h configSetCommandHandler) Set(key string, value string, profileName string) error {
1✔
26
        cfg := h.getOrCreateProfile(profileName)
1✔
27
        err := h.setConfigValue(&cfg, key, value)
1✔
28
        if err != nil {
2✔
29
                return err
1✔
30
        }
1✔
31
        err = h.ConfigProvider.Update(profileName, cfg)
1✔
32
        if err != nil {
1✔
NEW
33
                return err
×
NEW
34
        }
×
35
        _, _ = fmt.Fprintln(h.StdOut, successfullySetMessage)
1✔
36
        return nil
1✔
37
}
38

39
func (h configSetCommandHandler) setConfigValue(cfg *config.Config, key string, value string) error {
1✔
40
        keyParts := strings.Split(key, ".")
1✔
41
        if key == "serviceVersion" {
2✔
42
                cfg.SetServiceVersion(value)
1✔
43
                return nil
1✔
44
        } else if key == "organization" {
3✔
45
                cfg.SetOrganization(value)
1✔
46
                return nil
1✔
47
        } else if key == "tenant" {
3✔
48
                cfg.SetTenant(value)
1✔
49
                return nil
1✔
50
        } else if key == "uri" {
3✔
51
                return cfg.SetUri(value)
1✔
52
        } else if key == "insecure" {
3✔
53
                insecure, err := h.convertToBool(value)
1✔
54
                if err != nil {
2✔
55
                        return fmt.Errorf("Invalid value for 'insecure': %w", err)
1✔
56
                }
1✔
57
                cfg.SetInsecure(insecure)
1✔
58
                return nil
1✔
59
        } else if key == "debug" {
2✔
60
                debug, err := h.convertToBool(value)
1✔
61
                if err != nil {
2✔
62
                        return fmt.Errorf("Invalid value for 'debug': %w", err)
1✔
63
                }
1✔
64
                cfg.SetDebug(debug)
1✔
65
                return nil
1✔
66
        } else if key == "auth.grantType" {
2✔
67
                cfg.SetAuthGrantType(value)
1✔
68
                return nil
1✔
69
        } else if key == "auth.scopes" {
3✔
70
                cfg.SetAuthScopes(value)
1✔
71
                return nil
1✔
72
        } else if h.isHeaderKey(keyParts) {
3✔
73
                cfg.SetHeader(keyParts[1], value)
1✔
74
                return nil
1✔
75
        } else if h.isParameterKey(keyParts) {
3✔
76
                cfg.SetParameter(keyParts[1], value)
1✔
77
                return nil
1✔
78
        } else if h.isAuthPropertyKey(keyParts) {
3✔
79
                cfg.SetAuthProperty(keyParts[2], value)
1✔
80
                return nil
1✔
81
        }
1✔
82
        return fmt.Errorf("Unknown config key '%s'", key)
1✔
83
}
84

85
func (h configSetCommandHandler) isHeaderKey(keyParts []string) bool {
1✔
86
        return len(keyParts) == 2 && keyParts[0] == "header"
1✔
87
}
1✔
88

89
func (h configSetCommandHandler) isParameterKey(keyParts []string) bool {
1✔
90
        return len(keyParts) == 2 && keyParts[0] == "parameter"
1✔
91
}
1✔
92

93
func (h configSetCommandHandler) isAuthPropertyKey(keyParts []string) bool {
1✔
94
        return len(keyParts) == 3 && keyParts[0] == "auth" && keyParts[1] == "properties"
1✔
95
}
1✔
96

97
func (h configSetCommandHandler) convertToBool(value string) (bool, error) {
1✔
98
        if strings.EqualFold(value, "true") {
2✔
99
                return true, nil
1✔
100
        }
1✔
101
        if strings.EqualFold(value, "false") {
1✔
NEW
102
                return false, nil
×
NEW
103
        }
×
104
        return false, fmt.Errorf("Invalid boolean value: %s", value)
1✔
105
}
106

107
func (h configSetCommandHandler) getOrCreateProfile(profileName string) config.Config {
1✔
108
        cfg := h.ConfigProvider.Config(profileName)
1✔
109
        if cfg == nil {
2✔
110
                return h.ConfigProvider.New()
1✔
111
        }
1✔
112
        return *cfg
1✔
113
}
114

115
func newConfigSetCommandHandler(
116
        stdOut io.Writer,
117
        configProvider config.ConfigProvider,
118
) *configSetCommandHandler {
1✔
119
        return &configSetCommandHandler{
1✔
120
                StdOut:         stdOut,
1✔
121
                ConfigProvider: configProvider,
1✔
122
        }
1✔
123
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc