-
Notifications
You must be signed in to change notification settings - Fork 786
/
edit_app_jenkins_plugins.go
82 lines (69 loc) · 2.14 KB
/
edit_app_jenkins_plugins.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package edit
import (
"github.com/jenkins-x/jx-logging/pkg/log"
"github.com/jenkins-x/jx/v2/pkg/auth"
"github.com/jenkins-x/jx/v2/pkg/cmd/helper"
"github.com/jenkins-x/jx/v2/pkg/cmd/opts"
"github.com/jenkins-x/jx/v2/pkg/cmd/templates"
"github.com/jenkins-x/jx/v2/pkg/jenkins"
"github.com/jenkins-x/jx/v2/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
editAppJenkinsPluginsLong = templates.LongDesc(`
Edits a Jenkins App's plugins
`)
editAppJenkinsPluginsExample = templates.Examples(`
# Edits the plugins for a Jenkins App
jx edit app jenkins plugins
`)
)
// EditAppJenkinsPluginsOptions the options for the create spring command
type EditAppJenkinsPluginsOptions struct {
EditOptions
Name string
Enabled string
IssuesAuthConfigSvc auth.ConfigService
}
// NewCmdEditAppJenkinsPlugins creates a command object for the "create" command
func NewCmdEditAppJenkinsPlugins(commonOpts *opts.CommonOptions) *cobra.Command {
options := &EditAppJenkinsPluginsOptions{
EditOptions: EditOptions{
CommonOptions: commonOpts,
},
}
cmd := &cobra.Command{
Use: "app jenkins plugins",
Short: "Edits the Jenkins Plugins for a Jenkins App",
Long: editAppJenkinsPluginsLong,
Example: editAppJenkinsPluginsExample,
Run: func(cmd *cobra.Command, args []string) {
options.Cmd = cmd
options.Args = args
err := options.Run()
helper.CheckErr(err)
},
}
cmd.Flags().StringVarP(&options.Enabled, optionEnabled, "e", "", "Enables or disables the addon")
return cmd
}
// Run implements the command
func (o *EditAppJenkinsPluginsOptions) Run() error {
data, err := jenkins.LoadUpdateCenterURL(jenkins.DefaultUpdateCenterURL)
if err != nil {
return errors.Wrapf(err, "failed to load URL %s", jenkins.DefaultUpdateCenterURL)
}
// TODO load from the GitOps values.yaml folder
currentValues := []string{"jx-resources:1.0.0"}
selection, err := data.PickPlugins(currentValues, o.GetIOFileHandles())
if err != nil {
return err
}
log.Logger().Infof("chosen selection:")
for _, sel := range selection {
log.Logger().Infof(" %s", util.ColorInfo(sel))
}
// TODO update the GitOps values.yaml folder
return nil
}