diff --git a/internal/server/conv.go b/internal/server/conv.go index db725a6..9efdfc4 100644 --- a/internal/server/conv.go +++ b/internal/server/conv.go @@ -9,6 +9,14 @@ import ( "github.com/projecteru2/yavirt/internal/models" ) +func convGuestIDsResp(localIDs []string) []string { + eruIDs := make([]string, len(localIDs)) + for i, id := range localIDs { + eruIDs[i] = types.EruID(id) + } + return eruIDs +} + func convGuestResp(g *models.Guest) (resp *types.Guest) { resp = &types.Guest{} resp.ID = types.EruID(g.ID) diff --git a/internal/server/service.go b/internal/server/service.go index 30f7e40..24bae25 100644 --- a/internal/server/service.go +++ b/internal/server/service.go @@ -171,7 +171,7 @@ func (svc *Service) GetGuestIDList(ctx virt.Context) ([]string, error) { metrics.IncrError() return nil, err } - return ids, err + return convGuestIDsResp(ids), err } // GetGuestUUID . diff --git a/internal/server/service_test.go b/internal/server/service_test.go index 27ddb2d..fa940cb 100644 --- a/internal/server/service_test.go +++ b/internal/server/service_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + "github.com/projecteru2/libyavirt/types" "github.com/projecteru2/yavirt/internal/models" "github.com/projecteru2/yavirt/internal/virt" vg "github.com/projecteru2/yavirt/internal/virt/guest" @@ -55,9 +56,12 @@ func TestGetGuestIDList(t *testing.T) { localIDs := []string{"ya0", "ya1", "ya2"} svc := testService(t) svc.guest.(*managerocks.Manageable).On("ListLocalIDs", mock.Anything, mock.Anything).Return(localIDs, nil).Once() + ids, err := svc.GetGuestIDList(testVirtContext(t)) assert.NilErr(t, err) - assert.Equal(t, []string{"ya0", "ya1", "ya2"}, ids) + + eruIDs := []string{types.EruID("ya0"), types.EruID("ya1"), types.EruID("ya2")} + assert.Equal(t, eruIDs, ids) } func TestGetGuestUUID(t *testing.T) { diff --git a/internal/virt/guest/guest_copy_file.go b/internal/virt/guest/guest_copy_file.go index 1ba39b5..7d4314f 100644 --- a/internal/virt/guest/guest_copy_file.go +++ b/internal/virt/guest/guest_copy_file.go @@ -1,7 +1,7 @@ package guest import ( - "context" //nolint + "context" "os" "path" diff --git a/pkg/sh/shx.go b/pkg/sh/shx.go index 7ab2b4e..f0aeed3 100644 --- a/pkg/sh/shx.go +++ b/pkg/sh/shx.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io" //nolint + "io" "os/exec" "github.com/projecteru2/yavirt/pkg/errors"