-
Notifications
You must be signed in to change notification settings - Fork 51
/
requirement.go
36 lines (33 loc) · 1.45 KB
/
requirement.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
package requirement
import (
"github.com/jenkins-x-plugins/jx-gitops/pkg/cmd/requirement/edit"
"github.com/jenkins-x-plugins/jx-gitops/pkg/cmd/requirement/merge"
"github.com/jenkins-x-plugins/jx-gitops/pkg/cmd/requirement/publish"
"github.com/jenkins-x-plugins/jx-gitops/pkg/cmd/requirement/resolve"
"github.com/jenkins-x/jx-helpers/v3/pkg/cobras"
"github.com/jenkins-x/jx-helpers/v3/pkg/cobras/helper"
"github.com/jenkins-x/jx-logging/v3/pkg/log"
"github.com/spf13/cobra"
)
var requirementRetriableErrors = []string{
"dial tcp \\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d+: i/o timeout",
}
// NewCmdRequirement creates the new command
func NewCmdRequirement() *cobra.Command {
command := &cobra.Command{
Use: "requirement",
Short: "Commands for working with jx-requirements.yml",
Aliases: []string{"req", "requirements"},
Run: func(command *cobra.Command, args []string) {
err := command.Help()
if err != nil {
log.Logger().Errorf(err.Error())
}
},
}
command.AddCommand(cobras.SplitCommand(edit.NewCmdRequirementsEdit()))
command.AddCommand(helper.RetryOnErrorCommand(cobras.SplitCommand(merge.NewCmdRequirementsMerge()), helper.RegexRetryFunction(requirementRetriableErrors)))
command.AddCommand(helper.RetryOnErrorCommand(cobras.SplitCommand(resolve.NewCmdRequirementsResolve()), helper.RegexRetryFunction(requirementRetriableErrors)))
command.AddCommand(cobras.SplitCommand(publish.NewCmdRequirementsPublish()))
return command
}