From 2bfe1392299a4baf700fdb6be92f45581dc73c84 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Wed, 10 Aug 2022 16:42:12 -0400 Subject: [PATCH] chore: updates spelling and docs and sorts imports Signed-off-by: Jennifer Power --- attributes/doc.go | 4 ++-- builder/config/convert.go | 6 +++--- cli/pull_test.go | 2 +- cli/testdata/configs/nomatch.yaml | 2 +- docs/design/model.md | 2 +- docs/design/schema.md | 7 ++++--- model/nodes/collection/collection_test.go | 3 ++- model/nodes/descriptor/descriptor.go | 4 ++-- ocimanifest/annotations.go | 4 ++-- ocimanifest/annotations_test.go | 1 + 10 files changed, 19 insertions(+), 16 deletions(-) diff --git a/attributes/doc.go b/attributes/doc.go index ac912700..4a556a1a 100644 --- a/attributes/doc.go +++ b/attributes/doc.go @@ -16,5 +16,5 @@ package attributes // This package defines types and methods for performing attributing matching, // implementation, and node searching. -// NOTE: This package contains helper functions when create new attributes namely (attributes.Reflect). -// A warning, the functions in this package use reflect and therefore will incur a performance penalty. +// This package contains helper functions when creating new attributes. +// WARNING: The helper functions (attribute.Reflect) in this package use reflection and therefore will incur a performance penalty. diff --git a/builder/config/convert.go b/builder/config/convert.go index 83a159c9..efd4e804 100644 --- a/builder/config/convert.go +++ b/builder/config/convert.go @@ -7,10 +7,10 @@ import ( "github.com/uor-framework/uor-client-go/model" ) -// ConvertToModel converts an attribute query to an attribute set. -func ConvertToModel(v1attributes v1alpha1.Attributes) (model.AttributeSet, error) { +// ConvertToModel converts v1alpha1.Attributes to an model.AttributeSet. +func ConvertToModel(input v1alpha1.Attributes) (model.AttributeSet, error) { set := attributes.Attributes{} - for key, val := range v1attributes { + for key, val := range input { mattr, err := attributes.Reflect(key, val) if err != nil { return nil, fmt.Errorf("error converting attribute %s to model: %v", key, err) diff --git a/cli/pull_test.go b/cli/pull_test.go index ac53aff1..7aef41cb 100644 --- a/cli/pull_test.go +++ b/cli/pull_test.go @@ -307,7 +307,7 @@ func prepTestArtifact(t *testing.T, ref string, host string) { ocimanifest.AnnotationCollectionLinks: linked1Ref, } linkedRef := fmt.Sprintf("%s/linked:test", host) - publishFunc(fileLinkedName, linkedRef, fileContent, map[string]string{"test": "" + "linkedannotation"}, middleAnnotations) + publishFunc(fileLinkedName, linkedRef, fileContent, map[string]string{"test": "linkedannotation"}, middleAnnotations) rootAnnotations := map[string]string{ ocimanifest.AnnotationSchema: "test.com/schema:latest", ocimanifest.AnnotationSchemaLinks: "test.com/schema:latest", diff --git a/cli/testdata/configs/nomatch.yaml b/cli/testdata/configs/nomatch.yaml index 55d40b84..e8f10be2 100644 --- a/cli/testdata/configs/nomatch.yaml +++ b/cli/testdata/configs/nomatch.yaml @@ -1,4 +1,4 @@ kind: AttributeQuery apiVersion: client.uor-framework.io/v1alpha1 attributes: - - "test": annotation" \ No newline at end of file + - "test2": annotation" \ No newline at end of file diff --git a/docs/design/model.md b/docs/design/model.md index e1d444e1..5ab0bb58 100644 --- a/docs/design/model.md +++ b/docs/design/model.md @@ -37,7 +37,7 @@ Matcher is an interface that defines methods for node searching/matching that ca # Attribute Attribute is an interface that defines a single attribute values with a key that is a type of string and a value that -can be a string, boolean, number or null value. +can be a string, boolean, integer, number, or null value. # AttributeSet diff --git a/docs/design/schema.md b/docs/design/schema.md index e3c4bc58..c45baf70 100644 --- a/docs/design/schema.md +++ b/docs/design/schema.md @@ -22,9 +22,10 @@ declarations MUST follow the following syntax and guidelines: and are expressions with JSON syntax: 1. Number (expressed at float) -2. String -3. Boolean -4. Null +2. Integer +3. String +4. Boolean +5. Null ### Algorithm Reference diff --git a/model/nodes/collection/collection_test.go b/model/nodes/collection/collection_test.go index 43448a32..eb47cc0a 100644 --- a/model/nodes/collection/collection_test.go +++ b/model/nodes/collection/collection_test.go @@ -1,11 +1,12 @@ package collection import ( - "github.com/uor-framework/uor-client-go/attributes" "sort" "testing" "github.com/stretchr/testify/require" + + "github.com/uor-framework/uor-client-go/attributes" "github.com/uor-framework/uor-client-go/model" "github.com/uor-framework/uor-client-go/util/testutils" ) diff --git a/model/nodes/descriptor/descriptor.go b/model/nodes/descriptor/descriptor.go index 5edf4857..3aaa7923 100644 --- a/model/nodes/descriptor/descriptor.go +++ b/model/nodes/descriptor/descriptor.go @@ -1,10 +1,10 @@ package descriptor import ( + ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/uor-framework/uor-client-go/model" "github.com/uor-framework/uor-client-go/ocimanifest" - - ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) // Node defines a single unit containing information about a UOR dataset node. diff --git a/ocimanifest/annotations.go b/ocimanifest/annotations.go index b039b44c..73c5e3af 100644 --- a/ocimanifest/annotations.go +++ b/ocimanifest/annotations.go @@ -4,14 +4,14 @@ import ( "encoding/json" "errors" "fmt" - "github.com/uor-framework/uor-client-go/builder/api/v1alpha1" - "github.com/uor-framework/uor-client-go/builder/config" "regexp" "strings" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/uor-framework/uor-client-go/attributes" + "github.com/uor-framework/uor-client-go/builder/api/v1alpha1" + "github.com/uor-framework/uor-client-go/builder/config" "github.com/uor-framework/uor-client-go/model" ) diff --git a/ocimanifest/annotations_test.go b/ocimanifest/annotations_test.go index fe40bca7..83b9b5dc 100644 --- a/ocimanifest/annotations_test.go +++ b/ocimanifest/annotations_test.go @@ -30,5 +30,6 @@ func TestAnnotationsToAttributeSet(t *testing.T) { require.Equal(t, expJSON, string(set.AsJSON())) // JSON standard lib will unmarshal all numbers as float64 exists, err := set.Exists(attributes.NewFloat("size", 2)) + require.NoError(t, err) require.True(t, exists) }