From d0e119c94c4da0e4564e8ec34e7ccecf11dc839f Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Fri, 21 Aug 2020 15:28:20 +0200 Subject: [PATCH] fix(action/plugin-kubernetes): improve error when .kube directory already exists Signed-off-by: Yvonnick Esnault --- contrib/integrations/kubernetes/plugin-kubernetes/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/integrations/kubernetes/plugin-kubernetes/main.go b/contrib/integrations/kubernetes/plugin-kubernetes/main.go index cbb3754ee3..23bdb3513c 100644 --- a/contrib/integrations/kubernetes/plugin-kubernetes/main.go +++ b/contrib/integrations/kubernetes/plugin-kubernetes/main.go @@ -120,6 +120,10 @@ contexts: name: default-context current-context: default-context`, k8sToken, certb64, k8sAPIURL) + if _, err := os.Stat(".kube"); !os.IsNotExist(err) { + return fail(".kube directory already exists, you have to delete it before using this action") + } + if err := os.Mkdir(".kube", 0755); err != nil { return fail("Cannot create directory .kube : %v", err) }