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

Refactor: move plugin kind to apitype #15946

Merged
merged 10 commits into from
Apr 25, 2024
Merged

Conversation

glena
Copy link
Contributor

@glena glena commented Apr 15, 2024

Description

This PR moves PluginKind to apitype to prevent circular dependencies when adding apitype as a dependency of the workspace module.
It also re-exports PluginKind to keep backward compatibility

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Apr 15, 2024

Changelog

[uncommitted] (2024-04-25)

Miscellaneous

  • [cli/plugin] Move PluginKind type definition into apitype and re-export for backward compatibility
    #15946

@glena glena force-pushed the german/refactor-pluginkind branch from c8e399f to 5351677 Compare April 15, 2024 21:26
@glena glena marked this pull request as ready for review April 16, 2024 14:56
@glena glena requested a review from a team as a code owner April 16, 2024 14:56
Comment on lines 1501 to 1512
const (
// AnalyzerPlugin is a plugin that can be used as a resource analyzer.
AnalyzerPlugin PluginKind = "analyzer"
// LanguagePlugin is a plugin that can be used as a language host.
LanguagePlugin PluginKind = "language"
// ResourcePlugin is a plugin that can be used as a resource provider for custom CRUD operations.
ResourcePlugin PluginKind = "resource"
// ConverterPlugin is a plugin that can be used to convert from other ecosystems to Pulumi.
ConverterPlugin PluginKind = "converter"
// ToolPlugin is an arbitrary plugin that can be run as a tool.
ToolPlugin PluginKind = "tool"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to re-export these as well? Otherwise I think this is still a backwards incompatible change.

Of course that makes it quite awkward to keep in sync,

Copy link
Member

Choose a reason for hiding this comment

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

We do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes I just pushed it. It sucks tho... wonder how can we do it differently

The source of the circular dependency is this line https://github.com/pulumi/pulumi/pull/15945/files#diff-c59945d33c5fccb80d8b16ea994dfd17192bdd306b70f7feb07c73031fd88f72R855

because apitype depends on workspace in this line

Type workspace.PluginKind `json:"type" yaml:"type"`

I could move all the deployment settings definitions under workspace and avoid all this refactor (which I dont like but might simplify everything). What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I agree that it kinda sucks. I guess on second thought we don't actually need to keep them in sync though, if we're introducing new plugin types we can just add it to the apitype package, as that won't be a breaking change, and people can move over to that.

If move the deployment settings definitions under workspace that also gets a bit awkward.

Another potential option would be to create a new package in pulumi/sdk/go/common/apitype/deployment and only have the deployment definitions there? Though I guess that doesn't work either because DeploymentSettings would still depend on apitype, so we'd just get the same dependency cycle again. And to break that we'd have to move all of that stuff to apitype/deployment, which means we have to re-export a bunch more stuff, which is not better.

So I guess this is maybe the best we can do unless someone can come up with a smarter idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tgummerer so I believe this is ready now. Not sure if the failed Downstream Codegen Tests status are something to look into.

Question, should we add a deprecation notice to the re-exported types redirecting people to use apitype?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The codegen tests look like they failed to even create the downstream PR, and timed out. I'm trying to re-run them, but I think we can merge this either way, as it doesn't look like it's actually changing anything in codegen, other than some refactoring, so there's a pretty low chance of something breaking downstream.

I see you did add a deprecation notice already, and I think that's the right place to put it, I don't think we need anything in addition to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you merge the pr? I cant (I assume because of the downstream tests)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Huh weird, I expected you to be able to merge it either way. I added it to the merge queue now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you merge it again? I just rebased and fixed a new usage of workspace.ResourcePlugin that made the lint fail

@glena glena force-pushed the german/refactor-pluginkind branch from f50bbaf to 3ea51c5 Compare April 23, 2024 18:04
LanguagePlugin = apitype.LanguagePlugin
ResourcePlugin = apitype.ResourcePlugin
ConverterPlugin = apitype.ConverterPlugin
ToolPlugin = apitype.ToolPlugin
)

// IsPluginKind returns true if k is a valid plugin kind, and false otherwise.
func IsPluginKind(k string) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels maybe a little bit odd not to have this in apitype as well, but I don't think it's worth moving unless we actually have to.

Copy link
Contributor Author

@glena glena Apr 24, 2024

Choose a reason for hiding this comment

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

it makes sense I just moved it too

@tgummerer tgummerer added this pull request to the merge queue Apr 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 25, 2024
@glena glena force-pushed the german/refactor-pluginkind branch from bf380a6 to 9214bef Compare April 25, 2024 16:15
@tgummerer tgummerer added this pull request to the merge queue Apr 25, 2024
Merged via the queue into master with commit d7f24df Apr 25, 2024
50 of 56 checks passed
@tgummerer tgummerer deleted the german/refactor-pluginkind branch April 25, 2024 18:12
@justinvp justinvp mentioned this pull request Apr 25, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 26, 2024
Will wait to merge this until after
#16057 merges

### Features

- [auto/{go,nodejs,python}] Add support for the continue-on-error
parameter of the up command to the Automation API
  [#15953](#15953)

- [engine] Add a --continue-on-error flag to pulumi up
  [#15740](#15740)


### Bug Fixes

- [sdk/nodejs] Fix a race condition that could cause the NodeJS runtime
to terminate before finishing all work
  [#16005](#16005)

- [sdk/python] Fix an exception when setting providers resource option
with a dict
  [#16022](#16022)

- [sdk/python] Fix event loop tracking in the python SDK when using
remote transforms
  [#16039](#16039)

- [sdk/python] Workaround lazy module loading regression
  [#16038](#16038)


### Miscellaneous

- [cli/plugin] Move PluginKind type definition into apitype and
re-export for backward compatibility
  [#15946](#15946)
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.

None yet

4 participants