From cfde1171675f0c7b2d09cc09f88ee766f65afdc1 Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Mon, 15 Nov 2021 09:16:22 +0000 Subject: [PATCH 1/2] [installer]: validate external container registry and cloudsql secrets --- installer/pkg/config/v1/validation.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/installer/pkg/config/v1/validation.go b/installer/pkg/config/v1/validation.go index c192bc6b6b56e2..a8057fc855b3b8 100644 --- a/installer/pkg/config/v1/validation.go +++ b/installer/pkg/config/v1/validation.go @@ -77,5 +77,15 @@ func (v version) ClusterValidation(rcfg interface{}) cluster.ValidationChecks { res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("service-account.json"))) } + if cfg.ContainerRegistry.External != nil { + secretName := cfg.ContainerRegistry.External.Certificate.Name + res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData(".dockerconfigjson"))) + } + + if cfg.Database.CloudSQL != nil { + secretName := cfg.Database.CloudSQL.ServiceAccount.Name + res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("credentials.json", "encryptionKeys", "password", "username"))) + } + return res } From 4ac29cd4e97bb29c9834a95c07e73cdd9831af49 Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Mon, 15 Nov 2021 09:56:41 +0000 Subject: [PATCH 2/2] [installer]: change validation status if the cluster config validation fails --- installer/cmd/validate-cluster.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/installer/cmd/validate-cluster.go b/installer/cmd/validate-cluster.go index b05360e3424953..08b1cc6b9e5f0a 100644 --- a/installer/cmd/validate-cluster.go +++ b/installer/cmd/validate-cluster.go @@ -55,6 +55,18 @@ var validateClusterCmd = &cobra.Command{ return err } + // Update the status + switch res.Status { + case cluster.ValidationStatusError: + // Always change the status if error + result.Status = cluster.ValidationStatusError + case cluster.ValidationStatusWarning: + // Only put to warning if status is ok + if result.Status == cluster.ValidationStatusOk { + result.Status = cluster.ValidationStatusWarning + } + } + result.Items = append(result.Items, res.Items...) }