@@ -2,7 +2,10 @@ package baremetal
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
7+ "os"
8+ "path/filepath"
69
710 baremetalhost "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
811 "github.com/sirupsen/logrus"
@@ -12,11 +15,13 @@ import (
1215 "k8s.io/client-go/dynamic"
1316 "k8s.io/client-go/rest"
1417 clientwatch "k8s.io/client-go/tools/watch"
18+
19+ "github.com/openshift/installer/pkg/infrastructure/baremetal"
1520)
1621
1722// WaitForBaremetalBootstrapControlPlane will watch baremetalhost resources on the bootstrap
1823// and wait for the control plane to finish provisioning.
19- func WaitForBaremetalBootstrapControlPlane (ctx context.Context , config * rest.Config ) error {
24+ func WaitForBaremetalBootstrapControlPlane (ctx context.Context , config * rest.Config , dir string ) error {
2025 client , err := dynamic .NewForConfig (config )
2126 if err != nil {
2227 return fmt .Errorf ("creating a baremetal client: %w" , err )
@@ -91,5 +96,19 @@ func WaitForBaremetalBootstrapControlPlane(ctx context.Context, config *rest.Con
9196 },
9297 )
9398
94- return err
99+ if err != nil {
100+ return err
101+ }
102+
103+ mastersJSON , err := json .Marshal (masters )
104+ if err != nil {
105+ return fmt .Errorf ("failed to marshal masters: %w" , err )
106+ }
107+
108+ err = os .WriteFile (filepath .Join (dir , baremetal .MastersFileName ), mastersJSON , 0600 )
109+ if err != nil {
110+ return fmt .Errorf ("failed to persist masters file to disk: %w" , err )
111+ }
112+
113+ return nil
95114}
0 commit comments