-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from pb82/configurable-image
Configurable image
- Loading branch information
Showing
4 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package grafana | ||
|
||
import "sync" | ||
|
||
const ( | ||
ConfigGrafanaImage = "grafana.image.url" | ||
ConfigGrafanaImageTag = "grafana.image.tag" | ||
) | ||
|
||
type ControllerConfig struct { | ||
Values map[string]string | ||
} | ||
|
||
var instance *ControllerConfig | ||
var once sync.Once | ||
|
||
func GetControllerConfig() *ControllerConfig { | ||
once.Do(func() { | ||
instance = &ControllerConfig{ | ||
Values: map[string]string{}, | ||
} | ||
}) | ||
return instance | ||
} | ||
|
||
func (c *ControllerConfig) AddConfigItem(key, value string) { | ||
if key != "" && value != "" { | ||
c.Values[key] = value | ||
} | ||
} | ||
|
||
func (c *ControllerConfig) GetConfigItem(key, defaultValue string) string { | ||
if c.HasConfigItem(key) { | ||
return c.Values[key] | ||
} | ||
return defaultValue | ||
} | ||
|
||
func (c *ControllerConfig) HasConfigItem(key string) bool { | ||
_, ok := c.Values[key] | ||
return ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters