Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2020-07-28 07:32:49 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2020-08-04 11:23:51 +0300
commit574317c8f7b3f56958a5604cbb39e57e49a7d32b (patch)
treea7b3d5de359eef9111960a5acfdce5d43433b66c
parent95e3f2803e09b105a275f3760909175d4b3bbb04 (diff)
Remove gitlabsourceconfig package
-rw-r--r--internal/source/domains/gitlabsourceconfig/gitlabsourceconfig.go94
1 files changed, 0 insertions, 94 deletions
diff --git a/internal/source/domains/gitlabsourceconfig/gitlabsourceconfig.go b/internal/source/domains/gitlabsourceconfig/gitlabsourceconfig.go
deleted file mode 100644
index ebc8b485..00000000
--- a/internal/source/domains/gitlabsourceconfig/gitlabsourceconfig.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package gitlabsourceconfig
-
-import (
- "bytes"
- "io/ioutil"
- "os"
- "time"
-
- log "github.com/sirupsen/logrus"
- "gopkg.in/yaml.v2"
-)
-
-// GitlabSourceDomains holds the domains to be used with the gitlab source
-type GitlabSourceDomains struct {
- Enabled []string
- Broken string
- Rollout GitlabSourceRollout
-}
-
-// GitlabSourceRollout holds the rollout strategy and percentage
-type GitlabSourceRollout struct {
- Stickiness string
- Percentage int
-}
-
-// GitlabSourceConfig holds the configuration for the gitlab source
-type GitlabSourceConfig struct {
- Domains GitlabSourceDomains
-}
-
-// UpdateFromYaml updates the config
-// We use new variable here (instead of using `config` directly)
-// because if `content` is empty `yaml.Unmarshal` does not update
-// the fields already set.
-func (config *GitlabSourceConfig) UpdateFromYaml(content []byte) error {
- updated := GitlabSourceConfig{}
-
- err := yaml.Unmarshal(content, &updated)
- if err != nil {
- return err
- }
-
- *config = updated
-
- log.WithFields(log.Fields{
- "Enabled domains": config.Domains.Enabled,
- "Broken domain": config.Domains.Broken,
- "Rollout %": config.Domains.Rollout.Percentage,
- "Rollout stickiness": config.Domains.Rollout.Stickiness,
- }).Info("gitlab source config updated")
-
- return nil
-}
-
-// WatchForGitlabSourceConfigChange polls the filesystem and updates test domains if needed.
-func WatchForGitlabSourceConfigChange(config *GitlabSourceConfig, interval time.Duration) {
- var lastContent []byte
-
- gitlabSourceConfigFile := os.Getenv("GITLAB_SOURCE_CONFIG_FILE")
- if gitlabSourceConfigFile == "" {
- gitlabSourceConfigFile = ".gitlab-source-config.yml"
- }
-
- for {
- content, err := readConfig(gitlabSourceConfigFile)
- if err != nil {
- log.WithError(err).Warn("Failed to read gitlab source config file")
-
- time.Sleep(interval)
- continue
- }
-
- if !bytes.Equal(lastContent, content) {
- lastContent = content
-
- err = config.UpdateFromYaml(content)
- if err != nil {
- log.WithError(err).Warn("Failed to update gitlab source config")
- }
- }
-
- time.Sleep(interval)
- }
-}
-
-func readConfig(configfile string) ([]byte, error) {
- content, err := ioutil.ReadFile(configfile)
-
- if err != nil && !os.IsNotExist(err) {
- return nil, err
- }
-
- return content, nil
-}