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

[WIP] patcher concepts: what is a patch #2180

Merged
merged 6 commits into from
Nov 22, 2024

Conversation

ceschae
Copy link
Contributor

@ceschae ceschae commented Nov 12, 2024

To-Dos

  • outstanding screenshots to incorporate. will go out with next push

Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 22, 2024 9:40pm

Copy link
Contributor

@josh-padnick josh-padnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bunch of comments. This is a good start, but overall we need to set more context, and be more explicit.

@@ -1,3 +1,48 @@
# What is a Patcher Patch?

This page is under construction
A Patcher Patch is a set of instructions that Patcher can carry out to resolve a breaking change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just call it a "Patch" rather than "Patcher Patch." Though we should clarify that patches work specifically with Patcher.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Patcher Patch is a set of instructions that Patcher can carry out to resolve a breaking change.

Can we be even more explicit? Something like:

A Patch is a set of instructions executed by Patcher that do code transformations. This is especially useful as a way to automate adoption of a breaking change with infrastructure as code, such as Terragrunt, OpenTofu, or Terraform.

docs/2.0/docs/patcher/concepts/patches.md Show resolved Hide resolved
# etc
```

## As a Consumer of Patches...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we reword to "For Module Consumers" and the section below to "For Module Authors"? In the end, anyone who writes patches will be the one who writes modules.


## As a Consumer of Patches...

All that's required to ingest patches for breaking IaC changes is to run a `patcher update` (with whatever flags you deem appropriate).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we set more context here? I'm assuming the user has no idea what Patcher is and is now reading this concepts section to understand it, so let's set the stage more.

For example:

As a module consumer, you make use of OpenTofu/Terraform modules to launch infrastructure by writing Terragrunt units (terragrunt.hcl files) or OpenTofu/Terraform code that calls a module.

It's a best practice to reference a specific version of an OpenTofu/Terraform module. But, over time, module authors release new versions of the module, and your consuming code slowly gets out of date. In some cases, the latest update of the underlying modules requires a breaking change to your code, meaning you can't just bump the version; you actually need to edit your consuming code to make use of the new version. That's when using a patch with Patcher comes in handy.

Patches can be consumed either by "push" -- when Patcher proactively opens a pull request with the latest update -- or a "pull" -- when you manually scan your repo to look at the current state of your infrastructure using the Patcher CLI tool.

Let's take a look at the experience of "pulling" available updates by using the Patcher CLI tool. The first step is to run patcher update...

Also, can you list an example of a full command the user would run, including the flags? This makes it more concrete for the user.


All that's required to ingest patches for breaking IaC changes is to run a `patcher update` (with whatever flags you deem appropriate).

This command can be run locally, in which case, the steps outlined in the patch(es) would be executed within your codebase, and it would be up to you to apply IoC changes, or open them in a PR against your codebase, whichever is appropriate for your use case.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds confusing as written. Can you more clearly separate the specific things that are happening?

For example:

  • patcher update executes the steps in the patch
  • This changes the code in your local environment, but does not commit it or do any kind of terragrunt apply or other operation against it.
  • It's up to you to apply the code and open a PR that submits it for review.


This command can be run locally, in which case, the steps outlined in the patch(es) would be executed within your codebase, and it would be up to you to apply IoC changes, or open them in a PR against your codebase, whichever is appropriate for your use case.

Additionally, Gruntwork offers a GitHub Action to automate this process for you.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the "push" intro for this. Consider adding a header for pull and one for push.


Additionally, Gruntwork offers a GitHub Action to automate this process for you.
Using the GitHub action, PRs will be opened against your codebase on a cadence specified by you, against environments, versions, etc. specified by you.
The intention with this GitHub action is to leave you, the repo owner, in full control of your upgrade cadence.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include PR screenshot?


## As an Author of Patches...

As an author of a patch, this means that you are publishing a breaking change with a release of your module.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch to more active language. Instead of "this means that you are...," consider language like "Module authors periodically need to introduce breaking changes in their modules, causing a downstream painful experience for module consumers. With patches, module authors write not only the updated module code, but also include a patch YAML file that automatically updates consuming code to incorporate the breaking changes.

use patches to enable their modules consumers to automatically update consuming code to adopt breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like your verbage! incorporated 👍

as a general note, you'll likely notice i abstain from assertive/aggressive language. if i swung too far away from the docs site's conventions, please do feel free to call me out, always happy to fix it!


Here is an example of what your PR will look like, after being generated by Patcher:

** insert image of PR screenshot **
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO @ceschae

The intention with this GitHub action is to leave the repo owner in full control of your upgrade cadence.

<details>
<summary>The example configuration is long. Click to expand!</summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit too casual IMO for our docs and doesn't match the style used elsewhere. How about just something very direct "GitHub Actions Workflow Example"

When `patcher update` is run, the default mode is to click through the updates **interactively**.
In this mode, available updates are found, and the details of those updates are presented to you:

** insert image here **
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ceschae TODO


You can choose to run in `--non-interactive` mode, which will modify the codebase and present results about what the program did at the end.

Interactively nor not, by default, a PR will _not_ be opened with the changes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Interactively nor not, by default, a PR will _not_ be opened with the changes.
By default a PR will _not_ be opened with the changes.


```bash
$ cd <repo-root-directory>
# give me ALL the patches for ALL the things
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again a bit too casual.

Suggested change
# give me ALL the patches for ALL the things
# Show what patches are available for everything in the current directory and all it's children

Using the GitHub action, PRs will be opened against your codebase on a cadence specified by you, against environments, versions, etc. specified by you.
The intention with this GitHub action is to leave the repo owner in full control of your upgrade cadence.

<details>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry this will go stale, and is also too much unexplained detail for a concept page. Maybe better to just remove it and link instead to the promotion workflows guides?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm which noun we're talking about - remove "it" being the full example?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the whole workflow file


```bash
# run 'update' non-interactively, only up to the next safe version, and publish a PR with the changes
$ patcher update --update-strategy next-safe --non-interactive --publish --pr-branch grunty/update-via-patcher --pr-title "[Patcher] Update All Dependencies to Next Safe"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example references a handful of concepts the user probably isn't aware of yet. I'd suggest either removing the advanced concepts or linking to them explicitly (specifically the idea of update strategies, publishing PRs directly via patcher update)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opting for a link instead of removing detail. i personally find that a complex example gets the gears turning for folks, and keeps them continuing to click through the docs. but i agree, providing a link to more docs is definitely needed, thank you!!

@ZachGoldberg ZachGoldberg merged commit 8c4b393 into main Nov 22, 2024
5 of 6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants