Skip to content

Commit 1f12718

Browse files
Merge pull request #9 from codefresh-io/SAAS-8076
support inCluster config
2 parents ff47677 + 99c6602 commit 1f12718

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.2
1+
1.4.3

pkg/kubernetes/kubernetes.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
log "github.com/sirupsen/logrus"
99
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1010
kubeConfig "k8s.io/client-go/kubernetes"
11+
"k8s.io/client-go/rest"
1112
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
1213
"k8s.io/client-go/tools/clientcmd"
1314
"k8s.io/client-go/tools/clientcmd/api"
@@ -55,7 +56,12 @@ func goOverContext(options *getOverContextOptions) error {
5556
if e != nil {
5657
message := fmt.Sprintf("Failed to create config with error:\n%s", e)
5758
options.logger.Warn(message)
58-
return e
59+
clientCnf, e = rest.InClusterConfig()
60+
if e != nil {
61+
message = fmt.Sprintf("Failed to create in cluster config with error:\n%s", e)
62+
options.logger.Warn(message)
63+
return e
64+
}
5965
}
6066
options.logger.Info("Created config for context")
6167
host = clientCnf.Host
@@ -65,6 +71,7 @@ func goOverContext(options *getOverContextOptions) error {
6571
if e != nil {
6672
message := fmt.Sprintf("Failed to create kubernetes client with error:\n%s", e)
6773
options.logger.Warn(message)
74+
6875
return e
6976
}
7077
options.logger.Info("Created client set for context")

0 commit comments

Comments
 (0)