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

upgrade ko to v6 provider model #69

Closed
wants to merge 7 commits into from
Closed

Conversation

imjasonh
Copy link
Member

@imjasonh imjasonh commented Apr 27, 2023

There are some breaking changes involved here:

  • ko_image is removed 🖖
  • provider docker_repo becomes repo 🧹
  • the ko_build resource's docker_repo attribute becomes repo 🧹
  • state is probably not retained in the upgrade, either because it's impossible, or because I messed it up.

I expect this to be a rocky upgrade 😕

@imjasonh imjasonh marked this pull request as ready for review April 28, 2023 19:21
@@ -41,8 +38,8 @@ func TestAccResourceKoResolve(t *testing.T) {
}
`,
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("ko_resolve.foo", "manifests.0", regexp.MustCompile("^0: "+url+"/test-46c4b272b3716c422d5ff6dfc7547fa9@sha256:")),
resource.TestMatchResourceAttr("ko_resolve.foo", "manifests.1", regexp.MustCompile("^1: "+url+"/test-46c4b272b3716c422d5ff6dfc7547fa9@sha256:")),
resource.TestMatchResourceAttr("ko_resolve.foo", "manifests.0", regexp.MustCompile("0: "+repo.String()+"/github.com/google/ko/test@sha256:")),
Copy link
Contributor

Choose a reason for hiding this comment

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

What's driving the namer change? I think we want to match ko's default here so that we work with DockerHub and friends, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll back this out, since it's a needless behavior change in an already-too-big change.

But I'd like to get us to the point where we define behaviors like this at the provider level, and we can document "for Dockerhub, set provider's namer to BLAH" and have the default be full importpaths.

I don't think it's worth doing the same for ko since it's harder to configure setting -P for all invocations of ko, but it's easier here in IaC-land.

Copy link
Member Author

Choose a reason for hiding this comment

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

ko_build actually defaults to --preserve-import-paths, which is probably not great.

Filed #71 to track aligning these and making a provider-wide default.

Signed-off-by: Jason Hall <[email protected]>
"repo": schema.StringAttribute{
Description: "Container repository to publish images to. If set, this overrides the provider's docker_repo, and the image name will be exactly the specified `repo`, without the importpath appended.",
Optional: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting thought exercise... This is a "ForceNew" but does changing it at the provider level (when it is unspecified here) cause a rebuilt? 🤔

This might be a "ForceNew" hole in our logic, but worth trying out (not sure if a test is practical)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. We can't set plan modifiers on fields at the provider level. Changing it (unless it matched the previous value specified on the resource) would result in a new result with a new ID, but I guess the question is whether TF would understand that as a change that should call Create vs Update. In either case I think we'd be fine, since Update does the same thing as Create. But this is based only on my shaky understanding of TF semantics, and not any kind of testing.

Copy link
Contributor

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

stamping since the comments are largely superficial.

Copy link
Contributor

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

I'd like to see what the upgrade implications of this are for a release before we release, e.g. with the prober module.

cc @nsmith5 in case he has ideas to make the docker_repo -> repo change go smoother.

internal/provider/provider.go Outdated Show resolved Hide resolved
Signed-off-by: Jason Hall <[email protected]>
@nsmith5
Copy link
Collaborator

nsmith5 commented Jun 9, 2023

Yeah I don't really have any suggestions. There are state upgraders that can move the data from docker_repo over to repo but you still need to go to every resource and change the name. I don't really think implementing the state upgraders is necessary for this module as the provider is pretty stateless already and the cost of the diff is just a ko build that was probably already going to happen anyways.

@cpanato
Copy link
Member

cpanato commented Jun 20, 2023

@mattmoor @imjasonh this is pending for any follow up or can we merge this?

@nsmith5 nsmith5 removed their request for review August 29, 2023 22:34
@cpanato
Copy link
Member

cpanato commented Dec 3, 2023

@imjasonh need rebase

@imjasonh imjasonh closed this Dec 3, 2023
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.

4 participants