-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add support for base and target trees in git ingest, add .tar.gz bundler #5181
base: main
Are you sure you want to change the base?
Conversation
3333aa7
to
889ac19
Compare
func BaseFileArchive(res *interfaces.Result) func(*rego.Rego) { | ||
return rego.Function1( | ||
®o.Function{ | ||
Name: "base_file.archive", |
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.
The PR description
says it would be file.bundle
. is this naming difference intentional?
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.
Talking with Ed, he suggested archive
instead.
// a tarball. It takes one argument: a list of file or directory paths to | ||
// include, and outputs the tarball as a string. | ||
// It's exposed as 'base_file.archive`. | ||
func BaseFileArchive(res *interfaces.Result) func(*rego.Rego) { |
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.
Do we want to expose this function to non PR/diff contexts too? I think it would be handy in general.
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.
See FileArchive
, above. 😁
// If the branch is not provided in the rule-type | ||
// configuration, use the default branch | ||
return defaultBranch | ||
checkpoint := checkpoints.NewCheckpointV1Now().WithBranch(ent.GetTargetRef()).WithCommitHash(head.Hash().String()) |
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.
We don't need to fix this in this PR... But... I wonder if we should have a base and target checkpoints checksum checkpoints?
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.
Since "base" is the branch that the PR will be merged into, I think that only changes if the target/head branch changes.
@@ -57,30 +70,47 @@ func FileExists(res *interfaces.Result) func(*rego.Rego) { | |||
Name: "file.exists", | |||
Decl: types.NewFunction(types.Args(types.S), types.B), | |||
}, | |||
func(_ rego.BuiltinContext, op1 *ast.Term) (*ast.Term, error) { |
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.
This diff looks really bad, but I just moved this to the return function from fsExists
func BaseFileArchive(res *interfaces.Result) func(*rego.Rego) { | ||
return rego.Function1( | ||
®o.Function{ | ||
Name: "base_file.archive", |
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.
Talking with Ed, he suggested archive
instead.
// a tarball. It takes one argument: a list of file or directory paths to | ||
// include, and outputs the tarball as a string. | ||
// It's exposed as 'base_file.archive`. | ||
func BaseFileArchive(res *interfaces.Result) func(*rego.Rego) { |
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.
See FileArchive
, above. 😁
// If the branch is not provided in the rule-type | ||
// configuration, use the default branch | ||
return defaultBranch | ||
checkpoint := checkpoints.NewCheckpointV1Now().WithBranch(ent.GetTargetRef()).WithCommitHash(head.Hash().String()) |
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.
Since "base" is the branch that the PR will be merged into, I think that only changes if the target/head branch changes.
Summary
Prepare for running external tools via Minder rego. This adds two features (sorry, I got on a roll!):
git
ingest during a pull request can access the PR base branch (what you want to merge to) viabase_file.*
analogues offile.*
operations.file.bundle
operation that takes a list of file paths and produces a.tar.gz
as a string.Change Type
Mark the type of change your PR introduces:
Testing
Unit testing for
lib
and some light manual testing for thegit
ingest.Review Checklist: