-
Notifications
You must be signed in to change notification settings - Fork 897
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
Support --input-type for exec-file #699
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #699 +/- ##
========================================
Coverage 38.26% 38.26%
========================================
Files 23 23
Lines 3335 3335
========================================
Hits 1276 1276
Misses 1929 1929
Partials 130 130 Continue to review full report at Codecov.
|
cmd/sops/main.go
Outdated
@@ -966,8 +970,9 @@ func inputStore(context *cli.Context, path string) common.Store { | |||
return common.DefaultStoreForPathOrFormat(path, context.String("input-type")) | |||
} | |||
|
|||
// SCARY! SHOULD THIS BE USING INPUT-TYPE? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, using output-type is correct. Please revert me, or show why you think I'm wrong :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@autrilla I freely-admit that I'm probably poking the wrong part of this code. Here was my (simplistic) test.
With the file test containing only: "superSecret: superSecretValue
"
and a sops/v3/cmd/sops/main.go containing:
func outputStore(context *cli.Context, path string) common.Store {
//fmt.Println("Doing the right thing")
//return common.DefaultStoreForPathOrFormat(path, context.String("output-type"))
fmt.Println("Doing the wrong thing")
return common.DefaultStoreForPathOrFormat(path, context.String("input-type"))
}
I get the following results:
# sops exec-file --input-type yaml /tmp/test 'cat {}'
Doing the right thing
Error dumping file: No binary data found in tree
# sops exec-file --input-type yaml /tmp/test 'cat {}'
Doing the wrong thing
superSecret: superSecretValue
Thank you for your time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see! I think the right thing to do here would be adding support for --output-type too. The issue is that SOPS tries to decide on the output store to use based on the file name, and assumes it should be binary (since /tmp/test
does not have an extension that indicates a known file type). You'll need to make your calls to sops be of the form sops exec-file --input-type yaml --output-type yaml /tmp/test 'cat {}'
afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right thing to do here would be adding support for --output-type too.
Well that's fair. PR is updated for same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than the small change to the command line help
Co-authored-by: Adrian Utrilla <[email protected]>
This PR resolves #652, adding support for an
--input-type
argument that will be honored bysops exec-file
.Until the argument for
func outputStore
was reversed (to useinput-type
instead ofoutput-type
) sops kept crashing with the message:This is certainly a debatable fix, but results were positive.