Skip to content

Commit

Permalink
feat: #51 drop secrets vars configs support
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-shulha committed Sep 13, 2024
1 parent 11d3f5c commit 688c6c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
25 changes: 3 additions & 22 deletions internal/app/ptah-agent/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ptah_agent

import (
"context"
"encoding/json"
"fmt"
"strings"

Expand Down Expand Up @@ -55,27 +54,9 @@ func (e *taskExecutor) updateDockerService(ctx context.Context, req *t.UpdateSer
func (e *taskExecutor) prepareServicePayload(ctx context.Context, servicePayload t.ServicePayload, secretVars t.SecretVars) (*swarm.ServiceSpec, error) {
spec := servicePayload.SwarmServiceSpec

if secretVars.ConfigName != "" {
newVarsJson, err := json.Marshal(secretVars.Values)
if err != nil {
return nil, errors.Wrapf(err, "marshal vars")
}

_, err = e.docker.ConfigCreate(ctx, swarm.ConfigSpec{
Annotations: swarm.Annotations{
Name: secretVars.ConfigName,
Labels: secretVars.ConfigLabels,
},
Data: newVarsJson,
})

if err != nil {
return nil, errors.Wrapf(err, "create config %s", secretVars.ConfigName)
}

for key, value := range secretVars.Values {
spec.TaskTemplate.ContainerSpec.Env = append(spec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("%s=%s", key, value))
}
for key, value := range secretVars.Values {
// We will be decoding the secret values here
spec.TaskTemplate.ContainerSpec.Env = append(spec.TaskTemplate.ContainerSpec.Env, fmt.Sprintf("%s=%s", key, value))
}

for _, config := range spec.TaskTemplate.ContainerSpec.Configs {
Expand Down
5 changes: 1 addition & 4 deletions internal/pkg/ptah-client/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CreateSecretRes struct {

type ServicePayload struct {
AuthConfigName string
SecretVars SecretVars
ReleaseCommand struct {
ConfigName string
ConfigLabels map[string]string
Expand All @@ -74,8 +75,6 @@ type SecretVars struct {

type CreateServiceReq struct {
ServicePayload

SecretVars SecretVars
}

type CreateServiceRes struct {
Expand All @@ -84,8 +83,6 @@ type CreateServiceRes struct {

type UpdateServiceReq struct {
ServicePayload

SecretVars SecretVars
}

type UpdateServiceRes struct {
Expand Down

0 comments on commit 688c6c6

Please sign in to comment.