mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 15:47:14 +01:00
Removed custom agent wait-for install-complete code. Moved installer WaitForInstallComplete function from cmd/openshift-install/main to cmd/openshift-install/command so that the function can be made public. Modified agent.newWaitForInstallCompleted() to use the common WaitForInstallComplete function. The benefit of moving agent over to the common WaitForInstallComplete function is that the common function has a step to wait for operators to be in a stable state before calling the cluster installation complete.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
"k8s.io/client-go/rest"
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
|
|
configclient "github.com/openshift/client-go/config/clientset/versioned"
|
|
routeclient "github.com/openshift/client-go/route/clientset/versioned"
|
|
)
|
|
|
|
// ClusterOpenShiftAPIClient Kube client using the OpenShift clientset instead of the Kubernetes clientset
|
|
type ClusterOpenShiftAPIClient struct {
|
|
ConfigClient *configclient.Clientset
|
|
RouteClient *routeclient.Clientset
|
|
ctx context.Context
|
|
config *rest.Config
|
|
configPath string
|
|
}
|
|
|
|
// NewClusterOpenShiftAPIClient Create a kube client with OCP understanding
|
|
func NewClusterOpenShiftAPIClient(ctx context.Context, kubeconfigPath string) (*ClusterOpenShiftAPIClient, error) {
|
|
ocpClient := &ClusterOpenShiftAPIClient{}
|
|
|
|
var kubeconfig *rest.Config
|
|
var err error
|
|
if kubeconfigPath != "" {
|
|
kubeconfig, err = clientcmd.BuildConfigFromFlags("", kubeconfigPath)
|
|
} else {
|
|
kubeconfig, err = rest.InClusterConfig()
|
|
}
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "creating kubeconfig for ocp config client")
|
|
}
|
|
|
|
configClient, err := configclient.NewForConfig(kubeconfig)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "creating an ocp config client")
|
|
}
|
|
|
|
routeClient, err := routeclient.NewForConfig(kubeconfig)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "creating an ocp route client")
|
|
}
|
|
|
|
ocpClient.ConfigClient = configClient
|
|
ocpClient.RouteClient = routeClient
|
|
ocpClient.ctx = ctx
|
|
ocpClient.config = kubeconfig
|
|
ocpClient.configPath = kubeconfigPath
|
|
|
|
return ocpClient, nil
|
|
}
|