[arvados] updated: 2.5.0-184-gaf6678611

git repository hosting git at public.arvados.org
Tue Feb 21 21:27:36 UTC 2023


Summary of changes:
 doc/api/properties.html.textile.liquid | 18 +++++++++++++++++-
 sdk/go/arvados/vocabulary.go           |  7 +++++--
 sdk/go/arvados/vocabulary_test.go      | 31 +++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)

       via  af6678611b4600eb65f64b7f194905d4698e1508 (commit)
       via  3429718113f11e999dd745e94ff981a4f3b01c57 (commit)
       via  f41bb69fdd60627f6e4880f51ed48f69e79af760 (commit)
       via  d5888bae24963b7e4808267a832024c930fbc1b0 (commit)
      from  b4792d835e27f7b5deaaff51adf648f395c3a999 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit af6678611b4600eb65f64b7f194905d4698e1508
Merge: b4792d835 342971811
Author: Brett Smith <brett.smith at curii.com>
Date:   Tue Feb 21 16:27:28 2023 -0500

    Merge branch '19980-arv-prefix-properties'
    
    Closes #19980.
    
    Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>


commit 3429718113f11e999dd745e94ff981a4f3b01c57
Author: Brett Smith <brett.smith at curii.com>
Date:   Tue Feb 21 16:24:17 2023 -0500

    19980: System properties only require arv: prefix
    
    The decision to require a following alphabetic character was
    well-intentioned but misplaced: it doesn't stop these properties from
    existing, just changes the layer they would be defined at.
    
    It might make sense to add some name rules to properties, but that would
    be better done across the board as a separate story, not as a specific
    corner case of system properties.
    
    Arvados-DCO-1.1-Signed-off-by: Brett Smith <brett.smith at curii.com>

diff --git a/sdk/go/arvados/vocabulary.go b/sdk/go/arvados/vocabulary.go
index caab6e8fb..1df43b5fb 100644
--- a/sdk/go/arvados/vocabulary.go
+++ b/sdk/go/arvados/vocabulary.go
@@ -10,13 +10,10 @@ import (
 	"errors"
 	"fmt"
 	"reflect"
-	"regexp"
 	"strconv"
 	"strings"
 )
 
-const systemKeyPattern = `^arv:[a-zA-Z]`
-
 type Vocabulary struct {
 	reservedTagKeys map[string]bool          `json:"-"`
 	StrictTags      bool                     `json:"strict_tags"`
@@ -30,8 +27,8 @@ type VocabularyTag struct {
 }
 
 // Cannot have a constant map in Go, so we have to use a function.
-// If you are adding a new system property, it SHOULD match `systemKeyPattern`
-// above, and Check will allow it. This map is for historical exceptions that
+// If you are adding a new system property, it SHOULD start with `arv:`,
+// and Check will allow it. This map is for historical exceptions that
 // predate standardizing on this prefix.
 func (v *Vocabulary) systemTagKeys() map[string]bool {
 	return map[string]bool{
@@ -271,13 +268,9 @@ func (v *Vocabulary) Check(data map[string]interface{}) error {
 	if v == nil {
 		return nil
 	}
-	systemKeyRegexp, err := regexp.Compile(systemKeyPattern)
-	if err != nil {
-		return err
-	}
 	for key, val := range data {
 		// Checks for key validity
-		if systemKeyRegexp.MatchString(key) || v.reservedTagKeys[key] {
+		if strings.HasPrefix(key, "arv:") || v.reservedTagKeys[key] {
 			// Allow reserved keys to be used even if they are not defined in
 			// the vocabulary no matter its strictness.
 			continue
diff --git a/sdk/go/arvados/vocabulary_test.go b/sdk/go/arvados/vocabulary_test.go
index c06efda3e..af62833a3 100644
--- a/sdk/go/arvados/vocabulary_test.go
+++ b/sdk/go/arvados/vocabulary_test.go
@@ -6,7 +6,6 @@ package arvados
 
 import (
 	"encoding/json"
-	"fmt"
 	"regexp"
 	"strings"
 
@@ -312,28 +311,21 @@ func (s *VocabularySuite) TestValidSystemProperties(c *check.C) {
 	c.Check(s.testVoc.Check(properties), check.IsNil)
 }
 
-func (s *VocabularySuite) TestSystemPropertiesFirstCharacterAlphabetic(c *check.C) {
-	s.testVoc.StrictTags = true
-	properties := map[string]interface{}{"arv:": "value"}
-	c.Check(s.testVoc.Check(properties), check.NotNil)
-	// If we expand the list of allowed characters in the future, these lists
-	// may need adjustment to match.
-	for _, prefix := range []string{" ", ".", "_", "-", "1"} {
-		for _, suffix := range []string{"", "invalid"} {
-			key := fmt.Sprintf("arv:%s%s", prefix, suffix)
-			properties := map[string]interface{}{key: "value"}
-			c.Check(s.testVoc.Check(properties), check.NotNil)
-		}
-	}
-}
-
 func (s *VocabularySuite) TestSystemPropertiesPrefixTypo(c *check.C) {
 	s.testVoc.StrictTags = true
 	for _, key := range []string{
+		// Extra characters in prefix
 		"arv :foo",
+		" arv:foo",
+		// Wrong punctuation
+		"arv.foo",
+		"arv-foo",
+		"arv_foo",
+		// Wrong case
+		"Arv:foo",
+		// Wrong word
 		"arvados",
 		"arvados:foo",
-		"Arv:foo",
 	} {
 		properties := map[string]interface{}{key: "value"}
 		c.Check(s.testVoc.Check(properties), check.NotNil)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list