From 2d5d1890d4ac5b445f197d723c5eda3a0e5beaff Mon Sep 17 00:00:00 2001 From: Tom Carrio Date: Fri, 20 Jul 2018 08:29:53 -0400 Subject: [PATCH] Switching sort method --- builder/openstack/image_query.go | 6 ++++-- builder/openstack/image_query_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/openstack/image_query.go b/builder/openstack/image_query.go index c6772a1aa..b07e77510 100644 --- a/builder/openstack/image_query.go +++ b/builder/openstack/image_query.go @@ -8,7 +8,8 @@ import ( ) const ( - mostRecentSort = "created_at:desc" + mostRecentSortDir = "desc" + mostRecentSortKey = "created_at" ) var validFields = map[string]string{ @@ -99,7 +100,8 @@ func buildImageFilters(input map[string]interface{}, listOpts *images.ListOpts) func applyMostRecent(listOpts *images.ListOpts) { // Sort isn't supported through our API so there should be no existing values. // Overwriting .Sort is okay. - listOpts.Sort = mostRecentSort + listOpts.SortKey = mostRecentSortKey + listOpts.SortDir = mostRecentSortDir listOpts.Limit = 1 return diff --git a/builder/openstack/image_query_test.go b/builder/openstack/image_query_test.go index d1731ecf2..58382750f 100644 --- a/builder/openstack/image_query_test.go +++ b/builder/openstack/image_query_test.go @@ -78,7 +78,7 @@ func TestApplyMostRecent(t *testing.T) { applyMostRecent(&testSortOpts) - if testSortOpts.Sort != "created_at:desc" { + if testSortOpts.SortKey != "created_at" || testSortOpts.SortDir != "desc" { t.Errorf("Error applying most recent filter: sort") } }