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 a VS Code devcontainer configuration #788

Merged
merged 19 commits into from
Jan 25, 2022
Merged

Conversation

olix0r
Copy link
Contributor

@olix0r olix0r commented Jan 19, 2022

Motivation

When loading kube-rs in VS Code, a variety of configurations are
needed to end up with a working environment. It does't Just Work out of
the box.

Solution

VS Code devcontainers make it easy to bootstrap a development
environment with project-specific tooling and configuration. This
configuration should also be usable in GitHub Codespaces.

This configuration ensures that various tools are available including:

  • cargo-deny
  • cargo-tarpaulin
  • k3d
  • kubectl
  • rust stable-1.56 toolchain
  • rust nightly toolchain
  • a few related VS Code plugins

While this developer image is based on rust 1.56 (the documented MSRV
for the project), it updates the default toolchain to be nightly so
clippy and rustfmt work as expected (since kube-rs depends on nightly
versions of these tools).


On one hand, I'd rather not commit configuration for any single editor into the repo. On the other hand, having a working development environment in VS Code should dramatically reduce the setup time for new contributors. We've recently adopted devcontainers in Linkerd (1 2), so I thought I'd share a modified version for kube-rs. At the very least, this would help me; but I won't be offended if this isn't accepted here.

Note that I've tried to omit anything touching developer-specific personalization (choice of shell, etc), leaving that to be configured in a dotfiles repo (eg) and in user-specific vscode configuration.

@codecov-commenter

This comment has been minimized.

.devcontainer/README.md Outdated Show resolved Hide resolved
.devcontainer/devcontainer.json Show resolved Hide resolved
.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
@clux
Copy link
Member

clux commented Jan 19, 2022

I think this is great. Thanks a lot for contributing this.
Need to have a few days for some time to play around with it, but I am happy to merge this in if it helps people.

@clux clux added the changelog-add changelog added category for prs label Jan 19, 2022
.devcontainer/Dockerfile Outdated Show resolved Hide resolved
@clux clux added this to the 0.68.0 milestone Jan 24, 2022
@clux
Copy link
Member

clux commented Jan 24, 2022

left some comments + suggestions + questions after having tested out the basics + the extensions. definitely merging this as it's pretty easy to maintain and an easy win.

some overall questions:

i guess the way you intend to use this is by creating a new sh terminal inside the container and using make test etc in there? do you want to be able to run lldb against examples? presumably this is doable, but didn't get that far.

i would have assumed the builtin tasks would be useful for less terminal use, but not even sure they forward into the devcontainer (or if they can be configured at this level) - there's another comment on that.

@olix0r
Copy link
Contributor Author

olix0r commented Jan 25, 2022

@clux

i guess the way you intend to use this is by creating a new sh terminal inside the container and using make test etc in there? do you want to be able to run lldb against examples? presumably this is doable, but didn't get that far.

i would have assumed the builtin tasks would be useful for less terminal use, but not even sure they forward into the devcontainer (or if they can be configured at this level) - there's another comment on that.

My workflow is generally to use a terminal to run compilations, etc (because RLS/compiling is painfully slow in Linkerd); but I should give tasks a shot in kube-rs. I'll take a look at configuring them.

Re: lldb, I didn't actually try it. I can remove that plugin for now. I think it was a recommended plugin for rust projects and I cargo-culted it here.

olix0r and others added 13 commits January 25, 2022 07:27
When loading `kube-rs` in VS Code, a variety of configurations are
needed to end up with a working environment. It does't Just Work out of
the box.

VS Code [devcontainers][dc] make it easy to bootstrap a development
environment with project-specific tooling and configuration. This
configuration should also be usable in [GitHub Codespaces][ghcs].

This configuration ensures that various tools are available including:

* `cargo-deny`
* `cargo-tarpaulin`
* `k3d`
* `kubectl`
* rust stable-1.58 toolchain
* rust nightly toolchain
* a variety of related VS Code plugins

While this developer image is based on rust 1.56 (the documented MSRV
for the project), it updates the default toolchain to be _nightly_ so
clippy and rustfmt work as expected (since `kube-rs` depends on nightly
versions of these tools).

[dc]: https://code.visualstudio.com/docs/remote/containers
[ghcs]: https://github.com/features/codespaces

Signed-off-by: Oliver Gould <ver@buoyant.io>
Co-authored-by: Eirik A <sszynrae@gmail.com>
Signed-off-by: Oliver Gould <ver@buoyant.io>
removing instructions on default features since they are all turned off
by default.

Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: clux <sszynrae@gmail.com>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
…ckerfile

Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Ensures that the devcontainer builds when the configuration changes.

Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
Signed-off-by: Oliver Gould <ver@buoyant.io>
@clux
Copy link
Member

clux commented Jan 25, 2022

I don't have any further comments on this. Are you happy with it as is?

Signed-off-by: Oliver Gould <ver@buoyant.io>
@olix0r
Copy link
Contributor Author

olix0r commented Jan 25, 2022

@clux I noticed a small issue with the dev container workflow, but fine to merge once the build is green :)

Thanks!

@clux clux merged commit 7b3c216 into kube-rs:master Jan 25, 2022
@olix0r olix0r deleted the ver/devcontainer branch January 26, 2022 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-add changelog added category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants