From 0ba2b40abe835ccc7f0baa3cbade33e6f0c647e1 Mon Sep 17 00:00:00 2001 From: Michael Desa Date: Thu, 9 Nov 2017 10:19:25 -0500 Subject: [PATCH] Set default role to viewer on source if not specified --- bolt/sources.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bolt/sources.go b/bolt/sources.go index 72c5cf8d74..9a9b52bb50 100644 --- a/bolt/sources.go +++ b/bolt/sources.go @@ -7,6 +7,7 @@ import ( "github.com/boltdb/bolt" "github.com/influxdata/chronograf" "github.com/influxdata/chronograf/bolt/internal" + "github.com/influxdata/chronograf/roles" ) // Ensure SourcesStore implements chronograf.SourcesStore. @@ -36,9 +37,12 @@ func (s *SourcesStore) Migrate(ctx context.Context) error { for _, source := range sources { if source.Organization == "" { source.Organization = defaultOrgID - if err := s.Update(ctx, source); err != nil { - return nil - } + } + if source.Role == "" { + source.Role = roles.ViewerRoleName + } + if err := s.Update(ctx, source); err != nil { + return nil } }