From 5dfcf252f1b3be936893515f5224d482b494c3dd Mon Sep 17 00:00:00 2001 From: Cristian Chiru Date: Thu, 28 Sep 2023 08:45:43 +0300 Subject: [PATCH] refactor keys extensions --- cmd/clusterBootstrap.go | 4 ++-- cmd/secretsBootstrap.go | 6 +++--- cmd/secretsEncryptDecrypt.go | 2 +- pkg/constants/constants.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/clusterBootstrap.go b/cmd/clusterBootstrap.go index f77b4d2..cc1674f 100644 --- a/cmd/clusterBootstrap.go +++ b/cmd/clusterBootstrap.go @@ -66,7 +66,7 @@ func RunClusterBootstrapCommand(cmd *cobra.Command, args []string) error { "--cluster-name", clusterBootstrap.parent.GetClusterContext(), "--key-path", - "cluster.sshkey.enc.pub", + "cluster.sshkey.pub", "root@10.0.0.1:@22", }, ) @@ -86,7 +86,7 @@ func RunClusterBootstrapCommand(cmd *cobra.Command, args []string) error { log.Warnf("Cluster file already exists: %s", clusterFile) } - sshKey := clusterBootstrapPath + "/cluster.sshkey.enc" + sshKey := clusterBootstrapPath + "/cluster.sshkey" if !file.IsAccessible(sshKey) { config.ViperSet(secretsCmd, secrets.KeySecretsContext(), clusterBootstrap.parent.GetClusterContext()) if err := RunBootstrapSecretsCommand( diff --git a/cmd/secretsBootstrap.go b/cmd/secretsBootstrap.go index 758d3d0..5507a4a 100644 --- a/cmd/secretsBootstrap.go +++ b/cmd/secretsBootstrap.go @@ -71,7 +71,7 @@ func init() { secretsBootstrapCmd.Flags().String( secretsBootstrap.KeyPublicKeyPath(), secretsBootstrap.DefaultPublicKeyPath(), - "Public key path", + "Public key path. Can have multiple keys separated by new lines", ) secretsBootstrapCmd.Flags().Bool( @@ -211,7 +211,7 @@ func (s *SecretsBootstrap) PatchSopsConfig() error { pubKeys := strings.Split(string(pubKeysData), "\n") filteredPubKeys := make([]string, 0, len(pubKeys)) for _, pk := range pubKeys { - pk = strings.Trim(pk, " \t") + pk = strings.TrimSpace(pk) if len(pk) > 0 { filteredPubKeys = append(filteredPubKeys, "\""+pk+"\"") } @@ -398,7 +398,7 @@ func (s *SecretsBootstrap) KeyPrivateKeyPath() string { } func (s *SecretsBootstrap) DefaultPrivateKeyPath() string { - return "secrets/" + defaults.Undefined + ".age.enc" + return "secrets/" + defaults.Undefined + ".age" } func (s *SecretsBootstrap) GetPrivateKeyPath() string { diff --git a/cmd/secretsEncryptDecrypt.go b/cmd/secretsEncryptDecrypt.go index d480204..b480f89 100644 --- a/cmd/secretsEncryptDecrypt.go +++ b/cmd/secretsEncryptDecrypt.go @@ -196,7 +196,7 @@ func (s *SecretsEncryptDecrypt) KeyPrivateKeyPath() string { } func (s *SecretsEncryptDecrypt) DefaultPrivateKeyPath() string { - return "secrets/" + defaults.Undefined + ".age.enc" + return "secrets/" + defaults.Undefined + ".age" } func (s *SecretsEncryptDecrypt) GetPrivateKeyPath() string { diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 8d675d3..6c9bf44 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -7,5 +7,5 @@ const ( Linux = "linux" Darwin = "darwin" DefaultConfigName = "kubestrap-defaults" - DefaultClusterSshKeyFileName = "cluster.sshkey.enc" + DefaultClusterSshKeyFileName = "cluster.sshkey" )