@@ -17,6 +17,9 @@ limitations under the License.
17
17
package scaffolds
18
18
19
19
import (
20
+ "fmt"
21
+ "strings"
22
+
20
23
log "github.com/sirupsen/logrus"
21
24
"github.com/spf13/afero"
22
25
"sigs.k8s.io/kubebuilder/v3/pkg/config"
@@ -71,6 +74,20 @@ func (s *initScaffolder) InjectFS(fs machinery.Filesystem) {
71
74
s .fs = fs
72
75
}
73
76
77
+ // getControllerRuntimeReleaseBranch converts the ControllerRuntime semantic versioning string to a
78
+ // release branch string. Example input: "v0.17.0" -> Output: "release-0.17"
79
+ func getControllerRuntimeReleaseBranch () string {
80
+ v := strings .TrimPrefix (ControllerRuntimeVersion , "v" )
81
+ tmp := strings .Split (v , "." )
82
+
83
+ if len (tmp ) < 2 {
84
+ fmt .Println ("Invalid version format. Expected at least major and minor version numbers." )
85
+ return ""
86
+ }
87
+ releaseBranch := fmt .Sprintf ("release-%s.%s" , tmp [0 ], tmp [1 ])
88
+ return releaseBranch
89
+ }
90
+
74
91
// Scaffold implements cmdutil.Scaffolder
75
92
func (s * initScaffolder ) Scaffold () error {
76
93
log .Println ("Writing scaffold for you to edit..." )
@@ -136,6 +153,7 @@ func (s *initScaffolder) Scaffold() error {
136
153
ControllerToolsVersion : ControllerToolsVersion ,
137
154
KustomizeVersion : kustomizeVersion ,
138
155
ControllerRuntimeVersion : ControllerRuntimeVersion ,
156
+ EnvtestVersion : getControllerRuntimeReleaseBranch (),
139
157
},
140
158
& templates.Dockerfile {},
141
159
& templates.DockerIgnore {},
0 commit comments