Skip to content

Commit

Permalink
fix(helm): config file for api (#4131)
Browse files Browse the repository at this point in the history
config file for api
and remove volume for µservice elasticsearch
improve some logs for debugging

Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored and bnjjj committed Apr 2, 2019
1 parent a7cc952 commit acae6b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
7 changes: 6 additions & 1 deletion contrib/helm/cds/templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ spec:
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
env:
- name: CDS_CONFIG_FILE
valueFrom:
secretKeyRef:
name: {{ template "cds.fullname" . }}
key: cds_config_file
- name: CDS_API_DATABASE_HOST
{{- if .Values.postgresql.enabled }}
value: {{ template "cds.postgresql.fullname" . }}
Expand Down Expand Up @@ -74,7 +79,7 @@ spec:
name: {{ template "cds.fullname" . }}
key: cds-api_secrets_key
command: ["/bin/sh"]
args: ["-c", "/app/cds-engine-linux-amd64 start api"]
args: ["-c", "echo $CDS_CONFIG_FILE | base64 --decode -o config.toml && /app/cds-engine-linux-amd64 start api --config config.toml"]
ports:
- name: http
containerPort: 8081
Expand Down
7 changes: 0 additions & 7 deletions contrib/helm/cds/templates/elasticsearch-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,3 @@ spec:
ports:
- name: http
containerPort: 8084
volumeMounts:
- name: cds-repos-data
mountPath: {{ .Values.repositories.persistence.mountPath }}
volumes:
- name: cds-repos-data
persistentVolumeClaim:
claimName: {{ (printf "%s-elasticsearch" (include "cds.fullname" .)) }}
8 changes: 4 additions & 4 deletions engine/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (a *API) CheckConfiguration(config interface{}) error {
}

if aConfig.Directories.Download == "" {
return fmt.Errorf("Invalid download directory")
return fmt.Errorf("Invalid download directory (empty)")
}

if ok, err := DirectoryExists(aConfig.Directories.Download); !ok {
Expand All @@ -309,7 +309,7 @@ func (a *API) CheckConfiguration(config interface{}) error {
}
log.Info("Directory %s has been created", aConfig.Directories.Download)
} else if err != nil {
return fmt.Errorf("Invalid download directory: %v", err)
return fmt.Errorf("Invalid download directory %s: %v", aConfig.Directories.Download, err)
}

if aConfig.Directories.Keys == "" {
Expand All @@ -333,15 +333,15 @@ func (a *API) CheckConfiguration(config interface{}) error {

if aConfig.Artifact.Mode == "local" {
if aConfig.Artifact.Local.BaseDirectory == "" {
return fmt.Errorf("Invalid artifact local base directory")
return fmt.Errorf("Invalid artifact local base directory (empty name)")
}
if ok, err := DirectoryExists(aConfig.Artifact.Local.BaseDirectory); !ok {
if err := os.MkdirAll(aConfig.Artifact.Local.BaseDirectory, os.FileMode(0700)); err != nil {
return fmt.Errorf("Unable to create directory %s: %v", aConfig.Artifact.Local.BaseDirectory, err)
}
log.Info("Directory %s has been created", aConfig.Artifact.Local.BaseDirectory)
} else if err != nil {
return fmt.Errorf("Invalid artifact local base directory: %v", err)
return fmt.Errorf("Invalid artifact local base directory %s: %v", aConfig.Artifact.Local.BaseDirectory, err)
}
}

Expand Down

0 comments on commit acae6b2

Please sign in to comment.