Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Ensure generated template modtime is Unix epoch #2473

Merged
merged 1 commit into from
Sep 25, 2019

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Sep 24, 2019

vsfgen which we use for maintaining an embedded copy of our templates
does also include the modtime of the files.

This poses a problem in combination with git, as in a project managed
by git the modtime of a file depends on the time it was changed
through a local git action (e.g. a checkout from a different state
which results in a file write on disk) instead of the time of the
actual change.

This commit adds a wrapper around http.FileSystem that modifies
the file mod times to always return Unix epoch. So that the only
things resulting in a new generated_template.gogen.go are folder
and/or file content changes.

vsfgen which we use for maintaining an embedded copy of our templates
does also include the modtime of the files.

This poses a problem in combination with git, as in a project managed
by git the modtime of a file depends on the time it was changed
through a local git action (e.g. a checkout from a different state
which results in a file write on disk) instead of the time of the
actual change.

This commit adds a wrapper around `http.FileSystem` that modifies
the file mod times to always return Unix epoch. So that the only
things resulting in a new `generated_template.gogen.go` are folder
and/or file content changes.
@hiddeco hiddeco merged commit 5094941 into master Sep 25, 2019
@hiddeco hiddeco deleted the build/modtime-unix-epoch branch September 25, 2019 07:49
@2opremio
Copy link
Contributor

Nice, thanks!!!

@hiddeco hiddeco added this to the 1.15.0 milestone Oct 1, 2019
squaremo added a commit that referenced this pull request Oct 17, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges.

In general we don't care about the generated Go code, only about what
it produces. This commit removes it from git and from the uncommitted
change detection (`make check-generated`); and uses `fluxctl install`
to generate the example files, removing the need for the code
generating program to depend on the code it's generating.
squaremo added a commit that referenced this pull request Oct 17, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges.

In general we don't care about the generated Go code, only about what
it produces. This commit removes it from git and from the uncommitted
change detection (`make check-generated`); and uses `fluxctl install`
to generate the example files, removing the need for the code
generating program to depend on the code it's generating.
squaremo added a commit that referenced this pull request Oct 17, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges.

In general we don't care about the generated Go code, only about what
it produces. This commit removes it from git and from the uncommitted
change detection (`make check-generated`); and uses `fluxctl install`
to generate the example files, removing the need for the code
generating program to depend on the code it's generating.
squaremo added a commit that referenced this pull request Oct 17, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges.

In general we don't care about the generated Go code, only about what
it produces. This commit removes the generated file from the
"uncommitted change" detection (`make check-generated`); and uses
`fluxctl install` to generate the example files, removing the need for
the code generating program to depend on the code it's generating.

NB It's still necessary to commit the generated code, since other
projects depend on the install package.
squaremo added a commit that referenced this pull request Oct 17, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges.

In general we don't care about the generated Go code, only about what
it produces. This commit removes the generated file from the
"uncommitted change" detection (`make check-generated`); and uses
`fluxctl install` to generate the example files, removing the need for
the code generating program to depend on the code it's generating.

NB It's still necessary to commit the generated code, since other
projects depend on the install package.
squaremo added a commit that referenced this pull request Oct 21, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

(A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges. The solution there
still works here.)

In general we don't care about the generated Go code, only about what
it produces. This commit removes the generated file from the
"uncommitted change" detection (`make check-generated`); and uses
`fluxctl install` to generate the example files, removing the need for
the code generating program to depend on the code it's generating.

NB It's still necessary to commit the generated code, since other
projects depend on the install package.
squaremo added a commit that referenced this pull request Oct 21, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

(A related problem, worked around elsewhere (#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges. The solution there
still works here.)

In general we don't care about the generated Go code, only about what
it produces. This commit removes the generated file from the
"uncommitted change" detection (`make check-generated`); and uses
`fluxctl install` to generate the example files, removing the need for
the code generating program to depend on the code it's generating.

NB It's still necessary to commit the generated code, since other
projects depend on the install package.
mpashka pushed a commit to pulsepointinc/flux that referenced this pull request Oct 24, 2019
For `fluxctl install`, we embed a set of templates in the fluxctl
binary by generating a fake filesystem as Go code
(pkg/install/generated_templates.gogen.go).

But the code that generates the fake filesystem also _depends_ on the
fake filesystem, since it does double duty as a program for generating
example manifests from those templates.

This leads to a problem: if anything has upset the generation process,
it's not possible to regenerate the files, since the generation tool
won't build.

(A related problem, worked around elsewhere (fluxcd#2473), is that it's easy
to introduce spurious differences in the generated code -- which,
since it's checked in -- means painful merges. The solution there
still works here.)

In general we don't care about the generated Go code, only about what
it produces. This commit removes the generated file from the
"uncommitted change" detection (`make check-generated`); and uses
`fluxctl install` to generate the example files, removing the need for
the code generating program to depend on the code it's generating.

NB It's still necessary to commit the generated code, since other
projects depend on the install package.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants