Skip to content

Commit 96b710c

Browse files
Merge pull request openshift#8715 from rwsu/AGENT-922
AGENT-922: Remove misleading inClusterConfig warning
2 parents 2623fb6 + 5aa318c commit 96b710c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pkg/agent/kube.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ type ClusterKubeAPIClient struct {
2727
func NewClusterKubeAPIClient(ctx context.Context, kubeconfigPath string) (*ClusterKubeAPIClient, error) {
2828
kubeClient := &ClusterKubeAPIClient{}
2929

30-
kubeconfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
30+
var kubeconfig *rest.Config
31+
var err error
32+
if kubeconfigPath != "" {
33+
kubeconfig, err = clientcmd.BuildConfigFromFlags("", kubeconfigPath)
34+
} else {
35+
kubeconfig, err = rest.InClusterConfig()
36+
}
3137
if err != nil {
3238
return nil, errors.Wrap(err, "error loading kubeconfig from assets")
3339
}

pkg/agent/ocp.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ const (
3636
func NewClusterOpenShiftAPIClient(ctx context.Context, kubeconfigPath string) (*ClusterOpenShiftAPIClient, error) {
3737
ocpClient := &ClusterOpenShiftAPIClient{}
3838

39-
kubeconfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
39+
var kubeconfig *rest.Config
40+
var err error
41+
if kubeconfigPath != "" {
42+
kubeconfig, err = clientcmd.BuildConfigFromFlags("", kubeconfigPath)
43+
} else {
44+
kubeconfig, err = rest.InClusterConfig()
45+
}
4046
if err != nil {
4147
return nil, errors.Wrap(err, "creating kubeconfig for ocp config client")
4248
}
@@ -58,7 +64,6 @@ func NewClusterOpenShiftAPIClient(ctx context.Context, kubeconfigPath string) (*
5864
ocpClient.configPath = kubeconfigPath
5965

6066
return ocpClient, nil
61-
6267
}
6368

6469
// AreClusterOperatorsInitialized Waits for all Openshift cluster operators to initialize
@@ -104,7 +109,6 @@ func (ocp *ClusterOpenShiftAPIClient) IsConsoleRouteAvailable() (bool, error) {
104109
}
105110
}
106111
return false, errors.Wrap(err, "Waiting for openshift-console route")
107-
108112
}
109113

110114
// IsConsoleRouteURLAvailable Check if the console route URL is available

0 commit comments

Comments
 (0)