File tree Expand file tree Collapse file tree 3 files changed +7
-17
lines changed Expand file tree Collapse file tree 3 files changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ import (
10
10
11
11
func Builder () * cobra.Command {
12
12
o := & cli.BaseOpts {
13
- Fs : afero .NewOsFs (),
14
- Converter : cli . ConvertFunc ( convert .AdvancedClusterToNew ) ,
13
+ Fs : afero .NewOsFs (),
14
+ Convert : convert .AdvancedClusterToNew ,
15
15
}
16
16
cmd := & cobra.Command {
17
17
Use : "advancedClusterToNew" ,
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ func Builder() *cobra.Command {
17
17
Fs : afero .NewOsFs (),
18
18
},
19
19
}
20
- o .Converter = cli . ConvertFunc ( func (config []byte ) ([]byte , error ) {
20
+ o .Convert = func (config []byte ) ([]byte , error ) {
21
21
return convert .ClusterToAdvancedCluster (config , o .includeMoved )
22
- })
22
+ }
23
23
cmd := & cobra.Command {
24
24
Use : "clusterToAdvancedCluster" ,
25
25
Short : "Convert cluster to advanced_cluster preview provider 2.0.0" ,
Original file line number Diff line number Diff line change @@ -9,22 +9,12 @@ import (
9
9
"github.com/spf13/afero"
10
10
)
11
11
12
- // Converter defines the interface for different conversion functions.
13
- type Converter interface {
14
- Convert (config []byte ) ([]byte , error )
15
- }
16
-
17
- // ConvertFunc is a function type that implements the Converter interface.
18
- type ConvertFunc func (config []byte ) ([]byte , error )
19
-
20
- func (f ConvertFunc ) Convert (config []byte ) ([]byte , error ) {
21
- return f (config )
22
- }
12
+ type ConvertFn func (config []byte ) ([]byte , error )
23
13
24
14
// BaseOpts contains common functionality for CLI commands that convert files.
25
15
type BaseOpts struct {
26
16
Fs afero.Fs
27
- Converter Converter
17
+ Convert ConvertFn
28
18
File string
29
19
Output string
30
20
ReplaceOutput bool
@@ -60,7 +50,7 @@ func (o *BaseOpts) generateFile(allowParseErrors bool) error {
60
50
return fmt .Errorf ("failed to read file %s: %w" , o .File , err )
61
51
}
62
52
63
- outConfig , err := o .Converter . Convert (inConfig )
53
+ outConfig , err := o .Convert (inConfig )
64
54
if err != nil {
65
55
if allowParseErrors {
66
56
outConfig = []byte ("# CONVERT ERROR: " + err .Error () + "\n \n " )
You can’t perform that action at this time.
0 commit comments