@@ -33,6 +33,7 @@ import (
3333 "github.com/metal3-io/baremetal-operator/pkg/provisioner/demo"
3434 "github.com/metal3-io/baremetal-operator/pkg/provisioner/fixture"
3535 "github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic"
36+ starlarkprov "github.com/metal3-io/baremetal-operator/pkg/provisioner/starlark"
3637 "github.com/metal3-io/baremetal-operator/pkg/secretutils"
3738 "github.com/metal3-io/baremetal-operator/pkg/version"
3839 ironicv1alpha1 "github.com/metal3-io/ironic-standalone-operator/api/v1alpha1"
@@ -133,6 +134,7 @@ func main() {
133134 var devLogging bool
134135 var runInTestMode bool
135136 var runInDemoMode bool
137+ var starlarkScript string
136138 var webhookPort int
137139 var restConfigQPS float64
138140 var restConfigBurst int
@@ -157,6 +159,8 @@ func main() {
157159 flag .BoolVar (& runInTestMode , "test-mode" , false , "disable ironic communication" )
158160 flag .BoolVar (& runInDemoMode , "demo-mode" , false ,
159161 "use the demo provisioner to set host states" )
162+ flag .StringVar (& starlarkScript , "starlark-provisioner-script" , os .Getenv ("STARLARK_PROVISIONER_SCRIPT" ),
163+ "path to a Starlark script implementing the provisioner interface" )
160164 flag .StringVar (& healthAddr , "health-addr" , ":9440" ,
161165 "The address the health endpoint binds to." )
162166 flag .IntVar (& webhookPort , "webhook-port" , 9443 , //nolint:mnd
@@ -201,6 +205,23 @@ func main() {
201205
202206 printVersion ()
203207
208+ // At most one provisioner mode may be selected. Silently picking the
209+ // first true mode (the previous behavior) hides a misconfiguration
210+ // that would otherwise surface much later as confusing reconcile
211+ // behavior. Run this guard before any expensive setup so the operator
212+ // fails fast at startup. Enumerating the three pairwise conflicts
213+ // covers every "two or more true" combination (the all-three case
214+ // matches all three disjuncts).
215+ if (runInTestMode && runInDemoMode ) ||
216+ (runInTestMode && starlarkScript != "" ) ||
217+ (runInDemoMode && starlarkScript != "" ) {
218+ setupLog .Error (nil , "only one provisioner mode may be set" ,
219+ "test-mode" , runInTestMode ,
220+ "demo-mode" , runInDemoMode ,
221+ "starlark-provisioner-script" , starlarkScript )
222+ os .Exit (1 )
223+ }
224+
204225 enableWebhook := webhookPort != 0
205226
206227 leaderElectionNamespace := os .Getenv ("POD_NAMESPACE" )
@@ -320,6 +341,13 @@ func main() {
320341 } else if runInDemoMode {
321342 ctrl .Log .Info ("using demo provisioner" )
322343 provisionerFactory = & demo.Demo {}
344+ } else if starlarkScript != "" {
345+ ctrl .Log .Info ("using starlark provisioner" , "script" , starlarkScript )
346+ provisionerFactory , err = starlarkprov .NewProvisionerFactory (starlarkScript )
347+ if err != nil {
348+ setupLog .Error (err , "cannot start starlark provisioner" )
349+ os .Exit (1 )
350+ }
323351 } else {
324352 provLog := zap .New (zap .UseFlagOptions (& logOpts )).WithName ("provisioner" )
325353 // Check if we should use Ironic CR integration
0 commit comments