Code Monkey home page Code Monkey logo

Comments (6)

philomory avatar philomory commented on May 30, 2024 2

I think maybe a better way to resolve this would be to avoid decrypting secrets files to a decrypted file at all; it would probably be better to simply capture the stdout of helm secrets view, than to run helm secrets dec, work out the path to the decrypted file, read it, and then delete it manually.

Using helm secrets view instead of helm secrets dec would also have the advantage of allowing helmfile to correctly handle sops-encrypted files stored in a read-only filesystem.

from helmfile.

philomory avatar philomory commented on May 30, 2024 1

@IkePCampbell Still waiting on review for PR #201, once that's merged this should be addressed AFAIK.

from helmfile.

raxod502-plaid avatar raxod502-plaid commented on May 30, 2024

A workaround for this issue is to use a suffix other than .yaml on your secrets file. We renamed our secrets files from .yaml to .yml and it works fine, albeit looking very silly.

from helmfile.

philomory avatar philomory commented on May 30, 2024

I think something like this would do it, though I haven't tested it yet:

diff --git a/pkg/helmexec/exec.go b/pkg/helmexec/exec.go
index dc1668c..ca52d05 100644
--- a/pkg/helmexec/exec.go
+++ b/pkg/helmexec/exec.go
@@ -281,38 +281,14 @@ func (helm *execer) DecryptSecret(context HelmContext, name string, flags ...str
                helm.logger.Infof("Decrypting secret %v", absPath)
                preArgs := context.GetTillerlessArgs(helm)
                env := context.getTillerlessEnv()
-               out, err := helm.exec(append(append(preArgs, "secrets", "dec", absPath), flags...), env)
-               helm.info(out)
+               secretBytes, err := helm.exec(append(append(preArgs, "secrets", "view", absPath), flags...), env)
                if err != nil {
                        secret.err = err
                        return "", err
                }

-               // HELM_SECRETS_DEC_SUFFIX is used by the helm-secrets plugin to define the output file
-               decSuffix := os.Getenv("HELM_SECRETS_DEC_SUFFIX")
-               if len(decSuffix) == 0 {
-                       decSuffix = ".yaml.dec"
-               }
-
-               // helm secrets replaces the extension with its suffix ONLY when the extension is ".yaml"
-               var decFilename string
-               if strings.HasSuffix(absPath, ".yaml") {
-                       decFilename = strings.Replace(absPath, ".yaml", decSuffix, 1)
-               } else {
-                       decFilename = absPath + decSuffix
-               }
-
-               secretBytes, err := os.ReadFile(decFilename)
-               if err != nil {
-                       secret.err = err
-                       return "", err
-               }
                secret.bytes = secretBytes

-               if err := os.Remove(decFilename); err != nil {
-                       return "", err
-               }
-
        } else {
                // Cache hit
                helm.logger.Debugf("Found secret in cache %v", absPath)

from helmfile.

yxxhero avatar yxxhero commented on May 30, 2024

@philomory Can you create a PR. reveiw it toghter.Thanks very much.

from helmfile.

IkePCampbell avatar IkePCampbell commented on May 30, 2024

Sadly glad we arent the only ones affected by this, any update?

from helmfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.