Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get a native .net Nuget? #1420

Open
mikeblakeuk opened this issue Jan 26, 2024 · 0 comments
Open

Is it possible to get a native .net Nuget? #1420

mikeblakeuk opened this issue Jan 26, 2024 · 0 comments

Comments

@mikeblakeuk
Copy link

Using dotnet6 on windows.
We want to use SOPS and wrap the tool in a dotnet command line tool.

a) Why can't we pass text to SOPS instead of a file
b) Could someone write a NuGet to interact with SOPS?

Thanks

Not idea:

        var tempFile = Path.Combine(_workingFolder, Guid.NewGuid().ToString());

        try
        {
            // Write data to temp file
            await File.WriteAllTextAsync(tempFile, data);

            using var myProcess = new System.Diagnostics.Process();
            try
            {

                myProcess.StartInfo.FileName = "sops";
                myProcess.StartInfo.Arguments = $"-e {tempFile} --input-type {inputType}";
                myProcess.StartInfo.WorkingDirectory = _workingFolder;
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.RedirectStandardInput = false;
                myProcess.StartInfo.RedirectStandardOutput = true;
                myProcess.StartInfo.RedirectStandardError = true;

                myProcess.Start();

                await myProcess.WaitForExitAsync();

                var stdOut = await myProcess.StandardOutput.ReadToEndAsync();
                var stdErr = await myProcess.StandardError.ReadToEndAsync();

                if (myProcess.ExitCode < 0 || !string.IsNullOrEmpty(stdErr))
                {
                    throw new Exception(stdErr);
                }
                return stdOut;
            }
            finally
            {
                myProcess.Kill();
                myProcess.Close();
            }
        }
        finally
        {
            // Delete temp file
            File.Delete(tempFile);
        }```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant