func (c *clusterctlClient) Init(options InitOptions) ([]Components, error) {
	log := logf.Log

	// gets access to the management cluster
	clusterClient, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: options.Kubeconfig})
	if err != nil {
		return nil, err
	}

	// ensure the custom resource definitions required by clusterctl are in place
	if err := clusterClient.ProviderInventory().EnsureCustomResourceDefinitions(); err != nil {
		return nil, err
	}

	// Ensure this command only runs against v1alpha4 management clusters
	if err := clusterClient.ProviderInventory().CheckCAPIContract(cluster.AllowCAPINotInstalled{}); err != nil {
		return nil, err
	}

	// checks if the cluster already contains a Core provider.
	// if not we consider this the first time init is executed, and thus we enforce the installation of a core provider,
	// a bootstrap provider and a control-plane provider (if not already explicitly requested by the user)
	log.Info("Fetching providers")
	firstRun := c.addDefaultProviders(clusterClient, &options)

	// create an installer service, add the requested providers to the install queue and then perform validation
	// of the target state of the management cluster before starting the installation.
	installer, err := c.setupInstaller(clusterClient, options)
	if err != nil {
		return nil, err
	}

	// Before installing the providers, validates the management cluster resulting by the planned installation. The following checks are performed:
	// - There should be only one instance of the same provider per namespace.
	// - Instances of the same provider should not be fighting for objects (no watching overlap).
	// - Providers combines in valid management groups
	//   - All the providers should belong to one/only one management groups
	//   - All the providers in a management group must support the same API Version of Cluster API (contract)
	if err := installer.Validate(); err != nil {
		return nil, err
	}

	// Before installing the providers, ensure the cert-manager Webhook is in place.
	certManager, err := clusterClient.CertManager()
	if err != nil {
		return nil, err
	}

	if err := certManager.EnsureInstalled(); err != nil {
		return nil, err
	}

	components, err := installer.Install()
	if err != nil {
		return nil, err
	}

	// If this is the firstRun, then log the usage instructions.
	if firstRun && options.LogUsageInstructions {
		log.Info("")
		log.Info("Your management cluster has been initialized successfully!")
		log.Info("")
		log.Info("You can now create your first workload cluster by running the following:")
		log.Info("")
		log.Info("  clusterctl config cluster [name] --kubernetes-version [version] | kubectl apply -f -")
		log.Info("")
	}

	// Components is an alias for repository.Components; this makes the conversion from the two types
	aliasComponents := make([]Components, len(components))
	for i, components := range components {
		aliasComponents[i] = components
	}
	return aliasComponents, nil
}
// Init initializes a management cluster by adding the requested list of providers.
Init initializes a management cluster by adding the requested list of providers.
// Init initializes a management cluster by adding the requested list of providers .
func (c *clusterctlClient) Init(options InitOptions) ([]Components, error) {
	log := logf.Log
	clusterClient, err := c.clusterClientFactory(ClusterClientFactoryInput{Kubeconfig: options.Kubeconfig})
	if err != nil {
		return nil, err
	}
	if err := clusterClient.ProviderInventory().EnsureCustomResourceDefinitions(); err != nil {
		return nil, err
	}
	if err := clusterClient.ProviderInventory().CheckCAPIContract(cluster.AllowCAPINotInstalled{}); err != nil {
		return nil, err
	}
	log.Info("Fetching providers")
	firstRun := c.addDefaultProviders(clusterClient, &options)
	installer, err := c.setupInstaller(clusterClient, options)
	if err != nil {
		return nil, err
	}
	if err := installer.Validate(); err != nil {
		return nil, err
	}
	certManager, err := clusterClient.CertManager()
	if err != nil {
		return nil, err
	}
	if err := certManager.EnsureInstalled(); err != nil {
		return nil, err
	}
	components, err := installer.Install()
	if err != nil {
		return nil, err
	}
	if firstRun && options.LogUsageInstructions {
		log.Info("")
		log.Info("Your management cluster has been initialized successfully!")
		log.Info("")
		log.Info("You can now create your first workload cluster by running the following:")
		log.Info("")
		log.Info("  clusterctl config cluster [name] --kubernetes-version [version] | kubectl apply -f -")
		log.Info("")
	}
	aliasComponents := make([]Components, len(components))
	for i, components := range components {
		aliasComponents[i] = components
	}
	return aliasComponents, nil
}
func ( c * clusterctlClient ) Init ( options InitOptions ) ( [ ] Components , error ) { log := logf . Log clusterClient , err := c . clusterClientFactory ( ClusterClientFactoryInput { Kubeconfig : options . Kubeconfig } ) if err != nil { return nil , err } if err := clusterClient . ProviderInventory ( ) . EnsureCustomResourceDefinitions ( ) ; err != nil { return nil , err } if err := clusterClient . ProviderInventory ( ) . CheckCAPIContract ( cluster . AllowCAPINotInstalled { } ) ; err != nil { return nil , err } log . Info ( " " ) firstRun := c . addDefaultProviders ( clusterClient , & options ) installer , err := c . setupInstaller ( clusterClient , options ) if err != nil { return nil , err } if err := installer . Validate ( ) ; err != nil { return nil , err } certManager , err := clusterClient . CertManager ( ) if err != nil { return nil , err } if err := certManager . EnsureInstalled ( ) ; err != nil { return nil , err } components , err := installer . Install ( ) if err != nil { return nil , err } if firstRun && options . LogUsageInstructions { log . Info ( " " ) log . Info ( " " ) log . Info ( " " ) log . Info ( " " ) log . Info ( " " ) log . Info ( " " ) log . Info ( " " ) } aliasComponents := make ( [ ] Components , len ( components ) ) for i , components := range components { aliasComponents [ i ] = components } return aliasComponents , nil }
Init initializes a management cluster by adding the requested list of providers.
Init initializes a management cluster by adding the requested list of providers .
// gets access to the management cluster // ensure the custom resource definitions required by clusterctl are in place // Ensure this command only runs against v1alpha4 management clusters // checks if the cluster already contains a Core provider. // if not we consider this the first time init is executed, and thus we enforce the installation of a core provider, // a bootstrap provider and a control-plane provider (if not already explicitly requested by the user) // create an installer service, add the requested providers to the install queue and then perform validation // of the target state of the management cluster before starting the installation. // Before installing the providers, validates the management cluster resulting by the planned installation. The following checks are performed: // - There should be only one instance of the same provider per namespace. // - Instances of the same provider should not be fighting for objects (no watching overlap). // - Providers combines in valid management groups //   - All the providers should belong to one/only one management groups //   - All the providers in a management group must support the same API Version of Cluster API (contract) // Before installing the providers, ensure the cert-manager Webhook is in place. // If this is the firstRun, then log the usage instructions. // Components is an alias for repository.Components; this makes the conversion from the two types