Skip to content

PROPOSAL: dagger.#DecodeSecret is a high-level wrapper to engine.#TransformSecret #1496

@talentedmrjones

Description

@talentedmrjones

As discussed in #1429 we need some high-level wrappers to ease the entry into #TransformSecret. This is a proposal for the design of dagger.#YamlSecret (I'm not attached to names at this point, open/happy to consider other suggestions)

EDIT: per latest proposal from @shykes

package dagger

import (
  "encoding/yaml"
  "encoding/json"
)

DecodeSecret: {
  {
    format: "json"
    engine.#TransformSecret & {
      #function: {
        input:  _
        output: json.Unmarshal(input)
      }
    }
  } | {
    format: "yaml"
    engine.#TransformSecret & {
      #function: {
        input:  _
        output: yaml.Unmarshal(input)
      }
    }
  }

}

To use it:

dagger.#Plan & {
  inputs: secrets: sops: {
    command: {
      name: "sops"
      args: ["-d", "path/to/encryptedSecrets.yaml"]
    }
  }

  actions: {
    sopsSecrets: dagger.#DecodeSecret & {
      format: "yaml"
      input: inputs.secrets.sopsStuff
    }

    // we can now reference sopsSecrets.output.someKey.contents
  }
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions