From 81e47da354c5e7809510a9d59afc3b311073ff8b Mon Sep 17 00:00:00 2001 From: Antoine Pelisse Date: Mon, 19 Mar 2018 10:53:04 -0700 Subject: [PATCH] Move predicates and unstructpath to path And rename unstructpath to selectors, since the package only contains selectors now. The name of types in the selectors package could be improved now that the package name is more specific. --- .../{ => path}/predicates/interface.go | 0 .../{ => path}/predicates/interface_test.go | 2 +- pkg/framework/{ => path}/predicates/map.go | 0 .../{ => path}/predicates/map_test.go | 2 +- pkg/framework/{ => path}/predicates/number.go | 0 .../{ => path}/predicates/number_test.go | 2 +- pkg/framework/{ => path}/predicates/slice.go | 0 .../{ => path}/predicates/slice_test.go | 2 +- pkg/framework/{ => path}/predicates/string.go | 0 .../{ => path}/predicates/string_test.go | 2 +- .../{unstructpath => path/selectors}/doc.go | 4 ++-- .../selectors}/example_test.go | 4 ++-- .../selectors}/interfacef.go | 4 ++-- .../selectors}/interfaces.go | 4 ++-- .../selectors}/interfaces_test.go | 24 +++++++++---------- .../{unstructpath => path/selectors}/mapf.go | 4 ++-- .../{unstructpath => path/selectors}/maps.go | 4 ++-- .../selectors}/numbers.go | 4 ++-- .../selectors}/numbers_test.go | 6 ++--- .../selectors}/slicef.go | 4 ++-- .../selectors}/slices.go | 4 ++-- .../selectors}/strings.go | 4 ++-- .../selectors}/strings_test.go | 6 ++--- 23 files changed, 43 insertions(+), 43 deletions(-) rename pkg/framework/{ => path}/predicates/interface.go (100%) rename pkg/framework/{ => path}/predicates/interface_test.go (98%) rename pkg/framework/{ => path}/predicates/map.go (100%) rename pkg/framework/{ => path}/predicates/map_test.go (98%) rename pkg/framework/{ => path}/predicates/number.go (100%) rename pkg/framework/{ => path}/predicates/number_test.go (98%) rename pkg/framework/{ => path}/predicates/slice.go (100%) rename pkg/framework/{ => path}/predicates/slice_test.go (98%) rename pkg/framework/{ => path}/predicates/string.go (100%) rename pkg/framework/{ => path}/predicates/string_test.go (98%) rename pkg/framework/{unstructpath => path/selectors}/doc.go (89%) rename pkg/framework/{unstructpath => path/selectors}/example_test.go (97%) rename pkg/framework/{unstructpath => path/selectors}/interfacef.go (97%) rename pkg/framework/{unstructpath => path/selectors}/interfaces.go (98%) rename pkg/framework/{unstructpath => path/selectors}/interfaces_test.go (86%) rename pkg/framework/{unstructpath => path/selectors}/mapf.go (96%) rename pkg/framework/{unstructpath => path/selectors}/maps.go (97%) rename pkg/framework/{unstructpath => path/selectors}/numbers.go (96%) rename pkg/framework/{unstructpath => path/selectors}/numbers_test.go (93%) rename pkg/framework/{unstructpath => path/selectors}/slicef.go (96%) rename pkg/framework/{unstructpath => path/selectors}/slices.go (97%) rename pkg/framework/{unstructpath => path/selectors}/strings.go (96%) rename pkg/framework/{unstructpath => path/selectors}/strings_test.go (93%) diff --git a/pkg/framework/predicates/interface.go b/pkg/framework/path/predicates/interface.go similarity index 100% rename from pkg/framework/predicates/interface.go rename to pkg/framework/path/predicates/interface.go diff --git a/pkg/framework/predicates/interface_test.go b/pkg/framework/path/predicates/interface_test.go similarity index 98% rename from pkg/framework/predicates/interface_test.go rename to pkg/framework/path/predicates/interface_test.go index cba21b28e..15f5439dd 100644 --- a/pkg/framework/predicates/interface_test.go +++ b/pkg/framework/path/predicates/interface_test.go @@ -19,7 +19,7 @@ package predicates_test import ( "testing" - . "k8s.io/kubectl/pkg/framework/predicates" + . "k8s.io/kubectl/pkg/framework/path/predicates" ) type InterfaceTrue struct{} diff --git a/pkg/framework/predicates/map.go b/pkg/framework/path/predicates/map.go similarity index 100% rename from pkg/framework/predicates/map.go rename to pkg/framework/path/predicates/map.go diff --git a/pkg/framework/predicates/map_test.go b/pkg/framework/path/predicates/map_test.go similarity index 98% rename from pkg/framework/predicates/map_test.go rename to pkg/framework/path/predicates/map_test.go index 34baa5a6a..571b89b6f 100644 --- a/pkg/framework/predicates/map_test.go +++ b/pkg/framework/path/predicates/map_test.go @@ -19,7 +19,7 @@ package predicates_test import ( "testing" - . "k8s.io/kubectl/pkg/framework/predicates" + . "k8s.io/kubectl/pkg/framework/path/predicates" ) type MapTrue struct{} diff --git a/pkg/framework/predicates/number.go b/pkg/framework/path/predicates/number.go similarity index 100% rename from pkg/framework/predicates/number.go rename to pkg/framework/path/predicates/number.go diff --git a/pkg/framework/predicates/number_test.go b/pkg/framework/path/predicates/number_test.go similarity index 98% rename from pkg/framework/predicates/number_test.go rename to pkg/framework/path/predicates/number_test.go index b4e78347a..8bdfdd329 100644 --- a/pkg/framework/predicates/number_test.go +++ b/pkg/framework/path/predicates/number_test.go @@ -20,7 +20,7 @@ import ( "fmt" "testing" - . "k8s.io/kubectl/pkg/framework/predicates" + . "k8s.io/kubectl/pkg/framework/path/predicates" ) // This example shows you how you can create a IntP, and how it's use to diff --git a/pkg/framework/predicates/slice.go b/pkg/framework/path/predicates/slice.go similarity index 100% rename from pkg/framework/predicates/slice.go rename to pkg/framework/path/predicates/slice.go diff --git a/pkg/framework/predicates/slice_test.go b/pkg/framework/path/predicates/slice_test.go similarity index 98% rename from pkg/framework/predicates/slice_test.go rename to pkg/framework/path/predicates/slice_test.go index 96accd178..f4e576d19 100644 --- a/pkg/framework/predicates/slice_test.go +++ b/pkg/framework/path/predicates/slice_test.go @@ -19,7 +19,7 @@ package predicates_test import ( "testing" - . "k8s.io/kubectl/pkg/framework/predicates" + . "k8s.io/kubectl/pkg/framework/path/predicates" ) type SliceTrue struct{} diff --git a/pkg/framework/predicates/string.go b/pkg/framework/path/predicates/string.go similarity index 100% rename from pkg/framework/predicates/string.go rename to pkg/framework/path/predicates/string.go diff --git a/pkg/framework/predicates/string_test.go b/pkg/framework/path/predicates/string_test.go similarity index 98% rename from pkg/framework/predicates/string_test.go rename to pkg/framework/path/predicates/string_test.go index 34f6a094b..b7870a907 100644 --- a/pkg/framework/predicates/string_test.go +++ b/pkg/framework/path/predicates/string_test.go @@ -20,7 +20,7 @@ import ( "regexp" "testing" - . "k8s.io/kubectl/pkg/framework/predicates" + . "k8s.io/kubectl/pkg/framework/path/predicates" ) func TestStringEqual(t *testing.T) { diff --git a/pkg/framework/unstructpath/doc.go b/pkg/framework/path/selectors/doc.go similarity index 89% rename from pkg/framework/unstructpath/doc.go rename to pkg/framework/path/selectors/doc.go index b13e8d52f..8b3162793 100644 --- a/pkg/framework/unstructpath/doc.go +++ b/pkg/framework/path/selectors/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package helps you find specific fields in your unstruct +// This package helps you find specific fields in your interface{} // object. It is similar to what you can do with jsonpath, but reads the // path from strongly typed object, not strings. -package unstructpath +package selectors diff --git a/pkg/framework/unstructpath/example_test.go b/pkg/framework/path/selectors/example_test.go similarity index 97% rename from pkg/framework/unstructpath/example_test.go rename to pkg/framework/path/selectors/example_test.go index f310cec9a..f61932c4a 100644 --- a/pkg/framework/unstructpath/example_test.go +++ b/pkg/framework/path/selectors/example_test.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( "github.com/ghodss/yaml" - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // This example is inspired from http://goessner.net/articles/JsonPath/#e3. diff --git a/pkg/framework/unstructpath/interfacef.go b/pkg/framework/path/selectors/interfacef.go similarity index 97% rename from pkg/framework/unstructpath/interfacef.go rename to pkg/framework/path/selectors/interfacef.go index d6b4cf4a5..84a305ea7 100644 --- a/pkg/framework/unstructpath/interfacef.go +++ b/pkg/framework/path/selectors/interfacef.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // A interfaceFilter allows us to chain InterfaceS to InterfaceS. None of this is diff --git a/pkg/framework/unstructpath/interfaces.go b/pkg/framework/path/selectors/interfaces.go similarity index 98% rename from pkg/framework/unstructpath/interfaces.go rename to pkg/framework/path/selectors/interfaces.go index 8a9655f4f..49762fb26 100644 --- a/pkg/framework/unstructpath/interfaces.go +++ b/pkg/framework/path/selectors/interfaces.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // InterfaceS is a "interface selector". It filters interfaces based on the diff --git a/pkg/framework/unstructpath/interfaces_test.go b/pkg/framework/path/selectors/interfaces_test.go similarity index 86% rename from pkg/framework/unstructpath/interfaces_test.go rename to pkg/framework/path/selectors/interfaces_test.go index e07d0d552..b3f8baf7d 100644 --- a/pkg/framework/unstructpath/interfaces_test.go +++ b/pkg/framework/path/selectors/interfaces_test.go @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath_test +package selectors_test import ( "reflect" "testing" - "k8s.io/kubectl/pkg/framework/unstructpath" + "k8s.io/kubectl/pkg/framework/path/selectors" ) func TestAll(t *testing.T) { @@ -30,7 +30,7 @@ func TestAll(t *testing.T) { "key4": map[string]interface{}{"key5": 5.}, } - numbers := unstructpath.All().Number().SelectFrom(u) + numbers := selectors.All().Number().SelectFrom(u) expected := []float64{1., 2., 3., 4., 5.} if !reflect.DeepEqual(expected, numbers) { t.Fatalf("Expected to find all numbers (%v), got: %v", expected, numbers) @@ -44,7 +44,7 @@ func TestChildren(t *testing.T) { "key4": 5., } - numbers := unstructpath.Children().Number().SelectFrom(u) + numbers := selectors.Children().Number().SelectFrom(u) expected := []float64{1., 5.} if !reflect.DeepEqual(expected, numbers) { t.Fatalf("Expected to find all numbers (%v), got: %v", expected, numbers) @@ -60,14 +60,14 @@ func TestFilter(t *testing.T) { "string", } expected := []interface{}{us[1]} - actual := unstructpath.Filter(unstructpath.Slice().At(3)).SelectFrom(us...) + actual := selectors.Filter(selectors.Slice().At(3)).SelectFrom(us...) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Expected to filter (%v), got: %v", expected, actual) } } func TestInterfaceSPredicate(t *testing.T) { - if !unstructpath.Slice().Match([]interface{}{}) { + if !selectors.Slice().Match([]interface{}{}) { t.Fatal("SelectFroming a slice from a slice should match.") } } @@ -92,7 +92,7 @@ func TestInterfaceSMap(t *testing.T) { root, root["key4"].(map[string]interface{}), } - actual := unstructpath.All().Map().SelectFrom(root) + actual := selectors.All().Map().SelectFrom(root) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Map should find maps %v, got %v", expected, actual) } @@ -118,7 +118,7 @@ func TestInterfaceSSlice(t *testing.T) { root["key3"].([]interface{}), root["key4"].(map[string]interface{})["subkey"].([]interface{}), } - actual := unstructpath.All().Slice().SelectFrom(root) + actual := selectors.All().Slice().SelectFrom(root) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Slice should find slices %#v, got %#v", expected, actual) } @@ -144,7 +144,7 @@ func TestInterfaceSChildren(t *testing.T) { root["key3"].([]interface{})[0], root["key3"].([]interface{})[1], } - actual := unstructpath.Map().Field("key3").Children().SelectFrom(root) + actual := selectors.Map().Field("key3").Children().SelectFrom(root) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Expected %v, got %v", expected, actual) } @@ -153,7 +153,7 @@ func TestInterfaceSChildren(t *testing.T) { func TestInterfaceSNumber(t *testing.T) { u := []interface{}{1., 2., "three", 4., 5., []interface{}{}} - numbers := unstructpath.Children().Number().SelectFrom(u) + numbers := selectors.Children().Number().SelectFrom(u) expected := []float64{1., 2., 4., 5.} if !reflect.DeepEqual(expected, numbers) { t.Fatalf("Children().Number() should select %v, got %v", expected, numbers) @@ -182,7 +182,7 @@ func TestInterfaceSString(t *testing.T) { "other value", "string", } - actual := unstructpath.All().String().SelectFrom(root) + actual := selectors.All().String().SelectFrom(root) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Expected %v, got %v", expected, actual) } @@ -211,7 +211,7 @@ func TestInterfaceSAll(t *testing.T) { root["key4"].(map[string]interface{})["subkey"].([]interface{})[1], } - actual := unstructpath.Map().Field("key4").All().SelectFrom(root) + actual := selectors.Map().Field("key4").All().SelectFrom(root) if !reflect.DeepEqual(expected, actual) { t.Fatalf("Expected %v, got %v", expected, actual) } diff --git a/pkg/framework/unstructpath/mapf.go b/pkg/framework/path/selectors/mapf.go similarity index 96% rename from pkg/framework/unstructpath/mapf.go rename to pkg/framework/path/selectors/mapf.go index dd464f1bb..f8235f32f 100644 --- a/pkg/framework/unstructpath/mapf.go +++ b/pkg/framework/path/selectors/mapf.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( "sort" - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // This is a Map-to-Interface filter. diff --git a/pkg/framework/unstructpath/maps.go b/pkg/framework/path/selectors/maps.go similarity index 97% rename from pkg/framework/unstructpath/maps.go rename to pkg/framework/path/selectors/maps.go index bce67e0aa..3c5888b9a 100644 --- a/pkg/framework/unstructpath/maps.go +++ b/pkg/framework/path/selectors/maps.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // MapS is a "map selector". It selects interfaces as maps (if diff --git a/pkg/framework/unstructpath/numbers.go b/pkg/framework/path/selectors/numbers.go similarity index 96% rename from pkg/framework/unstructpath/numbers.go rename to pkg/framework/path/selectors/numbers.go index 567c3e608..890dae4b8 100644 --- a/pkg/framework/unstructpath/numbers.go +++ b/pkg/framework/path/selectors/numbers.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // NumberS is a "number selector". It selects values as numbers (if diff --git a/pkg/framework/unstructpath/numbers_test.go b/pkg/framework/path/selectors/numbers_test.go similarity index 93% rename from pkg/framework/unstructpath/numbers_test.go rename to pkg/framework/path/selectors/numbers_test.go index c49b00ee3..a6813d9cc 100644 --- a/pkg/framework/unstructpath/numbers_test.go +++ b/pkg/framework/path/selectors/numbers_test.go @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath_test +package selectors_test import ( "reflect" "testing" - p "k8s.io/kubectl/pkg/framework/predicates" - . "k8s.io/kubectl/pkg/framework/unstructpath" + p "k8s.io/kubectl/pkg/framework/path/predicates" + . "k8s.io/kubectl/pkg/framework/path/selectors" ) func TestNumberSSelectFrom(t *testing.T) { diff --git a/pkg/framework/unstructpath/slicef.go b/pkg/framework/path/selectors/slicef.go similarity index 96% rename from pkg/framework/unstructpath/slicef.go rename to pkg/framework/path/selectors/slicef.go index ce4baea22..0d85e8de3 100644 --- a/pkg/framework/unstructpath/slicef.go +++ b/pkg/framework/path/selectors/slicef.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) func filterSlice(ss SliceS, sf sliceFilter) InterfaceS { diff --git a/pkg/framework/unstructpath/slices.go b/pkg/framework/path/selectors/slices.go similarity index 97% rename from pkg/framework/unstructpath/slices.go rename to pkg/framework/path/selectors/slices.go index dda6d96dd..20df6680d 100644 --- a/pkg/framework/unstructpath/slices.go +++ b/pkg/framework/path/selectors/slices.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // SliceS is a "slice selector". It selects values as slices (if diff --git a/pkg/framework/unstructpath/strings.go b/pkg/framework/path/selectors/strings.go similarity index 96% rename from pkg/framework/unstructpath/strings.go rename to pkg/framework/path/selectors/strings.go index 7a727c04e..528002c29 100644 --- a/pkg/framework/unstructpath/strings.go +++ b/pkg/framework/path/selectors/strings.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath +package selectors import ( - p "k8s.io/kubectl/pkg/framework/predicates" + p "k8s.io/kubectl/pkg/framework/path/predicates" ) // StringS is a "string selector". It selects values as strings (if diff --git a/pkg/framework/unstructpath/strings_test.go b/pkg/framework/path/selectors/strings_test.go similarity index 93% rename from pkg/framework/unstructpath/strings_test.go rename to pkg/framework/path/selectors/strings_test.go index 2572b6c70..cf2f1af50 100644 --- a/pkg/framework/unstructpath/strings_test.go +++ b/pkg/framework/path/selectors/strings_test.go @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -package unstructpath_test +package selectors_test import ( "reflect" "testing" - p "k8s.io/kubectl/pkg/framework/predicates" - . "k8s.io/kubectl/pkg/framework/unstructpath" + p "k8s.io/kubectl/pkg/framework/path/predicates" + . "k8s.io/kubectl/pkg/framework/path/selectors" ) func TestStringSSelectFrom(t *testing.T) {