Skip to content

Commit

Permalink
move generate func
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-sakamoto committed Jun 16, 2024
1 parent cce66d7 commit a9236c8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cloudinit/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type WriteFile struct {
Permissions string `yaml:"permissions,omitempty"`
}

func Generate(c Config, vars map[string]string) (string, error) {
func (c *Config) Generate(vars map[string]string) (string, error) {
buff := &bytes.Buffer{}
if err := yaml.NewEncoder(buff).Encode(c); err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudinit/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestGenerate(t *testing.T) {
result, err := cloudinit.Generate(cloudinit.Config{
result, err := (&cloudinit.Config{
Packages: []string{
"git",
"vim",
Expand All @@ -28,7 +28,7 @@ func TestGenerate(t *testing.T) {
RunCmds: []string{
"/use/bin/ok",
},
}, map[string]string{
}).Generate(map[string]string{
"Content": "content",
})
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioner/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func LaunchInstance(clusterName string, config InstanceConfig, cloudinitConfig c
return "", fmt.Errorf("instance already exists: %s", instanceName)
}

template, err := cloudinit.Generate(cloudinitConfig, map[string]string{
template, err := cloudinitConfig.Generate(map[string]string{
"KubernetesVersion": config.K8sVersion,
"Arch": "amd64",
})
Expand Down

0 comments on commit a9236c8

Please sign in to comment.