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

UiPath / uipathcli / 6442892572

07 Oct 2023 06:45PM UTC coverage: 67.119% (-23.3%) from 90.418%
6442892572

push

github

thschmitt
Upgrade to golang 1.21, update dependencies to latest versions

- Upgrade to golang 1.21
- Update all dependencies to latest versions

3068 of 4571 relevant lines covered (67.12%)

362.28 hits per line

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

86.67
/executor/plugin_executor.go
1
package executor
2

3
import (
4
        "errors"
5
        "net/url"
6

7
        "github.com/UiPath/uipathcli/auth"
8
        "github.com/UiPath/uipathcli/config"
9
        "github.com/UiPath/uipathcli/log"
10
        "github.com/UiPath/uipathcli/output"
11
        "github.com/UiPath/uipathcli/plugin"
12
)
13

14
// The PluginExecutor implements the Executor interface and invokes the
15
// registered plugin for the executed command.
16
// The plugin takes care of sending the HTTP request or performing other
17
// operations.
18
type PluginExecutor struct {
19
        authenticators []auth.Authenticator
20
}
21

22
func (e PluginExecutor) executeAuthenticators(baseUri url.URL, authConfig config.AuthConfig, debug bool, insecure bool) (*auth.AuthenticatorResult, error) {
22✔
23
        authRequest := *auth.NewAuthenticatorRequest(baseUri.String(), map[string]string{})
22✔
24
        ctx := *auth.NewAuthenticatorContext(authConfig.Type, authConfig.Config, debug, insecure, authRequest)
22✔
25
        for _, authProvider := range e.authenticators {
88✔
26
                result := authProvider.Auth(ctx)
66✔
27
                if result.Error != "" {
66✔
28
                        return nil, errors.New(result.Error)
×
29
                }
×
30
                ctx.Config = result.Config
66✔
31
                for k, v := range result.RequestHeader {
66✔
32
                        ctx.Request.Header[k] = v
×
33
                }
×
34
        }
35
        return auth.AuthenticatorSuccess(ctx.Request.Header, ctx.Config), nil
22✔
36
}
37

38
func (e PluginExecutor) convertToPluginParameters(parameters []ExecutionParameter) []plugin.ExecutionParameter {
22✔
39
        result := []plugin.ExecutionParameter{}
22✔
40
        for _, parameter := range parameters {
87✔
41
                param := plugin.NewExecutionParameter(parameter.Name, parameter.Value)
65✔
42
                result = append(result, *param)
65✔
43
        }
65✔
44
        return result
22✔
45
}
46

47
func (e PluginExecutor) pluginAuth(auth *auth.AuthenticatorResult) plugin.AuthResult {
22✔
48
        return plugin.AuthResult{
22✔
49
                Header: auth.RequestHeader,
22✔
50
        }
22✔
51
}
22✔
52

53
func (e PluginExecutor) Call(context ExecutionContext, writer output.OutputWriter, logger log.Logger) error {
22✔
54
        auth, err := e.executeAuthenticators(context.BaseUri, context.AuthConfig, context.Debug, context.Insecure)
22✔
55
        if err != nil {
22✔
56
                return err
×
57
        }
×
58

59
        pluginAuth := e.pluginAuth(auth)
22✔
60
        pluginParams := e.convertToPluginParameters(context.Parameters)
22✔
61
        pluginContext := plugin.NewExecutionContext(
22✔
62
                context.Organization,
22✔
63
                context.Tenant,
22✔
64
                context.BaseUri,
22✔
65
                pluginAuth,
22✔
66
                context.Input,
22✔
67
                pluginParams,
22✔
68
                context.Insecure,
22✔
69
                context.Debug)
22✔
70
        return context.Plugin.Execute(*pluginContext, writer, logger)
22✔
71
}
72

73
func NewPluginExecutor(authenticators []auth.Authenticator) *PluginExecutor {
39✔
74
        return &PluginExecutor{authenticators}
39✔
75
}
39✔
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

© 2025 Coveralls, Inc