-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix checkout/init change summaries #3496
Conversation
This reverts commit fe2051f. Buildplan itself should never filter its artifacts, filtering is for consuming code.
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.
My comments and questions are all nits
@@ -45,7 +68,7 @@ func Unmarshal(data []byte) (*BuildPlan, error) { | |||
} | |||
|
|||
func (b *BuildPlan) Marshal() ([]byte, error) { | |||
return json.Marshal(b.raw) | |||
return json.MarshalIndent(b.raw, "", " ") |
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 don't think this has an effect on parsing, but MarshalIndent is for a more readable output. Was this for debugging and do we want to keep it?
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.
It was indeed for debugging, but I figured it would be worth keeping. It'll be useful if we're doing proxy debugging. And the extra whitespace really doesn't have a noticeable effect on performance.
@@ -212,7 +214,7 @@ func (b *BuildPlan) sanityCheck() error { | |||
// Ensure all artifacts have an associated ingredient | |||
// If this fails either the API is bugged or the hydrate logic is bugged | |||
for _, a := range b.Artifacts() { | |||
if len(a.Ingredients) == 0 { | |||
if raw.IsStateToolMimeType(a.MimeType) && len(a.Ingredients) == 0 { |
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're only concerned with state tool artifacts having ingredients now?
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.
They're the only type of artifact that is guaranteed to have an ingredient, so the only thing we can reasonably validate.
pkg/buildplan/buildplan.go
Outdated
// Sort buildplan slices to ensure consistency, because the API does not guarantee a consistent ordering | ||
sort.Slice(b.raw.Sources, func(i, j int) bool { return b.raw.Sources[i].NodeID < b.raw.Sources[j].NodeID }) | ||
sort.Slice(b.raw.Steps, func(i, j int) bool { return b.raw.Steps[i].StepID < b.raw.Steps[j].StepID }) | ||
sort.Slice(b.raw.Artifacts, func(i, j int) bool { return b.raw.Artifacts[i].NodeID < b.raw.Artifacts[j].NodeID }) | ||
sort.Slice(b.raw.Terminals, func(i, j int) bool { return b.raw.Terminals[i].Tag < b.raw.Terminals[j].Tag }) | ||
sort.Slice(b.raw.ResolvedRequirements, func(i, j int) bool { | ||
return b.raw.ResolvedRequirements[i].Source < b.raw.ResolvedRequirements[j].Source | ||
}) | ||
for _, t := range b.raw.Terminals { | ||
sort.Slice(t.NodeIDs, func(i, j int) bool { return t.NodeIDs[i] < t.NodeIDs[j] }) | ||
} | ||
for _, a := range b.raw.Artifacts { | ||
sort.Slice(a.RuntimeDependencies, func(i, j int) bool { return a.RuntimeDependencies[i] < a.RuntimeDependencies[j] }) | ||
} | ||
for _, step := range b.raw.Steps { | ||
sort.Slice(step.Inputs, func(i, j int) bool { return step.Inputs[i].Tag < step.Inputs[j].Tag }) | ||
sort.Slice(step.Outputs, func(i, j int) bool { return step.Outputs[i] < step.Outputs[j] }) | ||
for _, input := range step.Inputs { | ||
sort.Slice(input.NodeIDs, func(i, j int) bool { return input.NodeIDs[i] < input.NodeIDs[j] }) | ||
} | ||
} |
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.
nit: Might be nice to have this in a method similar to how you have b.cleanup()
above.
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.
Good call!
pkg/buildplan/mock_test.go
Outdated
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001"} | ||
artifact0002 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000002"} | ||
artifact0003 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000003"} | ||
artifact0001 := &Artifact{ArtifactID: "00000000-0000-0000-0000-000000000001", MimeType: types.XArtifactMimeType} |
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 added these mime types when I was trying to filter on them. Are they still needed?
Ran into several issues in fixing this: