From 86d5fb595fe63e02ba2b34a75ad82c4dd5ff35d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Thu, 21 Dec 2023 18:19:30 +0100 Subject: [PATCH] add support for devcontainer --- .devcontainer/devcontainer.json | 26 ++++++++++++++++++++++++++ .devcontainer/setup.sh | 24 ++++++++++++++++++++++++ .devcontainer/welcome-message.txt | 20 ++++++++++++++++++++ .gitignore | 1 - 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/setup.sh create mode 100644 .devcontainer/welcome-message.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..3492f9a5e9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://containers.dev +{ + "name": "Kops environment from dev container", + // Image to pull when not building from scratch. See .devcontainer/build/devcontainer.json + // and .github/devcontainer-build-and-push.yml for the instructions on how this image is built + "image": "registry.k8s.io/build-image/kube-cross:v1.29.0-go1.21.3-bullseye.0", + // Setup the go environment and mount into the dev container at the expected location + "workspaceFolder": "/go/src/k8s.io/kops", + "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/k8s.io/kops,type=bind,consistency=cached", + // Ensure that the host machine has enough resources to build and test Kops + "hostRequirements": { + "cpus": 4 + }, + // Copy over welcome message and install pyyaml + "onCreateCommand": "bash .devcontainer/setup.sh", + // for Kubernetes testing, suppress extraneous forwarding messages + "otherPortsAttributes": { + "onAutoForward": "silent" + }, + "remoteUser": "root" + // Configure tool-specific properties. + // "customizations": { + // }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], +} \ No newline at end of file diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh new file mode 100644 index 0000000000..0f30e42dcc --- /dev/null +++ b/.devcontainer/setup.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eux + +# Copies over welcome message +cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt + +git remote add upstream https://github.com/kubernetes/kops.git +# Never push to upstream master +git remote set-url --push upstream no_push diff --git a/.devcontainer/welcome-message.txt b/.devcontainer/welcome-message.txt new file mode 100644 index 0000000000..bd6e4fd7ba --- /dev/null +++ b/.devcontainer/welcome-message.txt @@ -0,0 +1,20 @@ +👋 Welcome to Kops contribution in a dev container! + Works in GitHub Codespaces, VS Code, or in docker using the devcontainer cli + +See https://kops.sigs.k8s.io/contributing/ for guidance on contributing to Kops + +This debian dev container image satisfies https://github.com/kubernetes/community/blob/master/contributors/devel/development.md and includes: + - kubernetes/kubernetes repository + - Docker + - go + - kubectl, etcd, kubetest2, and kind +For details about dev containers and the debian dev container base image see https://containers.dev and https://github.com/devcontainers/images/tree/main/src/base-debian. +The configuration for the dev container is in the .github/.devcontainer folder. (will be moved to prow) +🎵 By default in Codespaces this environment uses a 4-core machine. Some tests may require a larger machine. In Codespaces you can change the machine type. + See https://docs.github.com/en/codespaces/customizing-your-codespace/changing-the-machine-type-for-your-codespace + +⚙️ If you are working in Codespaces on your own fork, this environment is automatically configured to support the GitHub + workflow https://www.kubernetes.dev/docs/guide/github-workflow/ (omit the clone step) +↪️ Otherwise Codespaces will automatically fork the repository for you when you make your first push + +🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1). diff --git a/.gitignore b/.gitignore index 9d6d2ebf0a..7381ff6f0b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ # Vscode files .vscode -.devcontainer # Emacs save files *~