@@ -79,6 +79,10 @@ type InitOptions struct {
7979 // IgnoreValidationErrors allows for skipping the validation of provider installs.
8080 // NOTE this should only be used for development
8181 IgnoreValidationErrors bool
82+
83+ // allowMissingProviderCRD is used to allow for a missing provider CRD when listing images.
84+ // It is set to false to enforce that provider CRD is available when performing the standard init operation.
85+ allowMissingProviderCRD bool
8286}
8387
8488// Init initializes a management cluster by adding the requested list of providers.
@@ -181,6 +185,8 @@ func (c *clusterctlClient) InitImages(options InitOptions) ([]string, error) {
181185 // skip variable parsing when listing images
182186 options .skipTemplateProcess = true
183187
188+ options .allowMissingProviderCRD = true
189+
184190 // create an installer service, add the requested providers to the install queue and then perform validation
185191 // of the target state of the management cluster before starting the installation.
186192 installer , err := c .setupInstaller (clusterClient , options )
@@ -205,10 +211,7 @@ func (c *clusterctlClient) InitImages(options InitOptions) ([]string, error) {
205211func (c * clusterctlClient ) setupInstaller (cluster cluster.Client , options InitOptions ) (cluster.ProviderInstaller , error ) {
206212 installer := cluster .ProviderInstaller ()
207213
208- providerList , err := cluster .ProviderInventory ().List ()
209- if err != nil {
210- return nil , err
211- }
214+ providerList := & clusterctlv1.ProviderList {}
212215
213216 addOptions := addToInstallerOptions {
214217 installer : installer ,
@@ -217,6 +220,15 @@ func (c *clusterctlClient) setupInstaller(cluster cluster.Client, options InitOp
217220 providerList : providerList ,
218221 }
219222
223+ if ! options .allowMissingProviderCRD {
224+ providerList , err := cluster .ProviderInventory ().List ()
225+ if err != nil {
226+ return nil , err
227+ }
228+
229+ addOptions .providerList = providerList
230+ }
231+
220232 if options .CoreProvider != "" {
221233 if err := c .addToInstaller (addOptions , clusterctlv1 .CoreProviderType , options .CoreProvider ); err != nil {
222234 return nil , err
0 commit comments