Moved sensitive data to env vars: TODO: Remove config.yml from git history

This commit is contained in:
Adphi 2018-10-16 11:52:34 +02:00
parent 68f06ac164
commit f388c31259
2 changed files with 20 additions and 3 deletions

View File

@ -9,8 +9,9 @@ before_script:
- mkdir -p /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio - mkdir -p /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio
- cp -r $CI_PROJECT_DIR /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio - cp -r $CI_PROJECT_DIR /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio
- cd /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud - cd /go/src/gitlab.adphi.fr/partitio/Nextcloud-Partitio/gonextcloud
- sed -i -e 's/$NEXTCLOUD_URL/'${NEXTCLOUD_URL//\//\\/}'/g' config.yml #- sed -i -e 's/$NEXTCLOUD_URL/'${NEXTCLOUD_URL//\//\\/}'/g' config.yml
- sed -i -e 's/$NEXTCLOUD_PASSWORD/'${NEXTCLOUD_PASSWORD}'/g' config.yml #- sed -i -e 's/$NEXTCLOUD_PASSWORD/'${NEXTCLOUD_PASSWORD}'/g' config.yml
#- sed -i -e 's/$NEXTCLOUD_EMAIL/'${NEXTCLOUD_EMAIL}'/g' config.yml
- make dep - make dep
unit_tests: unit_tests:

View File

@ -587,7 +587,23 @@ func LoadConfig() error {
if err != nil { if err != nil {
return err return err
} }
return yaml.Unmarshal(b, &config) if err := yaml.Unmarshal(b, &config); err != nil {
return err
}
// Override with env variables
u := os.Getenv("NEXTCLOUD_URL")
if u != "" {
config.URL = u
}
p := os.Getenv("NEXTCLOUD_PASSWORD")
if p != "" {
config.Password = p
}
e := os.Getenv("NEXTCLOUD_EMAIL")
if e != "" {
config.Email = e
}
return nil
} }
func initClient() error { func initClient() error {