-
Notifications
You must be signed in to change notification settings - Fork 30
/
convert_pipeline.go
44 lines (40 loc) · 1.08 KB
/
convert_pipeline.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
package importcmd
import (
"os"
"path/filepath"
"github.com/jenkins-x/jx-helpers/v3/pkg/cmdrunner"
"github.com/pkg/errors"
)
// convertOldPipeline converts the old pipeline and returns true if it was converted
func (o *ImportOptions) convertOldPipeline() (bool, error) {
if !o.BatchMode {
flag, err := o.Input.Confirm("Convert the old jenkins-x.yml file to the new tekton yaml?: ", true, "please confirm you wish to convert the pipeline")
if err != nil {
return flag, errors.Wrapf(err, "failed to conform conversion")
}
if !flag {
return false, nil
}
}
dir, err := filepath.Abs(o.Dir)
if err != nil {
return false, errors.Wrapf(err, "failed to get absolute dir of %s", o.Dir)
}
args := []string{"pipeline", "convert", "--dir", dir}
if o.BatchMode {
args = append(args, "--batch-mode")
}
c := &cmdrunner.Command{
Dir: dir,
Name: "jx",
Args: args,
Out: os.Stdout,
Err: os.Stderr,
In: os.Stdin,
}
_, err = o.CommandRunner(c)
if err != nil {
return false, errors.Wrapf(err, "failed to convert old pipeline via %s", c.CLI())
}
return true, nil
}