[ARVADOS] updated: 1.3.0-1410-g46d2d8aa3

Git user git at public.curoverse.com
Fri Jul 26 20:22:39 UTC 2019


Summary of changes:
 sdk/go/arvados/config.go      | 50 ++++++++++++++++++++++++++++++++++++-------
 sdk/go/arvados/config_test.go | 10 +++++++++
 2 files changed, 52 insertions(+), 8 deletions(-)

       via  46d2d8aa38c07675081266bc287e4fb1f7149bb0 (commit)
      from  d18ccfa8bb9a03857eedbfcca6681d217c9ab066 (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 46d2d8aa38c07675081266bc287e4fb1f7149bb0
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Fri Jul 26 16:21:20 2019 -0400

    15467: Introduce "StringSet"
    
    Accepts an array of strings and converts to map for backwards
    compatibility.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go
index e04849bb8..bee93046e 100644
--- a/sdk/go/arvados/config.go
+++ b/sdk/go/arvados/config.go
@@ -69,7 +69,7 @@ type Cluster struct {
 
 	API struct {
 		AsyncPermissionsUpdateInterval Duration
-		DisabledAPIs                   map[string]struct{}
+		DisabledAPIs                   StringSet
 		MaxIndexDatabaseRead           int
 		MaxItemsPerResponse            int
 		MaxRequestAmplification        int
@@ -83,7 +83,7 @@ type Cluster struct {
 	AuditLogs struct {
 		MaxAge             Duration
 		MaxDeleteBatch     int
-		UnloggedAttributes map[string]struct{}
+		UnloggedAttributes StringSet
 	}
 	Collections struct {
 		BlobSigning          bool
@@ -135,10 +135,10 @@ type Cluster struct {
 		AutoSetupNewUsers                     bool
 		AutoSetupNewUsersWithRepository       bool
 		AutoSetupNewUsersWithVmUUID           string
-		AutoSetupUsernameBlacklist            map[string]struct{}
+		AutoSetupUsernameBlacklist            StringSet
 		EmailSubjectPrefix                    string
-		NewInactiveUserNotificationRecipients map[string]struct{}
-		NewUserNotificationRecipients         map[string]struct{}
+		NewInactiveUserNotificationRecipients StringSet
+		NewUserNotificationRecipients         StringSet
 		NewUsersAreActive                     bool
 		UserNotifierEmailFrom                 string
 		UserProfileNotificationAddress        string
@@ -148,7 +148,7 @@ type Cluster struct {
 		APIClientConnectTimeout          Duration
 		APIClientReceiveTimeout          Duration
 		APIResponseCompression           bool
-		ApplicationMimetypesWithViewIcon map[string]struct{}
+		ApplicationMimetypesWithViewIcon StringSet
 		ArvadosDocsite                   string
 		ArvadosPublicDataDocURL          string
 		DefaultOpenIdPrefix              string
@@ -267,7 +267,7 @@ type ContainersConfig struct {
 	MinRetryPeriod              Duration
 	ReserveExtraRAM             ByteSize
 	StaleLockTimeout            Duration
-	SupportedDockerImageFormats map[string]struct{}
+	SupportedDockerImageFormats StringSet
 	UsePreemptibleInstances     bool
 
 	JobsAPI struct {
@@ -300,7 +300,7 @@ type ContainersConfig struct {
 			DNSServerReloadCommand string
 			DNSServerUpdateCommand string
 			ComputeNodeDomain      string
-			ComputeNodeNameservers map[string]struct{}
+			ComputeNodeNameservers StringSet
 			AssignNodeHostname     string
 		}
 	}
@@ -388,6 +388,40 @@ func (it *InstanceTypeMap) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
+type StringSet map[string]struct{}
+
+// UnmarshalJSON handles old config files that provide an array of
+// instance types instead of a hash.
+func (ss *StringSet) UnmarshalJSON(data []byte) error {
+	if len(data) > 0 && data[0] == '[' {
+		var arr []string
+		err := json.Unmarshal(data, &arr)
+		if err != nil {
+			return err
+		}
+		if len(arr) == 0 {
+			*ss = nil
+			return nil
+		}
+		*ss = make(map[string]struct{}, len(arr))
+		for _, t := range arr {
+			(*ss)[t] = struct{}{}
+		}
+		return nil
+	}
+	var hash map[string]struct{}
+	err := json.Unmarshal(data, &hash)
+	if err != nil {
+		return err
+	}
+	*ss = make(map[string]struct{}, len(hash))
+	for t, _ := range hash {
+		(*ss)[t] = struct{}{}
+	}
+
+	return nil
+}
+
 type ServiceName string
 
 const (
diff --git a/sdk/go/arvados/config_test.go b/sdk/go/arvados/config_test.go
index 59c743268..b984cb566 100644
--- a/sdk/go/arvados/config_test.go
+++ b/sdk/go/arvados/config_test.go
@@ -15,6 +15,16 @@ type ConfigSuite struct{}
 
 func (s *ConfigSuite) TestInstanceTypesAsArray(c *check.C) {
 	var cluster Cluster
+	yaml.Unmarshal([]byte(`
+API:
+  DisabledAPIs: [jobs.list]`), &cluster)
+	c.Check(len(cluster.API.DisabledAPIs), check.Equals, 1)
+	_, ok := cluster.API.DisabledAPIs["jobs.list"]
+	c.Check(ok, check.Equals, true)
+}
+
+func (s *ConfigSuite) TestStringSetAsArray(c *check.C) {
+	var cluster Cluster
 	yaml.Unmarshal([]byte("InstanceTypes:\n- Name: foo\n"), &cluster)
 	c.Check(len(cluster.InstanceTypes), check.Equals, 1)
 	c.Check(cluster.InstanceTypes["foo"].Name, check.Equals, "foo")

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list