Linting fixes for provisoning (#23600)

This commit is contained in:
Carl Bergquist
2020-04-16 05:46:20 +02:00
committed by GitHub
parent 6e313e7d37
commit 5fc255bd89
11 changed files with 90 additions and 88 deletions
@@ -16,14 +16,14 @@ type configReader struct {
log log.Logger
}
func (cr *configReader) parseConfigs(file os.FileInfo) ([]*DashboardsAsConfig, error) {
func (cr *configReader) parseConfigs(file os.FileInfo) ([]*config, error) {
filename, _ := filepath.Abs(filepath.Join(cr.path, file.Name()))
yamlFile, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
apiVersion := &ConfigVersion{ApiVersion: 0}
apiVersion := &configVersion{APIVersion: 0}
// We ignore the error here because it errors out for version 0 which does not have apiVersion
// specified (so 0 is default). This can also error in case the apiVersion is not an integer but at the moment
@@ -32,8 +32,8 @@ func (cr *configReader) parseConfigs(file os.FileInfo) ([]*DashboardsAsConfig, e
// integer > max version?).
_ = yaml.Unmarshal(yamlFile, &apiVersion)
if apiVersion.ApiVersion > 0 {
v1 := &DashboardAsConfigV1{}
if apiVersion.APIVersion > 0 {
v1 := &configV1{}
err := yaml.Unmarshal(yamlFile, &v1)
if err != nil {
return nil, err
@@ -43,7 +43,7 @@ func (cr *configReader) parseConfigs(file os.FileInfo) ([]*DashboardsAsConfig, e
return v1.mapToDashboardsAsConfig()
}
} else {
var v0 []*DashboardsAsConfigV0
var v0 []*configV0
err := yaml.Unmarshal(yamlFile, &v0)
if err != nil {
return nil, err
@@ -55,11 +55,11 @@ func (cr *configReader) parseConfigs(file os.FileInfo) ([]*DashboardsAsConfig, e
}
}
return []*DashboardsAsConfig{}, nil
return []*config{}, nil
}
func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
var dashboards []*DashboardsAsConfig
func (cr *configReader) readConfig() ([]*config, error) {
var dashboards []*config
files, err := ioutil.ReadDir(cr.path)
if err != nil {
@@ -84,15 +84,15 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
uidUsage := map[string]uint8{}
for _, dashboard := range dashboards {
if dashboard.OrgId == 0 {
dashboard.OrgId = 1
if dashboard.OrgID == 0 {
dashboard.OrgID = 1
}
if dashboard.UpdateIntervalSeconds == 0 {
dashboard.UpdateIntervalSeconds = 10
}
if len(dashboard.FolderUid) > 0 {
uidUsage[dashboard.FolderUid]++
if len(dashboard.FolderUID) > 0 {
uidUsage[dashboard.FolderUID]++
}
}