Skip to content

Commit

Permalink
chore: remove the built-in function for generating ssh keys (#8545)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9a5bfa9)
  • Loading branch information
leon-inf committed Nov 29, 2024
1 parent f5c28aa commit 694cf31
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 136 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/authzed/controller-idioms v0.7.0
github.com/aws/aws-sdk-go v1.50.8
github.com/bhmj/jsonslice v1.1.2
github.com/charmbracelet/keygen v0.5.1
github.com/clbanning/mxj/v2 v2.5.7
github.com/docker/docker v25.0.6+incompatible
github.com/evanphx/json-patch v5.6.0+incompatible
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chai2010/gettext-go v1.0.2 h1:1Lwwip6Q2QGsAdl/ZKPCwTe9fe0CjlUbqj5bFNSjIRk=
github.com/chai2010/gettext-go v1.0.2/go.mod h1:y+wnP2cHYaVj19NZhYKAwEMH2CI1gNHeQQ+5AjwawxA=
github.com/charmbracelet/keygen v0.5.1 h1:zBkkYPtmKDVTw+cwUyY6ZwGDhRxXkEp0Oxs9sqMLqxI=
github.com/charmbracelet/keygen v0.5.1/go.mod h1:zznJVmK/GWB6dAtjluqn2qsttiCBhA5MZSiwb80fcHw=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
55 changes: 0 additions & 55 deletions pkg/gotemplate/sshkeygenerator.go

This file was deleted.

52 changes: 0 additions & 52 deletions pkg/gotemplate/sshkeygenerator_test.go

This file was deleted.

3 changes: 0 additions & 3 deletions pkg/gotemplate/tpl_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ const (
buildInSystemFailedName = "failed"
buildInSystemImportName = "import"
buildInSystemCallName = "call"

buildInSSHKeyGeneratorString = "sshKeyGen"
)

const (
Expand Down Expand Up @@ -201,7 +199,6 @@ func (t *TplEngine) initSystemFunMap(funcs template.FuncMap) {
funcs[goTemplateExtendBuildInRegexSubString] = regexStringSubmatch
funcs[goTemplateExtendBuildInFromYamlString] = fromYAML
funcs[goTemplateExtendBuildInFromYamlArrayString] = fromYAMLArray
funcs[buildInSSHKeyGeneratorString] = sshKeyGenerate

t.tpl.Option(DefaultTemplateOps)
t.tpl.Funcs(funcs)
Expand Down
23 changes: 0 additions & 23 deletions pkg/gotemplate/tpl_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

appsv1beta1 "github.com/apecloud/kubeblocks/apis/apps/v1beta1"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
"github.com/apecloud/kubeblocks/pkg/configuration/validate"
testutil "github.com/apecloud/kubeblocks/pkg/testutil/k8s"
)

Expand Down Expand Up @@ -87,27 +85,6 @@ my friend name is test2
})
})

Context("ssh-key-generator", func() {
It("Should success with no error", func() {
tplString := `
{{- $key := sshKeyGen }}
private_key={{ $key.PrivateKey | quote }}
public_key={{ $key.PublicKey | quote }}
`

context, err := emptyTplEngine(&TplValues{
"cluster": map[string]string{"name": "cluster"},
"name": "component_name",
}, nil, tplString)
Expect(err).NotTo(HaveOccurred())

keyValue, err := validate.LoadConfigObjectFromContent(appsv1beta1.Dotenv, context)
Expect(err).NotTo(HaveOccurred())
Expect(keyValue).To(HaveKey("private_key"))
Expect(keyValue).To(HaveKey("public_key"))
})
})

// A call funcB.1 in B module
// A call funcC.1 in C module
// A call funcC.2 in C module
Expand Down

0 comments on commit 694cf31

Please sign in to comment.