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

Add ability to generate .bicep file from a Kubernetes manifest #7812

Merged
merged 4 commits into from
Aug 5, 2022

Conversation

anthony-c-martin
Copy link
Member

@anthony-c-martin anthony-c-martin commented Aug 2, 2022

  • Add setting importsEnabledExperimental to VSIX package to enable/disable extensibility.
  • Add action importKubernetesManifest which takes a path to a kubernetes manifest, and generates a bicep file from it.
Microsoft Reviewers: Open in CodeFlow

@anthony-c-martin anthony-c-martin force-pushed the ant/kube_decomp branch 4 times, most recently from bce2a4f to e8af0e5 Compare August 2, 2022 19:33
Copy link
Contributor

@shenglol shenglol left a comment

Choose a reason for hiding this comment

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

:shipit:

public Task<ImportKubernetesManifestResponse> Handle(ImportKubernetesManifestRequest request, CancellationToken cancellationToken)
=> helper.ExecuteWithTelemetryAndErrorHandling(async () => {
var bicepFilePath = Path.ChangeExtension(request.ManifestFilePath, ".bicep");
var manifestContents = await File.ReadAllTextAsync(request.ManifestFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the right thing to do from the VS Code POV? I expected this to take a URI and need to interact with VS Code APIs to get the document. eg: will this work in remote scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a shortcut - the UI side brings up a file picker, meaning that you can only operate on on-disk files. Feels good enough for now, as there's no way I'm aware of to access the 'unsafe' behavior.

If we wanted to extend this in future, we'd need to either have the extension be aware of .yml files, or have the LSP send and receive the full file contents instead of sending/receiving URIs.

Copy link
Contributor

@rynowak rynowak left a comment

Choose a reason for hiding this comment

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

Overall the conversion algorithm seems good.

@anthony-c-martin anthony-c-martin enabled auto-merge (squash) August 5, 2022 19:38
@anthony-c-martin anthony-c-martin merged commit 36a97df into main Aug 5, 2022
@anthony-c-martin anthony-c-martin deleted the ant/kube_decomp branch August 5, 2022 20:40
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