Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KVM UUID Template name issue #96

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions glesys/resource_glesys_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ func getTemplate(original string, srv *glesys.ServerDetails) string {
return original
}
}
if original == srv.InitialTemplate.ID {
return original
}
return srv.Template
}

Expand Down
20 changes: 15 additions & 5 deletions glesys/resource_glesys_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
func Test_getTemplate(t *testing.T) {
srv := &glesys.ServerDetails{}
for _, tt := range []struct {
name string
tfTemplate string
readTemplate string
readTags []string
want string
name string
tfTemplate string
readTemplate string
readTemplateID string
readTags []string
want string
}{
{
name: "KVM_instance",
Expand All @@ -22,6 +23,14 @@ func Test_getTemplate(t *testing.T) {
readTags: []string{"ubuntu", "ubuntu-lts", "ubuntu-20-04"},
want: "ubuntu-20-04",
},
{
name: "KVM_instance_UUID_Template",
tfTemplate: "fc5d38f7-4c9d-4920-a3a0-3252f71fe2c5",
readTemplate: "Ubuntu 20.04 LTS (Focal Fossa)",
readTemplateID: "fc5d38f7-4c9d-4920-a3a0-3252f71fe2c5",
readTags: []string{"ubuntu", "ubuntu-lts", "ubuntu-20-04"},
want: "fc5d38f7-4c9d-4920-a3a0-3252f71fe2c5",
},
{
name: "VMware_instance",
tfTemplate: "Ubuntu 20.04 LTS 64-bit",
Expand All @@ -34,6 +43,7 @@ func Test_getTemplate(t *testing.T) {
srv.Template = tt.readTemplate
srv.InitialTemplate.Name = tt.readTemplate
srv.InitialTemplate.CurrentTags = tt.readTags
srv.InitialTemplate.ID = tt.readTemplateID
if got := getTemplate(tt.tfTemplate, srv); got != tt.want {
t.Errorf("got: %v, want %v", got, tt.want)
}
Expand Down