diff --git a/.azure-pipelines-k8s-matrix.yml b/.azure-pipelines-k8s-matrix.yml new file mode 100644 index 0000000000..77129460a3 --- /dev/null +++ b/.azure-pipelines-k8s-matrix.yml @@ -0,0 +1,57 @@ +variables: + YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn + node_version: 12.x +pr: + branches: + include: + - master + - releases/* + paths: + exclude: + - .github/* + - docs/* + - mkdocs/* +trigger: none +jobs: + - job: Linux + pool: + vmImage: ubuntu-16.04 + strategy: + matrix: + kube_1.16: + kubernetes_version: v1.16.15 + kube_1.17: + kubernetes_version: v1.17.15 + kube_1.18: + kubernetes_version: v1.18.13 + kube_1.19: + kubernetes_version: v1.19.5 + kube_1.20: + kubernetes_version: v1.20.0 + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(node_version) + displayName: Install Node.js + - task: Cache@2 + inputs: + key: 'yarn | "$(Agent.OS)" | yarn.lock' + restoreKeys: | + yarn | "$(Agent.OS)" + path: $(YARN_CACHE_FOLDER) + displayName: Cache Yarn packages + - bash: | + sudo apt-get update + sudo apt-get install libgconf-2-4 conntrack -y + curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 + sudo install minikube-linux-amd64 /usr/local/bin/minikube + sudo minikube start --driver=none --kubernetes-version $(kubernetes_version) + # Although the kube and minikube config files are in placed $HOME they are owned by root + sudo chown -R $USER $HOME/.kube $HOME/.minikube + displayName: Install integration test dependencies + - script: make node_modules + displayName: Install dependencies + - script: make -j2 build + displayName: Run build + - script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' yarn integration + displayName: Run integration tests for Kubernetes $(kubernetes_version) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 33dfe83206..afec611177 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -1,15 +1,15 @@ variables: YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn -pr: - - master - - releases/* +pr: none trigger: - branches: - include: - - '*' tags: include: - "*" + paths: + exclude: + - .github/* + - docs/* + - mkdocs/* jobs: - job: Windows pool: @@ -22,12 +22,14 @@ jobs: - powershell: | $CI_BUILD_TAG = git describe --tags Write-Output ("##vso[task.setvariable variable=CI_BUILD_TAG;]$CI_BUILD_TAG") - displayName: 'Set the tag name as an environment variable' condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" + displayName: Set the tag name as an environment variable + - task: NodeTool@0 inputs: versionSpec: $(node_version) displayName: Install Node.js + - task: Cache@2 inputs: key: 'yarn | "$(Agent.OS)"" | yarn.lock' @@ -35,23 +37,33 @@ jobs: yarn | "$(Agent.OS)" path: $(YARN_CACHE_FOLDER) displayName: Cache Yarn packages + + - bash: | + set -e + git clone "https://${GH_TOKEN}@github.com/lensapp/lens-ide.git" .lens-ide-overlay + rm -rf .lens-ide-overlay/.git + cp -r .lens-ide-overlay/* ./ + jq -s '.[0] * .[1]' package.json package.ide.json > package.custom.json && mv package.custom.json package.json + env: + GH_TOKEN: $(LENS_IDE_GH_TOKEN) + displayName: Customize config + - script: make node_modules displayName: Install dependencies + - script: make build-npm displayName: Generate npm package - - script: make -j2 build-extensions - displayName: Build bundled extensions - - script: make integration-win - displayName: Run integration tests - - script: make test-extensions - displayName: Run In-tree Extension tests + - script: make build condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" - displayName: Build env: WIN_CSC_LINK: $(WIN_CSC_LINK) WIN_CSC_KEY_PASSWORD: $(WIN_CSC_KEY_PASSWORD) - GH_TOKEN: $(GH_TOKEN) + AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID) + AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) + BUILD_NUMBER: $(Build.BuildNumber) + displayName: Build + - job: macOS pool: vmImage: macOS-10.14 @@ -61,12 +73,14 @@ jobs: node_version: 12.x steps: - script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG" - displayName: Set the tag name as an environment variable condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" + displayName: Set the tag name as an environment variable + - task: NodeTool@0 inputs: versionSpec: $(node_version) displayName: Install Node.js + - task: Cache@2 inputs: key: 'yarn | "$(Agent.OS)" | yarn.lock' @@ -74,29 +88,35 @@ jobs: yarn | "$(Agent.OS)" path: $(YARN_CACHE_FOLDER) displayName: Cache Yarn packages + + - bash: | + set -e + git clone "https://${GH_TOKEN}@github.com/lensapp/lens-ide.git" .lens-ide-overlay + rm -rf .lens-ide-overlay/.git + cp -r .lens-ide-overlay/* ./ + jq -s '.[0] * .[1]' package.json package.ide.json > package.custom.json && mv package.custom.json package.json + env: + GH_TOKEN: $(LENS_IDE_GH_TOKEN) + displayName: Customize config + - script: make node_modules displayName: Install dependencies + - script: make build-npm displayName: Generate npm package - - script: make -j2 build-extensions - displayName: Build bundled extensions - - script: make test - displayName: Run tests - - script: make test-extensions - displayName: Run In-tree Extension tests - - script: make integration-mac - displayName: Run integration tests - - script: make test-extensions - displayName: Run In-tree Extension tests + - script: make build condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" - displayName: Build env: APPLEID: $(APPLEID) APPLEIDPASS: $(APPLEIDPASS) CSC_LINK: $(CSC_LINK) CSC_KEY_PASSWORD: $(CSC_KEY_PASSWORD) - GH_TOKEN: $(GH_TOKEN) + AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID) + AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) + BUILD_NUMBER: $(Build.BuildNumber) + displayName: Build + - job: Linux pool: vmImage: ubuntu-16.04 @@ -106,12 +126,14 @@ jobs: node_version: 12.x steps: - script: CI_BUILD_TAG=`git describe --tags` && echo "##vso[task.setvariable variable=CI_BUILD_TAG]$CI_BUILD_TAG" - displayName: Set the tag name as an environment variable condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" + displayName: Set the tag name as an environment variable + - task: NodeTool@0 inputs: versionSpec: $(node_version) displayName: Install Node.js + - task: Cache@2 inputs: key: 'yarn | "$(Agent.OS)" | yarn.lock' @@ -119,46 +141,38 @@ jobs: yarn | "$(Agent.OS)" path: $(YARN_CACHE_FOLDER) displayName: Cache Yarn packages + + - bash: | + set -e + git clone "https://${GH_TOKEN}@github.com/lensapp/lens-ide.git" .lens-ide-overlay + rm -rf .lens-ide-overlay/.git + cp -r .lens-ide-overlay/* ./ + jq -s '.[0] * .[1]' package.json package.ide.json > package.custom.json && mv package.custom.json package.json + env: + GH_TOKEN: $(LENS_IDE_GH_TOKEN) + displayName: Customize config + - script: make node_modules displayName: Install dependencies - - script: make lint - displayName: Lint + - script: make build-npm displayName: Generate npm package - - script: make -j2 build-extensions - displayName: Build bundled extensions - - script: make test - displayName: Run tests - - script: make test-extensions - displayName: Run In-tree Extension tests - - bash: | - sudo apt-get update - sudo apt-get install libgconf-2-4 conntrack -y - curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 - sudo install minikube-linux-amd64 /usr/local/bin/minikube - sudo minikube start --driver=none - # Although the kube and minikube config files are in placed $HOME they are owned by root - sudo chown -R $USER $HOME/.kube $HOME/.minikube - displayName: Install integration test dependencies - - script: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' make integration-linux - displayName: Run integration tests + - bash: | sudo chown root:root / sudo apt-get update && sudo apt-get install -y snapd sudo snap install snapcraft --classic echo -n "${SNAP_LOGIN}" | base64 -i -d > snap_login snapcraft login --with snap_login - displayName: Setup snapcraft condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" env: SNAP_LOGIN: $(SNAP_LOGIN) + displayName: Setup snapcraft + - script: make build + condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" + env: + AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID) + AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY) + BUILD_NUMBER: $(Build.BuildNumber) displayName: Build - condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" - env: - GH_TOKEN: $(GH_TOKEN) - - script: make publish-npm - displayName: Publish npm package - condition: "and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))" - env: - NPM_TOKEN: $(NPM_TOKEN) diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 1c16b275cb..0000000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - "@babel/preset-env", - "@babel/preset-react", - "@lingui/babel-preset-react" - ], - "plugins": [ - "macros", - "@babel/plugin-syntax-dynamic-import", - "@babel/plugin-transform-runtime" - ] -} diff --git a/.bundled-extensions.json b/.bundled-extensions.json new file mode 100644 index 0000000000..f521c01dfd --- /dev/null +++ b/.bundled-extensions.json @@ -0,0 +1,8 @@ +{ + "extensions": [ + "pod-menu", + "node-menu", + "metrics-cluster-feature", + "kube-object-event-status" + ] +} diff --git a/.eslintrc.js b/.eslintrc.js index 913d959a97..7ef30d22ff 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,84 +1,177 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +const packageJson = require("./package.json"); + module.exports = { ignorePatterns: [ "**/node_modules/**/*", "**/dist/**/*", + "**/static/**/*", ], + settings: { + react: { + version: packageJson.devDependencies.react || "detect", + } + }, overrides: [ { files: [ - "src/renderer/**/*.js", - "build/**/*.js", - "extensions/**/*.js" + "**/*.js" ], extends: [ - 'eslint:recommended', + "eslint:recommended", ], env: { node: true }, parserOptions: { ecmaVersion: 2018, - sourceType: 'module', + sourceType: "module", }, + plugins: [ + "header", + "unused-imports", + "react-hooks" + ], rules: { + "header/header": [2, "./license-header"], "indent": ["error", 2, { "SwitchCase": 1, }], "no-unused-vars": "off", + "unused-imports/no-unused-imports": "error", + "unused-imports/no-unused-vars": [ + "warn", { + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": true, + } + ], + "quotes": ["error", "double", { + "avoidEscape": true, + "allowTemplateLiterals": true, + }], + "linebreak-style": ["error", "unix"], + "eol-last": ["error", "always"], "semi": ["error", "always"], "object-shorthand": "error", + "prefer-template": "error", + "template-curly-spacing": "error", + "padding-line-between-statements": [ + "error", + { "blankLine": "always", "prev": "*", "next": "return" }, + { "blankLine": "always", "prev": "*", "next": "block-like" }, + { "blankLine": "always", "prev": "*", "next": "function" }, + { "blankLine": "always", "prev": "*", "next": "class" }, + { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, + ] } }, { files: [ - "build/*.ts", - "src/**/*.ts", - "integration/**/*.ts", - "src/extensions/**/*.ts*", - "extensions/**/*.ts*", - "__mocks__/*.ts", + "**/*.ts", ], parser: "@typescript-eslint/parser", extends: [ - 'plugin:@typescript-eslint/recommended', + "plugin:@typescript-eslint/recommended", + ], + plugins: [ + "header", + "unused-imports" ], parserOptions: { ecmaVersion: 2018, - sourceType: 'module', + sourceType: "module", }, rules: { + "header/header": [2, "./license-header"], + "no-invalid-this": "off", + "@typescript-eslint/no-invalid-this": ["error"], "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-unused-vars": "off", + "unused-imports/no-unused-imports-ts": "error", + "unused-imports/no-unused-vars-ts": [ + "warn", { + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": true, + } + ], "indent": ["error", 2, { "SwitchCase": 1, }], + "quotes": ["error", "double", { + "avoidEscape": true, + "allowTemplateLiterals": true, + }], + "react/prop-types": "off", "semi": "off", "@typescript-eslint/semi": ["error"], + "linebreak-style": ["error", "unix"], + "eol-last": ["error", "always"], "object-shorthand": "error", + "prefer-template": "error", + "template-curly-spacing": "error", + "padding-line-between-statements": [ + "error", + { "blankLine": "always", "prev": "*", "next": "return" }, + { "blankLine": "always", "prev": "*", "next": "block-like" }, + { "blankLine": "always", "prev": "*", "next": "function" }, + { "blankLine": "always", "prev": "*", "next": "class" }, + { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, + ] }, }, { files: [ - "src/renderer/**/*.tsx", + "**/*.tsx", ], parser: "@typescript-eslint/parser", + plugins: [ + "header", + "unused-imports" + ], extends: [ - 'plugin:@typescript-eslint/recommended', + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended", ], parserOptions: { ecmaVersion: 2018, - sourceType: 'module', + sourceType: "module", jsx: true, }, rules: { + "header/header": [2, "./license-header"], + "no-invalid-this": "off", + "@typescript-eslint/no-invalid-this": ["error"], "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/interface-name-prefix": "off", "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-empty-interface": "off", @@ -87,12 +180,42 @@ module.exports = { "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/no-empty-function": "off", + "react/display-name": "off", + "@typescript-eslint/no-unused-vars": "off", + "unused-imports/no-unused-imports-ts": "error", + "unused-imports/no-unused-vars-ts": [ + "warn", { + "vars": "all", + "args": "after-used", + "ignoreRestSiblings": true, + } + ], "indent": ["error", 2, { "SwitchCase": 1, }], + "quotes": ["error", "double", { + "avoidEscape": true, + "allowTemplateLiterals": true, + }], + "react/prop-types": "off", "semi": "off", "@typescript-eslint/semi": ["error"], + "linebreak-style": ["error", "unix"], + "eol-last": ["error", "always"], "object-shorthand": "error", + "prefer-template": "error", + "template-curly-spacing": "error", + "padding-line-between-statements": [ + "error", + { "blankLine": "always", "prev": "*", "next": "return" }, + { "blankLine": "always", "prev": "*", "next": "block-like" }, + { "blankLine": "always", "prev": "*", "next": "function" }, + { "blankLine": "always", "prev": "*", "next": "class" }, + { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" }, + { "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}, + ], + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "off" }, } ] diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..fccf0482de --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# This is the default code owners for the whole Lens repo +* @lensapp/lens-ide diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e25375fca9..dab52add93 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: '' -labels: '' +labels: 'bug' assignees: '' --- @@ -26,8 +26,8 @@ If applicable, add screenshots to help explain your problem. **Environment (please complete the following information):** - Lens Version: - OS: [e.g. OSX] -- Installation method (e.g. snap or AppImage in Linux): - +- Installation method (e.g. snap or AppImage in Linux): + **Logs:** When you run the application executable from command line you will see some logging output. Please paste them here: ``` diff --git a/.github/PULL_REQUEST_TEMPLATE/default.md b/.github/PULL_REQUEST_TEMPLATE/default.md new file mode 100644 index 0000000000..a54a6ef38c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/default.md @@ -0,0 +1,5 @@ +Fixes # + +**Description of changes:** + +- diff --git a/.github/PULL_REQUEST_TEMPLATE/release.md b/.github/PULL_REQUEST_TEMPLATE/release.md new file mode 100644 index 0000000000..11e5822025 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/release.md @@ -0,0 +1,13 @@ +## Changes since v + +## ๐Ÿš€ Features + +* + +## ๐Ÿ› Bug Fixes + +* + +## ๐Ÿงฐ Maintenance + +* diff --git a/.github/actions/add-card-to-project/Dockerfile b/.github/actions/add-card-to-project/Dockerfile new file mode 100644 index 0000000000..95c2fe1628 --- /dev/null +++ b/.github/actions/add-card-to-project/Dockerfile @@ -0,0 +1,11 @@ +# Container image that runs your code +FROM alpine:3.10 + +RUN apk add --no-cache --no-progress curl jq + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/add-card-to-project/action.yml b/.github/actions/add-card-to-project/action.yml new file mode 100644 index 0000000000..e7fcba44c6 --- /dev/null +++ b/.github/actions/add-card-to-project/action.yml @@ -0,0 +1,23 @@ +name: 'add_card_to_project' +description: 'A GitHub Action to add a card to a project and set the card position' +author: 'Steve Richards' +branding: + icon: 'command' + color: 'blue' +inputs: + project: + description: 'The url of the project to be assigned to.' + required: true + column_name: + description: 'The column name of the project, defaults to "To do" for issues and "In progress" for pull requests.' + required: false + card_position: + description: 'The card position of the card in the column, defaults to "bottom". Valid values are "top", "bottom" and "after:".' + required: false +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.project }} + - ${{ inputs.column_name }} + - ${{ inputs.card_position }} diff --git a/.github/actions/add-card-to-project/entrypoint.sh b/.github/actions/add-card-to-project/entrypoint.sh new file mode 100644 index 0000000000..a67bfb1d96 --- /dev/null +++ b/.github/actions/add-card-to-project/entrypoint.sh @@ -0,0 +1,157 @@ +#!/bin/sh -l + +PROJECT_URL="$INPUT_PROJECT" +if [ -z "$PROJECT_URL" ]; then + echo "PROJECT_URL is not defined." >&2 + exit 1 +fi + +get_project_type() { + _PROJECT_URL="$1" + + case "$_PROJECT_URL" in + https://github.com/orgs/*) + echo "org" + ;; + https://github.com/users/*) + echo "user" + ;; + https://github.com/*/projects/*) + echo "repo" + ;; + *) + echo "Invalid PROJECT_URL: $_PROJECT_URL" >&2 + exit 1 + ;; + esac + + unset _PROJECT_URL +} + +find_project_id() { + _PROJECT_TYPE="$1" + _PROJECT_URL="$2" + + case "$_PROJECT_TYPE" in + org) + _ORG_NAME=$(echo "$_PROJECT_URL" | sed -e 's@https://github.com/orgs/\([^/]\+\)/projects/[0-9]\+@\1@') + _ENDPOINT="https://api.github.com/orgs/$_ORG_NAME/projects" + ;; + user) + _USER_NAME=$(echo "$_PROJECT_URL" | sed -e 's@https://github.com/users/\([^/]\+\)/projects/[0-9]\+@\1@') + _ENDPOINT="https://api.github.com/users/$_USER_NAME/projects" + ;; + repo) + _ENDPOINT="https://api.github.com/repos/$GITHUB_REPOSITORY/projects" + ;; + esac + + _PROJECTS=$(curl -s -X GET -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \ + -H 'Accept: application/vnd.github.inertia-preview+json' \ + "$_ENDPOINT") + + _PROJECTID=$(echo "$_PROJECTS" | jq -r ".[] | select(.html_url == \"$_PROJECT_URL\").id") + + if [ "$_PROJECTID" != "" ]; then + echo "$_PROJECTID" + else + echo "No project was found." >&2 + exit 1 + fi + + unset _PROJECT_TYPE _PROJECT_URL _ORG_NAME _USER_NAME _ENDPOINT _PROJECTS _PROJECTID +} + +find_column_id() { + _PROJECT_ID="$1" + _INITIAL_COLUMN_NAME="$2" + + _COLUMNS=$(curl -s -X GET -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \ + -H 'Accept: application/vnd.github.inertia-preview+json' \ + "https://api.github.com/projects/$_PROJECT_ID/columns") + + + echo "$_COLUMNS" | jq -r ".[] | select(.name == \"$_INITIAL_COLUMN_NAME\").id" + unset _PROJECT_ID _INITIAL_COLUMN_NAME _COLUMNS +} + +PROJECT_TYPE=$(get_project_type "${PROJECT_URL:? required this environment variable}") + +if [ "$PROJECT_TYPE" = org ] || [ "$PROJECT_TYPE" = user ]; then + if [ -z "$MY_GITHUB_TOKEN" ]; then + echo "MY_GITHUB_TOKEN not defined" >&2 + exit 1 + fi + + TOKEN="$MY_GITHUB_TOKEN" # It's User's personal access token. It should be secret. +else + if [ -z "$GITHUB_TOKEN" ]; then + echo "GITHUB_TOKEN not defined" >&2 + exit 1 + fi + + TOKEN="$GITHUB_TOKEN" # GitHub sets. The scope in only the repository containing the workflow file. +fi + +INITIAL_COLUMN_NAME="$INPUT_COLUMN_NAME" +if [ -z "$INITIAL_COLUMN_NAME" ]; then + # assing the column name by default + INITIAL_COLUMN_NAME='To do' + if [ "$GITHUB_EVENT_NAME" == "pull_request" ] || [ "$GITHUB_EVENT_NAME" == "pull_request_target" ]; then + echo "changing col name for PR event" + INITIAL_COLUMN_NAME='In progress' + fi +fi + + +PROJECT_ID=$(find_project_id "$PROJECT_TYPE" "$PROJECT_URL") +INITIAL_COLUMN_ID=$(find_column_id "$PROJECT_ID" "${INITIAL_COLUMN_NAME:? required this environment variable}") + +if [ -z "$INITIAL_COLUMN_ID" ]; then + echo "INITIAL_COLUMN_ID is not found." >&2 + exit 1 +fi + +case "$GITHUB_EVENT_NAME" in + issues) + ISSUE_ID=$(jq -r '.issue.id' < "$GITHUB_EVENT_PATH") + + # Add this issue to the project column + _CARDS=$(curl -s -X POST -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \ + -H 'Accept: application/vnd.github.inertia-preview+json' \ + -d "{\"content_type\": \"Issue\", \"content_id\": $ISSUE_ID}" \ + "https://api.github.com/projects/columns/$INITIAL_COLUMN_ID/cards") + ;; + pull_request|pull_request_target) + PULL_REQUEST_ID=$(jq -r '.pull_request.id' < "$GITHUB_EVENT_PATH") + + # Add this pull_request to the project column + _CARDS=$(curl -s -X POST -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \ + -H 'Accept: application/vnd.github.inertia-preview+json' \ + -d "{\"content_type\": \"PullRequest\", \"content_id\": $PULL_REQUEST_ID}" \ + "https://api.github.com/projects/columns/$INITIAL_COLUMN_ID/cards") + ;; + *) + echo "Nothing to be done on this action: $GITHUB_EVENT_NAME" >&2 + exit 1 + ;; +esac + +CARDS_ID=$(echo "$_CARDS" | jq -r .id) +unset _CARDS + +if [ -z "$CARDS_ID" ]; then + echo "CARDS_ID is not found." >&2 + exit 1 +fi + +INITIAL_CARD_POSITION="$INPUT_CARD_POSITION" +if [ -z "$INITIAL_CARD_POSITION" ]; then + # assign the card position by default + INITIAL_CARD_POSITION='bottom' +fi + +_CARDS=$(curl -s -X POST -u "$GITHUB_ACTOR:$TOKEN" --retry 3 \ + -H 'Accept: application/vnd.github.inertia-preview+json' \ + -d "{\"position\": \"$INITIAL_CARD_POSITION\"}" \ + "https://api.github.com/projects/columns/cards/$CARDS_ID/moves") diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..822722ed6c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates +# for config options + +version: 2 +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: daily + open-pull-requests-limit: 4 + reviewers: + - lensapp/lens-ide + labels: + - dependencies + versioning-strategy: increase + ignore: + - dependency-name: "*" + update-types: + - version-update:semver-major diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..93536874e2 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,21 @@ +exclude-labels: + - 'skip-changelog' +categories: + - title: '๐Ÿš€ Features' + labels: + - 'enhancement' + - title: '๐Ÿ› Bug Fixes' + labels: + - 'bug' + - title: '๐Ÿงฐ Maintenance' + labels: + - 'chore' + - 'area/documentation' + - 'area/ci' + - 'area/tests' + - 'dependencies' + +template: | + ## Changes since $PREVIOUS_TAG + + $CHANGES diff --git a/.github/workflows/add-to-project-board.yaml b/.github/workflows/add-to-project-board.yaml new file mode 100644 index 0000000000..8f23cd406c --- /dev/null +++ b/.github/workflows/add-to-project-board.yaml @@ -0,0 +1,33 @@ +name: Add Card to Project(s) +on: + issues: + types: [opened] + pull_request_target: + types: [opened] +env: + MY_GITHUB_TOKEN: ${{ secrets.PROJECT_GITHUB_TOKEN }} + EVENT_TYPE: $GITHUB_EVENT_NAME + +jobs: + add_card_to_project: + runs-on: ubuntu-latest + name: Add Card to Project(s) + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Get Event Type + run: echo $GITHUB_EVENT_NAME + - name: Assign NEW issues to project 1 + uses: ./.github/actions/add-card-to-project + if: github.event_name == 'issues' && github.event.action == 'opened' + with: + project: 'https://github.com/orgs/lensapp/projects/1' + column_name: 'Backlog' + card_position: 'bottom' + - name: Assign NEW pull requests to project 1 + uses: ./.github/actions/add-card-to-project + if: github.event_name == 'pull_request_target' && github.event.action == 'opened' + with: + project: 'https://github.com/orgs/lensapp/projects/1' + column_name: 'PRs' + card_position: 'bottom' diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml new file mode 100644 index 0000000000..eafc6befc0 --- /dev/null +++ b/.github/workflows/check-docs.yml @@ -0,0 +1,30 @@ +name: Check Documentation +on: + - pull_request +jobs: + build: + name: Check Docs + runs-on: ubuntu-latest + if: ${{ contains(github.event.pull_request.labels.*.name, 'area/documentation') }} + strategy: + matrix: + node-version: [12.x] + steps: + - name: Checkout Release from lens + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Generate Extensions API Reference using typedocs + run: | + yarn install + yarn typedocs-extensions-api + + - name: Verify that the markdown is valid + run: | + yarn run verify-docs diff --git a/.github/workflows/license-header.yml b/.github/workflows/license-header.yml new file mode 100644 index 0000000000..daba6a9ca9 --- /dev/null +++ b/.github/workflows/license-header.yml @@ -0,0 +1,26 @@ +name: Check License Header +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + css: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Golang + uses: actions/setup-go@v2 + - name: Install addlicense + run: | + export PATH=${PATH}:`go env GOPATH`/bin + go get -v -u github.com/google/addlicense + - name: Check license headers + run: | + set -e + export PATH=${PATH}:`go env GOPATH`/bin + + addlicense -check -l mit -c "OpenLens Authors" src/**/*.?css diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000000..e847eab0f5 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,26 @@ +name: Lint Repo +on: + - pull_request +jobs: + build: + name: Lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + steps: + - name: Checkout Release from lens + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install deps + run: yarn install + + - name: Lint + run: yarn run lint diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d70f5f10dd..afbcc74367 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,15 +4,47 @@ on: branches: - master release: - types: + types: - published jobs: + verify-docs: + name: Verify docs + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Checkout Release from lens + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Generate Extensions API Reference using typedocs + run: | + yarn install + yarn typedocs-extensions-api + + - name: Verify that the markdown is valid + run: | + yarn run verify-docs + build: name: Deploy docs runs-on: ubuntu-latest strategy: matrix: node-version: [12.x] + needs: verify-docs steps: - name: Set up Python 3.7 uses: actions/setup-python@v2 @@ -25,7 +57,6 @@ jobs: pip install git+https://${{ secrets.GH_TOKEN }}@github.com/lensapp/mkdocs-material-insiders.git pip install mike - - name: Checkout Release from lens uses: actions/checkout@v2 with: @@ -52,13 +83,12 @@ jobs: mike deploy --push master - name: Get the release version - if: contains(github.ref, 'refs/tags/v') # && !github.event.release.prerelease (generate pre-release docs until Lens 4.0.0 is GA, see #1408) + if: contains(github.ref, 'refs/tags/v') && !github.event.release.prerelease id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - + - name: mkdocs deploy new release - if: contains(github.ref, 'refs/tags/v') # && !github.event.release.prerelease (generate pre-release docs until Lens 4.0.0 is GA, see #1408) + if: contains(github.ref, 'refs/tags/v') && !github.event.release.prerelease run: | mike deploy --push --update-aliases ${{ steps.get_version.outputs.VERSION }} latest mike set-default --push ${{ steps.get_version.outputs.VERSION }} - diff --git a/.github/workflows/maintenance.yml b/.github/workflows/maintenance.yml new file mode 100644 index 0000000000..dfa16b99c7 --- /dev/null +++ b/.github/workflows/maintenance.yml @@ -0,0 +1,22 @@ +name: "Maintenance" +on: + # So that PRs touching the same files as the push are updated + push: + # So that the `dirtyLabel` is removed if conflicts are resolve + # We recommend `pull_request_target` so that github secrets are available. + # In `pull_request` we wouldn't be able to change labels of fork PRs + pull_request_target: + types: [synchronize] + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: check if prs are dirty + uses: eps1lon/actions-label-merge-conflict@releases/2.x + with: + dirtyLabel: "PR: needs rebase" + removeOnDirtyLabel: "PR: ready to ship" + repoToken: "${{ secrets.GITHUB_TOKEN }}" + commentOnDirty: "This pull request has conflicts, please resolve those before we can evaluate the pull request." + commentOnClean: "Conflicts have been resolved. A maintainer will review the pull request shortly." diff --git a/.github/workflows/mkdocs-manual.yml b/.github/workflows/mkdocs-manual.yml new file mode 100644 index 0000000000..632fccfa7b --- /dev/null +++ b/.github/workflows/mkdocs-manual.yml @@ -0,0 +1,67 @@ +name: Manual documentation update to sync a deployed Version with Master branch +on: + workflow_dispatch: + inputs: + version: + description: 'Version string to use (e.g."v0.0.1")' + required: true +jobs: + build: + name: Manual documentation update to sync a deployed Version with Master branch + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install git+https://${{ secrets.GH_TOKEN }}@github.com/lensapp/mkdocs-material-insiders.git + pip install mike + + - name: Checkout Version from lens + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: '${{ github.event.inputs.version }}' + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Generate Extensions API Reference using typedocs + run: | + yarn install + yarn typedocs-extensions-api + + - name: Checkout master branch from lens + uses: actions/checkout@v2 + with: + path: 'master' + ref: 'master' + + - name: Bring in latest mkdocs.yml from master + run: | + cp -p ./master/mkdocs.yml . + cp -p ./master/docs/stylesheets/extra.css ./docs/stylesheets/extra.css + rm -fr ./docs/clusters ./docs/contributing ./docs/faq ./docs/getting-started ./docs/helm ./docs/support ./docs/supporting + sed -i '/Protocol Handlers/d' ./mkdocs.yml + sed -i '/IPC/d' ./mkdocs.yml + sed -i 's#../../clusters/adding-clusters.md#https://docs.k8slens.dev/latest/clusters/adding-clusters/#g' ./docs/extensions/get-started/your-first-extension.md + sed -i 's#clusters/adding-clusters.md#https://docs.k8slens.dev/latest/clusters/adding-clusters/#g' ./docs/README.md + sed -i 's#../../contributing/README.md#https://docs.k8slens.dev/latest/contributing/#g' ./docs/extensions/guides/generator.md + + - name: git config + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: mkdocs deploy new release + run: | + mike deploy --push --force ${{ github.event.inputs.version }} diff --git a/.github/workflows/publish-master-npm.yml b/.github/workflows/publish-master-npm.yml new file mode 100644 index 0000000000..2be9721d3e --- /dev/null +++ b/.github/workflows/publish-master-npm.yml @@ -0,0 +1,35 @@ +name: Publish NPM Package `master` +on: + push: + branches: + - master +jobs: + publish: + name: Publish NPM Package `master` + runs-on: ubuntu-latest + if: | + ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'area/extension') }} + strategy: + matrix: + node-version: [12.x] + steps: + - name: Checkout Release + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Generate NPM package + run: | + make build-npm + + - name: publish new release + run: | + make publish-npm + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_RELEASE_TAG: master diff --git a/.github/workflows/publish-release-npm.yml b/.github/workflows/publish-release-npm.yml new file mode 100644 index 0000000000..5a8bd9aff5 --- /dev/null +++ b/.github/workflows/publish-release-npm.yml @@ -0,0 +1,33 @@ +name: Publish NPM Package Release +on: + release: + types: + - published +jobs: + publish: + name: Publish NPM Package Release + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + steps: + - name: Checkout Release + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Generate NPM package + run: | + make build-npm + + - name: publish new release + if: contains(github.ref, 'refs/tags/v') + run: | + make publish-npm + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..ec49fec6e5 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..2ce53e59e2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,88 @@ +name: Test +on: + pull_request: + branches: + - "*" + push: + branches: + - master +jobs: + build: + name: Test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-16.04, macos-10.15, windows-2019] + node-version: [12.x] + steps: + - name: Checkout Release from lens + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Add the current IP address, long hostname and short hostname record to /etc/hosts file + if: runner.os == 'Linux' + run: | + echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts + + - name: Using Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - uses: nick-invision/retry@v2 + name: Install dependencies + with: + timeout_minutes: 10 + max_attempts: 3 + retry_on: error + command: make node_modules + + - run: make build-npm + name: Generate npm package + + - uses: nick-invision/retry@v2 + name: Build bundled extensions + with: + timeout_minutes: 15 + max_attempts: 3 + retry_on: error + command: make -j2 build-extensions + + - run: make test + name: Run tests + + - run: make test-extensions + name: Run In-tree Extension tests + + - run: | + sudo apt-get update + sudo apt-get install libgconf-2-4 conntrack -y + curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 + sudo install minikube-linux-amd64 /usr/local/bin/minikube + sudo minikube start --driver=none + # Although the kube and minikube config files are in placed $HOME they are owned by root + sudo chown -R $USER $HOME/.kube $HOME/.minikube + name: Install integration test dependencies + if: runner.os == 'Linux' + + - run: xvfb-run --auto-servernum --server-args='-screen 0, 1600x900x24' make integration + name: Run Linux integration tests + if: runner.os == 'Linux' + + - run: make integration + name: Run integration tests + shell: bash + if: runner.os != 'Linux' diff --git a/.gitignore b/.gitignore index 93a56f1243..d018f3b251 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ types/extension-api.d.ts types/extension-renderer-api.d.ts extensions/*/dist docs/extensions/api +site/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..7d7cef13d8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,57 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Main Process", + "type": "node", + "request": "launch", + "cwd": "${workspaceFolder}", + "protocol": "inspector", + "preLaunchTask": "compile-dev", + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" + }, + "runtimeArgs": [ + "--remote-debugging-port=9223", + "--inspect", + "." + ], + "outputCapture": "std" + }, + { + "name": "Renderer Process", + "type": "pwa-chrome", + "request": "attach", + "port": 9223, + "webRoot": "${workspaceFolder}", + "timeout": 30000 + }, + { + "name": "Integration Tests", + "type": "node", + "request": "launch", + "console": "integratedTerminal", + "runtimeArgs": [ + "${workspaceFolder}/node_modules/.bin/jest", + "--runInBand", + "integration" + ], + }, + { + "name": "Unit Tests", + "type": "node", + "request": "launch", + "internalConsoleOptions": "openOnSessionStart", + "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", + "args": [ + "--env=jsdom", + "-i", + "src" + ] + } + ], +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..03a7b306f7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,18 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "group": "build", + "command": "yarn", + "args": [ + "debug-build" + ], + "problemMatcher": [], + "label": "compile-dev", + "detail": "Compiles main and extension types" + } + ] +} \ No newline at end of file diff --git a/.yarnrc b/.yarnrc index 5119ded102..f11de8a2a9 100644 --- a/.yarnrc +++ b/.yarnrc @@ -1,3 +1,3 @@ disturl "https://atom.io/download/electron" -target "9.1.0" +target "9.4.4" runtime "electron" diff --git a/LICENSE b/LICENSE index b7a6d74205..208e7c2e9c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,10 @@ -Copyright (c) 2020 Mirantis, Inc. +Copyright (c) 2021 OpenLens Authors. Portions of this software are licensed as follows: -* All content residing under the "docs/" directory of this repository, if that +* All content residing under the "docs/" directory of this repository, if that directory exists, is licensed under "Creative Commons: CC BY-SA 4.0 license". -* All third party components incorporated into the Lens Software are licensed -under the original license provided by the owner of the applicable component. -* Content outside of the above mentioned directories or restrictions above is +* Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined below. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/Makefile b/Makefile index 1f8d4f5392..8b2558e7f7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,9 @@ +CMD_ARGS = $(filter-out $@,$(MAKECMDGOALS)) + +%: + @: + +NPM_RELEASE_TAG ?= latest EXTENSIONS_DIR = ./extensions extensions = $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), ${dir}) extension_node_modules = $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), ${dir}/node_modules) @@ -9,68 +15,68 @@ else DETECTED_OS := $(shell uname) endif -binaries/client: - yarn download-bins - -node_modules: - yarn install --frozen-lockfile --verbose +node_modules: yarn.lock + yarn install --frozen-lockfile --network-timeout=100000 yarn check --verify-tree --integrity -static/build/LensDev.html: +binaries/client: node_modules + yarn download-bins + +static/build/LensDev.html: node_modules yarn compile:renderer .PHONY: compile-dev -compile-dev: +compile-dev: node_modules yarn compile:main --cache yarn compile:renderer --cache .PHONY: dev -dev: node_modules binaries/client build-extensions static/build/LensDev.html +dev: binaries/client build-extensions static/build/LensDev.html yarn dev .PHONY: lint lint: yarn lint +.PHONY: release-version +release-version: + npm version $(CMD_ARGS) --git-tag-version false + +.PHONY: tag-release +tag-release: + scripts/tag-release.sh $(CMD_ARGS) + .PHONY: test test: binaries/client - yarn test + yarn run jest $(or $(CMD_ARGS), "src") -.PHONY: integration-linux -integration-linux: build-extension-types build-extensions - yarn build:linux +.PHONY: integration +integration: build yarn integration -.PHONY: integration-mac -integration-mac: build-extension-types build-extensions - yarn build:mac - yarn integration - -.PHONY: integration-win -integration-win: build-extension-types build-extensions - yarn build:win - yarn integration - -.PHONY: test-app -test-app: - yarn test - .PHONY: build -build: node_modules binaries/client build-extensions +build: node_modules binaries/client + yarn run npm:fix-build-version + $(MAKE) build-extensions -B + yarn run compile ifeq "$(DETECTED_OS)" "Windows" - yarn dist:win + yarn run electron-builder --publish onTag --x64 --ia32 else - yarn dist + yarn run electron-builder --publish onTag endif -$(extension_node_modules): - cd $(@:/node_modules=) && npm install --no-audit --no-fund +$(extension_node_modules): node_modules + cd $(@:/node_modules=) && ../../node_modules/.bin/npm install --no-audit --no-fund $(extension_dists): src/extensions/npm/extensions/dist - cd $(@:/dist=) && npm run build + cd $(@:/dist=) && ../../node_modules/.bin/npm run build + +.PHONY: clean-old-extensions +clean-old-extensions: + find ./extensions -mindepth 1 -maxdepth 1 -type d '!' -exec test -e '{}/package.json' \; -exec rm -rf {} \; .PHONY: build-extensions -build-extensions: $(extension_node_modules) $(extension_dists) +build-extensions: node_modules clean-old-extensions $(extension_node_modules) $(extension_dists) .PHONY: test-extensions test-extensions: $(extension_node_modules) @@ -84,7 +90,7 @@ copy-extension-themes: src/extensions/npm/extensions/__mocks__: cp -r __mocks__ src/extensions/npm/extensions/ -src/extensions/npm/extensions/dist: +src/extensions/npm/extensions/dist: node_modules yarn compile:extension-types .PHONY: build-npm @@ -92,12 +98,13 @@ build-npm: build-extension-types copy-extension-themes src/extensions/npm/extens yarn npm:fix-package-version .PHONY: build-extension-types -build-extension-types: src/extensions/npm/extensions/dist +build-extension-types: node_modules src/extensions/npm/extensions/dist .PHONY: publish-npm -publish-npm: build-npm - npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - cd src/extensions/npm/extensions && npm publish --access=public +publish-npm: node_modules build-npm + ./node_modules/.bin/npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" + cd src/extensions/npm/extensions && npm publish --access=public --tag=$(NPM_RELEASE_TAG) + git restore src/extensions/npm/extensions/package.json .PHONY: docs docs: @@ -105,34 +112,19 @@ docs: .PHONY: clean-extensions clean-extensions: -ifeq "$(DETECTED_OS)" "Windows" - $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), if exist $(dir)\dist del /s /q $(dir)\dist) - $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), if exist $(dir)\node_modules del /s /q $(dir)\node_modules) -else $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), rm -rf $(dir)/dist) $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), rm -rf $(dir)/node_modules) -endif + $(foreach dir, $(wildcard $(EXTENSIONS_DIR)/*), rm $(dir)/*.tgz || true) .PHONY: clean-npm clean-npm: -ifeq "$(DETECTED_OS)" "Windows" - if exist src\extensions\npm\extensions\dist del /s /q src\extensions\npm\extensions\dist - if exist src\extensions\npm\extensions\__mocks__ del /s /q src\extensions\npm\extensions\__mocks__ - if exist src\extensions\npm\extensions\node_modules del /s /q src\extensions\npm\extensions\node_modules -else rm -rf src/extensions/npm/extensions/dist rm -rf src/extensions/npm/extensions/__mocks__ rm -rf src/extensions/npm/extensions/node_modules -endif .PHONY: clean clean: clean-npm clean-extensions -ifeq "$(DETECTED_OS)" "Windows" - if exist binaries\client del /s /q binaries\client - if exist dist del /s /q dist\*.* - if exist static\build del /s /q static\build\*.* -else rm -rf binaries/client rm -rf dist/* rm -rf static/build/* -endif + rm -rf node_modules/ diff --git a/README.md b/README.md index 7d86bf6c52..595def597b 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,21 @@ -# Lens | The Kubernetes IDE +# Lens Open Source Project (OpenLens) -[![Build Status](https://dev.azure.com/lensapp/lensapp/_apis/build/status/lensapp.lens?branchName=master)](https://dev.azure.com/lensapp/lensapp/_build/latest?definitionId=1&branchName=master) -[![Releases](https://img.shields.io/github/downloads/lensapp/lens/total.svg)](https://github.com/lensapp/lens/releases?label=Downloads) +[![Build Status](https://github.com/lensapp/lens/actions/workflows/test.yml/badge.svg)](https://github.com/lensapp/lens/actions/workflows/test.yml) [![Chat on Slack](https://img.shields.io/badge/chat-on%20slack-blue.svg?logo=slack&longCache=true&style=flat)](https://join.slack.com/t/k8slens/shared_invite/enQtOTc5NjAyNjYyOTk4LWU1NDQ0ZGFkOWJkNTRhYTc2YjVmZDdkM2FkNGM5MjhiYTRhMDU2NDQ1MzIyMDA4ZGZlNmExOTc0N2JmY2M3ZGI) -Worldโ€™s most popular Kubernetes IDE provides a simplified, consistent entry point for developers, testers, integrators, and DevOps, to ship code faster at scale. Lens is the only IDE youโ€™ll ever need to take control of your Kubernetes clusters. It is a standalone application for MacOS, Windows and Linux operating systems. Lens is an open source project and free! +## The Repository -[![Screenshot](.github/screenshot.png)](https://youtu.be/04v2ODsmtIs) +This repository ("OpenLens") is where Team Lens develops the [Lens IDE](https://k8slens.dev) product together with the community. It is backed by a number of Kubernetes and cloud native ecosystem pioneers. This source code is available to everyone under the [MIT license](./LICENSE). -## What makes Lens special? +## Lens - The Kubernetes IDE -* Amazing usability and end-user experience -* Unified, secure, multi-cluster management on any platform: support for hundreds of clusters -* Standalone application: no need to install anything in-cluster -* Lens installs anywhere, elimanting the need to wrangle credentials -* Real-time cluster state visualization -* Resource utilization charts and trends with history powered by built-in Prometheus -* Smart terminal access to nodes and containers -* Clusters can be local (e.g. minikube) or external (e.g. EKS, GKE, AKS) -* Performance optimized to handle massive clusters (tested with a cluster running 25k pods) -* RBAC security is preserved, as Lens uses the standard Kubernetes API -* Lens Extensions are used to add custom visualizations and functionality to accelerate development workflows for all the technologies and services that integrate with Kubernetes -* Helm package deployment: Browse and deploy Helm charts with one click-Install +Lens - The Kubernetes IDE ("Lens IDE") is a distribution of the OpenLens repository with Team Lens specific customizations released under a traditional [EULA](https://k8slens.dev/licenses/eula). + +Lens IDE provides the full situational awareness for everything that runs in Kubernetes. It's lowering the barrier of entry for people just getting started and radically improving productivity for people with more experience. + +Lens IDE a standalone application for MacOS, Windows and Linux operating systems. You can download it free of charge for Windows, MacOS, and Linux from [Lens IDE website](https://k8slens.dev). + +[![Screenshot](.github/screenshot.png)](https://www.youtube.com/watch?v=eeDwdVXattc) ## Installation diff --git a/RELEASE_GUIDE.md b/RELEASE_GUIDE.md index da4bf01d94..5fdc1efa32 100644 --- a/RELEASE_GUIDE.md +++ b/RELEASE_GUIDE.md @@ -2,10 +2,20 @@ Lens releases are built by CICD automatically on git tags. The typical release process flow is the following: -1. Create a release branch `release/v{version}` from `master` branch or from existing release branch (for example, `release/v3.5`) on patch releases. -2. Update changelog in `static/RELEASE_NOTES.md` and bump version in `package.json`. -3. Create PR and put change log in description field. -4. After the PR is accepted, create a tag from release branch. -5. Push tag to GitHub. -6. Publish automatically created GitHub release. -7. Merge the release PR after the release is published and delete the release branch from GitHub. \ No newline at end of file +1. From a clean and up to date `master` run `make release-version ` where `` is one of the following: + - `major` + - `minor` + - `patch` + - `premajor` + - `preminor` + - `prepatch` + - `prerelease [--preid=]` + - where `` is generally one of: + - `alpha` + - `beta` + - `rc` +1. Create PR (git should have printed a link to GitHub in the console) with the contents of all the accepted PRs since the last release. +1. After the PR is accepted and passes CI. Go to the same branch and run `make tag-release` +1. Once CI passes again go to the releases tab on GitHub, create a new release from the tag that was created, make sure that the change log is the same as that of the PR. +1. Merge the release PR after the release is published. GitHub should delete the branch once it is merged. +1. If you have just released a new major or minor version then create a new `vMAJOR.MINOR` branch from that same tag and push it to master. This will be the target for future patch releases and shouldn't be deleted. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..b1a54ec9d0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,9 @@ +# Security Policy + +## Reporting a Vulnerability + +Team Lens encourages users who become aware of a security vulnerability in Lens to contact Team Lens with details of the vulnerability. Team Lens has established an email address that should be used for reporting a vulnerability. Please send descriptions of any vulnerabilities found to security@k8slens.dev. Please include details on the software and hardware configuration of your system so that we can duplicate the issue being reported. + +Team Lens hopes that users encountering a new vulnerability will contact us privately as it is in the best interests of our users that Team Lens has an opportunity to investigate and confirm a suspected vulnerability before it becomes public knowledge. + +In the case of vulnerabilities found in third-party software components used in Lens, please also notify Team Lens as described above. diff --git a/__mocks__/@linguiMacro.ts b/__mocks__/@linguiMacro.ts deleted file mode 100644 index 5a0c157331..0000000000 --- a/__mocks__/@linguiMacro.ts +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - Trans: ({ children }: { children: React.ReactNode }) => children, -}; diff --git a/__mocks__/electron.ts b/__mocks__/electron.ts index 86f35c956d..0a369eea4e 100644 --- a/__mocks__/electron.ts +++ b/__mocks__/electron.ts @@ -1,12 +1,30 @@ -module.exports = { +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +export default { require: jest.fn(), match: jest.fn(), app: { getVersion: jest.fn().mockReturnValue("3.0.0"), getLocale: jest.fn().mockRejectedValue("en"), - getPath: jest.fn((name: string) => { - return "tmp"; - }), + getPath: jest.fn(() => "tmp"), }, remote: { app: { diff --git a/__mocks__/imageMock.ts b/__mocks__/imageMock.ts new file mode 100644 index 0000000000..f80e118413 --- /dev/null +++ b/__mocks__/imageMock.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +export default {}; diff --git a/__mocks__/styleMock.ts b/__mocks__/styleMock.ts index a099545376..375355db28 100644 --- a/__mocks__/styleMock.ts +++ b/__mocks__/styleMock.ts @@ -1 +1,21 @@ -module.exports = {}; \ No newline at end of file +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +export default {}; diff --git a/build/build_tray_icon.ts b/build/build_tray_icon.ts index e02d884412..026edeb217 100644 --- a/build/build_tray_icon.ts +++ b/build/build_tray_icon.ts @@ -1,5 +1,23 @@ -// Generate tray icons from SVG to PNG + different sizes and colors (B&W) -// Command: `yarn build:tray-icons` +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ import path from "path"; import sharp from "sharp"; import jsdom from "jsdom"; @@ -7,24 +25,25 @@ import fs from "fs-extra"; export async function generateTrayIcon( { - outputFilename = "tray_icon", // e.g. output tray_icon_dark@2x.png + outputFilename = "trayIcon", svgIconPath = path.resolve(__dirname, "../src/renderer/components/icon/logo-lens.svg"), outputFolder = path.resolve(__dirname, "./tray"), dpiSuffix = "2x", pixelSize = 32, shouldUseDarkColors = false, // managed by electron.nativeTheme.shouldUseDarkColors } = {}) { - outputFilename += shouldUseDarkColors ? "_dark" : ""; + outputFilename += `${shouldUseDarkColors ? "Dark" : ""}Template`; // e.g. output trayIconDarkTemplate@2x.png dpiSuffix = dpiSuffix !== "1x" ? `@${dpiSuffix}` : ""; const pngIconDestPath = path.resolve(outputFolder, `${outputFilename}${dpiSuffix}.png`); + try { // Modify .SVG colors - const trayIconColor = shouldUseDarkColors ? "white" : "black"; + const trayIconColor = shouldUseDarkColors ? "black" : "white"; const svgDom = await jsdom.JSDOM.fromFile(svgIconPath); const svgRoot = svgDom.window.document.body.getElementsByTagName("svg")[0]; + svgRoot.innerHTML += ``; const svgIconBuffer = Buffer.from(svgRoot.outerHTML); - // Resize and convert to .PNG const pngIconBuffer: Buffer = await sharp(svgIconBuffer) .resize({ width: pixelSize, height: pixelSize }) @@ -45,6 +64,7 @@ const iconSizes: Record = { "2x": 32, "3x": 48, }; + Object.entries(iconSizes).forEach(([dpiSuffix, pixelSize]) => { generateTrayIcon({ dpiSuffix, pixelSize, shouldUseDarkColors: false }); generateTrayIcon({ dpiSuffix, pixelSize, shouldUseDarkColors: true }); diff --git a/build/download_helm.ts b/build/download_helm.ts index 7a3dc62a72..703684066b 100644 --- a/build/download_helm.ts +++ b/build/download_helm.ts @@ -1,3 +1,23 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ import { helmCli } from "../src/main/helm/helm-cli"; helmCli.ensureBinary(); diff --git a/build/download_kubectl.ts b/build/download_kubectl.ts index 137588ff58..819b73dd02 100644 --- a/build/download_kubectl.ts +++ b/build/download_kubectl.ts @@ -1,3 +1,23 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ import packageInfo from "../package.json"; import fs from "fs"; import request from "request"; @@ -5,6 +25,7 @@ import md5File from "md5-file"; import requestPromise from "request-promise-native"; import { ensureDir, pathExists } from "fs-extra"; import path from "path"; +import { noop } from "../src/common/utils"; class KubectlDownloader { public kubectlVersion: string; @@ -15,6 +36,7 @@ class KubectlDownloader { constructor(clusterVersion: string, platform: string, arch: string, target: string) { this.kubectlVersion = clusterVersion; const binaryName = platform === "windows" ? "kubectl.exe" : "kubectl"; + this.url = `https://storage.googleapis.com/kubernetes-release/release/v${this.kubectlVersion}/bin/${platform}/${arch}/${binaryName}`; this.dirname = path.dirname(target); this.path = target; @@ -25,25 +47,29 @@ class KubectlDownloader { method: "HEAD", uri: this.url, resolveWithFullResponse: true - }).catch((error) => { console.log(error); }); + }).catch(console.error); if (response.headers["etag"]) { return response.headers["etag"].replace(/"/g, ""); } + return ""; } public async checkBinary() { const exists = await pathExists(this.path); + if (exists) { const hash = md5File.sync(this.path); const etag = await this.urlEtag(); - if(hash == etag) { + + if (hash == etag) { console.log("Kubectl md5sum matches the remote etag"); + return true; } - console.log("Kubectl md5sum " + hash + " does not match the remote etag " + etag + ", unlinking and downloading again"); + console.log(`Kubectl md5sum ${hash} does not match the remote etag ${etag}, unlinking and downloading again`); await fs.promises.unlink(this.path); } @@ -51,14 +77,14 @@ class KubectlDownloader { } public async downloadKubectl() { - const exists = await this.checkBinary(); - if(exists) { - console.log("Already exists and is valid"); - return; + if (await this.checkBinary()) { + return console.log("Already exists and is valid"); } + await ensureDir(path.dirname(this.path), 0o755); const file = fs.createWriteStream(this.path); + console.log(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`); const requestOpts: request.UriOptions & request.CoreOptions = { uri: this.url, @@ -68,17 +94,16 @@ class KubectlDownloader { stream.on("complete", () => { console.log("kubectl binary download finished"); - // eslint-disable-next-line @typescript-eslint/no-empty-function - file.end(() => {}); + file.end(noop); }); stream.on("error", (error) => { console.log(error); - // eslint-disable-next-line @typescript-eslint/no-empty-function - fs.unlink(this.path, () => {}); - throw(error); + fs.unlink(this.path, noop); + throw error; }); - return new Promise((resolve, reject) => { + + return new Promise((resolve, reject) => { file.on("close", () => { console.log("kubectl binary download closed"); fs.chmod(this.path, 0o755, (err) => { @@ -92,18 +117,18 @@ class KubectlDownloader { } const downloadVersion = packageInfo.config.bundledKubectlVersion; -const baseDir = path.join(process.env.INIT_CWD, 'binaries', 'client'); +const baseDir = path.join(process.env.INIT_CWD, "binaries", "client"); const downloads = [ - { platform: 'linux', arch: 'amd64', target: path.join(baseDir, 'linux', 'x64', 'kubectl') }, - { platform: 'darwin', arch: 'amd64', target: path.join(baseDir, 'darwin', 'x64', 'kubectl') }, - { platform: 'windows', arch: 'amd64', target: path.join(baseDir, 'windows', 'x64', 'kubectl.exe') }, - { platform: 'windows', arch: '386', target: path.join(baseDir, 'windows', 'ia32', 'kubectl.exe') } + { platform: "linux", arch: "amd64", target: path.join(baseDir, "linux", "x64", "kubectl") }, + { platform: "darwin", arch: "amd64", target: path.join(baseDir, "darwin", "x64", "kubectl") }, + { platform: "windows", arch: "amd64", target: path.join(baseDir, "windows", "x64", "kubectl.exe") }, + { platform: "windows", arch: "386", target: path.join(baseDir, "windows", "ia32", "kubectl.exe") } ]; downloads.forEach((dlOpts) => { console.log(dlOpts); const downloader = new KubectlDownloader(downloadVersion, dlOpts.platform, dlOpts.arch, dlOpts.target); - console.log("Downloading: " + JSON.stringify(dlOpts)); + + console.log(`Downloading: ${JSON.stringify(dlOpts)}`); downloader.downloadKubectl().then(() => downloader.checkBinary().then(() => console.log("Download complete"))); }); - diff --git a/build/icons/512x512.png b/build/icons/512x512.png index 2c953f6efd..e08b9f5b15 100644 Binary files a/build/icons/512x512.png and b/build/icons/512x512.png differ diff --git a/build/icons/512x512@2x.png b/build/icons/512x512@2x.png new file mode 100644 index 0000000000..da0aa8ae80 Binary files /dev/null and b/build/icons/512x512@2x.png differ diff --git a/build/notarize.js b/build/notarize.js index 9904dccc3b..959f526ddd 100644 --- a/build/notarize.js +++ b/build/notarize.js @@ -1,10 +1,32 @@ -const { notarize } = require('electron-notarize'); +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +const { notarize } = require("electron-notarize"); exports.default = async function notarizing(context) { const { electronPlatformName, appOutDir } = context; - if (electronPlatformName !== 'darwin') { + + if (electronPlatformName !== "darwin") { return; } + if (!process.env.APPLEID || !process.env.APPLEIDPASS) { return; } @@ -12,7 +34,7 @@ exports.default = async function notarizing(context) { const appName = context.packager.appInfo.productFilename; return await notarize({ - appBundleId: 'io.kontena.lens-app', + appBundleId: "io.kontena.lens-app", appPath: `${appOutDir}/${appName}.app`, appleId: process.env.APPLEID, appleIdPassword: process.env.APPLEIDPASS, diff --git a/build/set_build_version.ts b/build/set_build_version.ts new file mode 100644 index 0000000000..ebf74d6fab --- /dev/null +++ b/build/set_build_version.ts @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import * as fse from "fs-extra"; +import * as path from "path"; +import appInfo from "../package.json"; +import semver from "semver"; +import fastGlob from "fast-glob"; + +const packagePath = path.join(__dirname, "../package.json"); +const versionInfo = semver.parse(appInfo.version); +const buildNumber = process.env.BUILD_NUMBER || Date.now().toString(); + +function getBuildChannel(): string { + switch (versionInfo.prerelease?.[0]) { + case "beta": + return "beta"; + case undefined: + return "latest"; + default: + return "alpha"; + } +} + +async function writeOutExtensionVersion(manifestPath: string) { + const extensionPackageJson = await fse.readJson(manifestPath); + + extensionPackageJson.version = appInfo.version; + + return fse.writeJson(manifestPath, extensionPackageJson, { + spaces: 2, + }); +} + +async function writeOutNewVersions() { + await Promise.all([ + fse.writeJson(packagePath, appInfo, { + spaces: 2, + }), + ...(await fastGlob(["extensions/*/package.json"])).map(writeOutExtensionVersion), + ]); +} + +function main() { + const prereleaseParts: string[] = [getBuildChannel()]; + + if (versionInfo.prerelease && versionInfo.prerelease.length > 1) { + prereleaseParts.push(versionInfo.prerelease[1].toString()); + } + + prereleaseParts.push(buildNumber); + + appInfo.version = `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}-${prereleaseParts.join(".")}`; + + writeOutNewVersions() + .catch((error) => { + console.error(error); + process.exit(1); + }); +} + +main(); diff --git a/build/set_npm_version.ts b/build/set_npm_version.ts index 17d4a1ef83..c0b24b54a6 100644 --- a/build/set_npm_version.ts +++ b/build/set_npm_version.ts @@ -1,9 +1,41 @@ +/** + * Copyright (c) 2021 OpenLens Authors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ import * as fs from "fs"; import * as path from "path"; import packageInfo from "../src/extensions/npm/extensions/package.json"; import appInfo from "../package.json"; +import { SemVer } from "semver"; +import { execSync } from "child_process"; -const packagePath = path.join(__dirname, "../src/extensions/npm/extensions/package.json"); +const { NPM_RELEASE_TAG = "latest" } = process.env; +const version = new SemVer(appInfo.version); -packageInfo.version = appInfo.version; -fs.writeFileSync(packagePath, JSON.stringify(packageInfo, null, 2) + "\n"); +if (NPM_RELEASE_TAG !== "latest") { + const gitRef = execSync("git rev-parse --short HEAD", { + encoding: "utf-8", + }); + + version.inc("prerelease", `git.${gitRef.trim()}`); +} + +packageInfo.version = version.format(); + +fs.writeFileSync(path.join(__dirname, "../src/extensions/npm/extensions/package.json"), `${JSON.stringify(packageInfo, null, 2)}\n`); diff --git a/build/tray/trayIconDarkTemplate.png b/build/tray/trayIconDarkTemplate.png new file mode 100644 index 0000000000..d0a4bdce20 Binary files /dev/null and b/build/tray/trayIconDarkTemplate.png differ diff --git a/build/tray/trayIconDarkTemplate@2x.png b/build/tray/trayIconDarkTemplate@2x.png new file mode 100644 index 0000000000..46615aa5bf Binary files /dev/null and b/build/tray/trayIconDarkTemplate@2x.png differ diff --git a/build/tray/trayIconDarkTemplate@3x.png b/build/tray/trayIconDarkTemplate@3x.png new file mode 100644 index 0000000000..0c018f3ed3 Binary files /dev/null and b/build/tray/trayIconDarkTemplate@3x.png differ diff --git a/build/tray/trayIconTemplate.png b/build/tray/trayIconTemplate.png new file mode 100644 index 0000000000..16ada5ad31 Binary files /dev/null and b/build/tray/trayIconTemplate.png differ diff --git a/build/tray/trayIconTemplate@2x.png b/build/tray/trayIconTemplate@2x.png new file mode 100644 index 0000000000..73c40de994 Binary files /dev/null and b/build/tray/trayIconTemplate@2x.png differ diff --git a/build/tray/trayIconTemplate@3x.png b/build/tray/trayIconTemplate@3x.png new file mode 100644 index 0000000000..d7a39b9260 Binary files /dev/null and b/build/tray/trayIconTemplate@3x.png differ diff --git a/build/tray/tray_icon.png b/build/tray/tray_icon.png deleted file mode 100644 index 73c7346d33..0000000000 Binary files a/build/tray/tray_icon.png and /dev/null differ diff --git a/build/tray/tray_icon@2x.png b/build/tray/tray_icon@2x.png deleted file mode 100644 index 71206802ac..0000000000 Binary files a/build/tray/tray_icon@2x.png and /dev/null differ diff --git a/build/tray/tray_icon@3x.png b/build/tray/tray_icon@3x.png deleted file mode 100644 index a293ba7d32..0000000000 Binary files a/build/tray/tray_icon@3x.png and /dev/null differ diff --git a/build/tray/tray_icon_dark.png b/build/tray/tray_icon_dark.png deleted file mode 100644 index 568d13e00b..0000000000 Binary files a/build/tray/tray_icon_dark.png and /dev/null differ diff --git a/build/tray/tray_icon_dark@2x.png b/build/tray/tray_icon_dark@2x.png deleted file mode 100644 index 3f28605dbf..0000000000 Binary files a/build/tray/tray_icon_dark@2x.png and /dev/null differ diff --git a/build/tray/tray_icon_dark@3x.png b/build/tray/tray_icon_dark@3x.png deleted file mode 100644 index 5e682a5d82..0000000000 Binary files a/build/tray/tray_icon_dark@3x.png and /dev/null differ diff --git a/docs/CNAME b/docs/CNAME index 12bc650410..f51f3799f9 100644 --- a/docs/CNAME +++ b/docs/CNAME @@ -1 +1 @@ -docs.k8slens.dev +api-docs.k8slens.dev diff --git a/docs/README.md b/docs/README.md index f8a979fb90..67369f86fc 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,21 +1,54 @@ -# Overview +# Lens Extension API -Lens is the most powerful Kubernetes IDE on the market. It is a standalone application, and it is available on macOS, Windows, and Linux. Some of the benefits of using Lens include: +Customize and enhance the Lens experience with the Lens Extension API. +Use the extension API to create menus or page content. +The same extension API was used to create many of Lens's core features. +To install your first extension you should goto the [extension page](lens://app/extensions) in lens. -* Confidence that your clusters are properly setup and configured. -* Increased visibility, real time statistics, log streams, and hands-on troubleshooting capabilities. -* The ability to work with your clusters quickly and easily, radically improving productivity and the speed of business. +This documentation describes: -Watch this introductory video to see Lens in action: +* How to build, run, test, and publish an extension. +* How to take full advantage of the Lens Extension API. +* Where to find [guides](extensions/guides/README.md) and [code samples](https://github.com/lensapp/lens-extension-samples) to help get you started. -[![Screenshot](img/lens-intro-video-screenshot.png)](https://youtu.be/04v2ODsmtIs) +## What Extensions Can Do -**Note:** Use CTRL+click (on Windows and Linux) or CMD+click (on MacOS) to open the above in a new tab +Here are some examples of what you can achieve with the Extension API: + +* Add custom components & views in the UI - Extending the Lens Workbench + +For an overview of the Lens Extension API, refer to the [Common Capabilities](extensions/capabilities/common-capabilities.md) page. [Extension Guides Overview](extensions/guides/README.md) also includes a list of code samples and guides that illustrate various ways of using the Lens Extension API. + +## How to Build Extensions + +Here is what each section of the Lens Extension API docs can help you with: + +* **Getting Started** teaches fundamental concepts for building extensions with the Hello World sample. +* **Extension Capabilities** dissects Lens's Extension API into smaller categories and points you to more detailed topics. +* **Extension Guides** includes guides and code samples that explain specific usages of Lens Extension API. +* **Testing and Publishing** includes in-depth guides on various extension development topics, such as testing and publishing extensions. +* **API Reference** contains exhaustive references for the Lens Extension API, Contribution Points, and many other topics. + +## What's New + +Just like Lens itself, the extension API updates on a monthly cadence, rolling out new features with every release. + +Keep up with Lens and the Lens Extension API by reviewing the [release notes](https://github.com/lensapp/lens/releases). + +## Important changes since Lens v4 + +Lens has undergone major design improvements in v5, which have resulted in several large changes to the extension API. +Workspaces are gone, and the catalog is introduced for containing clusters, as well as other items, including custom entities. +Lens has migrated from using mobx 5 to mobx 6 for internal state management, and this may have ramifications for extension implementations. +Although the API retains many components from v4, given these changes, extensions written for Lens v4 are not compatible with the Lens v5 extension API. +See the [Lens v4 to v5 extension migration notes](extensions/extension-migration.md) on getting old extensions working in Lens v5. + +## Looking for Help + +If you have questions for extension development, try asking on the [Lens Dev Slack](http://k8slens.slack.com/). It's a public chatroom for Lens developers, where Lens team members chime in from time to time. + +To provide feedback on the documentation or issues with the Lens Extension API, create new issues at [lensapp/lens](https://github.com/lensapp/lens/issues). Please use the labels `area/documentation` and/or `area/extension`. ## Downloading Lens -[Download Lens](https://github.com/lensapp/lens/releases) for macOS, Windows, or Linux. - -## Quick Start - -Get up and running quickly by learning to [add clusters](clusters/adding-clusters.md). +[Download Lens](https://k8slens.dev/) for macOS, Windows, or Linux. diff --git a/docs/clusters/adding-clusters.md b/docs/clusters/adding-clusters.md deleted file mode 100644 index d153d8c9bf..0000000000 --- a/docs/clusters/adding-clusters.md +++ /dev/null @@ -1,22 +0,0 @@ -# Adding Clusters - -Add clusters by clicking the **Add Cluster** button in the left-side menu. - -1. Click the **Add Cluster** button (indicated with a '+' icon). -2. Enter the path to your kubeconfig file. You'll need to have a kubeconfig file for the cluster you want to add. You can either browse for the path from the file system or or enter it directly. - -Selected [cluster contexts](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context) are added as a separate item in the left-side cluster menu to allow you to operate easily on multiple clusters and/or contexts. - -**NOTE**: Any cluster that you added manually will not be merged into your kubeconfig file. - -![Add Cluster](images/add-cluster.png) - -For more information on kubeconfig see [Kubernetes docs](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/). - -To see your currently-enabled config with `kubectl`, enter `kubectl config view --minify --raw` in your terminal. - -When connecting to a cluster, make sure you have a valid and working kubeconfig for the cluster. Following lists known "gotchas" in some authentication types used in kubeconfig with Lens app. - -## Exec auth plugins - -When using [exec auth](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#configuration) plugins make sure the paths that are used to call any binaries are full paths as Lens app might not be able to call binaries with relative paths. Make also sure that you pass all needed information either as arguments or env variables in the config, Lens app might not have all login shell env variables set automatically. diff --git a/docs/clusters/images/add-cluster.png b/docs/clusters/images/add-cluster.png deleted file mode 100644 index fa7b632026..0000000000 Binary files a/docs/clusters/images/add-cluster.png and /dev/null differ diff --git a/docs/clusters/images/cluster-context-menu.png b/docs/clusters/images/cluster-context-menu.png deleted file mode 100644 index d733840df3..0000000000 Binary files a/docs/clusters/images/cluster-context-menu.png and /dev/null differ diff --git a/docs/clusters/images/cluster-settings-features.png b/docs/clusters/images/cluster-settings-features.png deleted file mode 100644 index 3a8066309d..0000000000 Binary files a/docs/clusters/images/cluster-settings-features.png and /dev/null differ diff --git a/docs/clusters/images/cluster-settings-general.png b/docs/clusters/images/cluster-settings-general.png deleted file mode 100644 index d7de0a1a35..0000000000 Binary files a/docs/clusters/images/cluster-settings-general.png and /dev/null differ diff --git a/docs/clusters/images/cluster-settings-removal.png b/docs/clusters/images/cluster-settings-removal.png deleted file mode 100644 index badcbcc6e0..0000000000 Binary files a/docs/clusters/images/cluster-settings-removal.png and /dev/null differ diff --git a/docs/clusters/images/cluster-settings-status.png b/docs/clusters/images/cluster-settings-status.png deleted file mode 100644 index af8e939e35..0000000000 Binary files a/docs/clusters/images/cluster-settings-status.png and /dev/null differ diff --git a/docs/clusters/images/cluster-settings.png b/docs/clusters/images/cluster-settings.png deleted file mode 100644 index 27a4a72ff9..0000000000 Binary files a/docs/clusters/images/cluster-settings.png and /dev/null differ diff --git a/docs/clusters/images/remove-cluster.png b/docs/clusters/images/remove-cluster.png deleted file mode 100644 index bcaa69c44a..0000000000 Binary files a/docs/clusters/images/remove-cluster.png and /dev/null differ diff --git a/docs/clusters/removing-clusters.md b/docs/clusters/removing-clusters.md deleted file mode 100644 index 3ec0d3a1cd..0000000000 --- a/docs/clusters/removing-clusters.md +++ /dev/null @@ -1,12 +0,0 @@ -# Removing Clusters - -Remove Lens clusters using the context menu that appears when you right-click the cluster in the left-side menu that you want to remove. - -To remove a cluster from your cluster list: - -1. Right-click the name of the cluster in the left-side menu that you want to remove. -2. Click **Remove**. - -**NOTE**: This will only remove the cluster from your Lens cluster list. It will not affect your actual Kubernetes cluster or its configuration. - -![Remove Cluster](images/remove-cluster.png) \ No newline at end of file diff --git a/docs/clusters/settings.md b/docs/clusters/settings.md deleted file mode 100644 index 351c0babeb..0000000000 --- a/docs/clusters/settings.md +++ /dev/null @@ -1,75 +0,0 @@ -# Settings - -It is easy to configure Lens Clusters to your liking through its various settings. - -1. Right-click the name of the cluster in the left-side menu that you want to open the settings for. -2. Click **Settings**. - -![Cluster settings](images/cluster-context-menu.png) - -## Status - -Overview of the cluster status - -### Cluster Status - -Cluster status information including the detected distribution, kernel version, API endpoint, and online status - -![Cluster settings status](images/cluster-settings-status.png) - -## General - -General cluster settings - -### Cluster Name - -The cluster name is inheritated by default from the kubeconfig file. Change the cluster name to another value by updating it here. Note that doing so does not update your kubeconfig file. - -### Workspace - -This is the Lens workspace that the cluster is associated with. Change workspaces by selecting a different workspace from the dropdown menu. Create a new workspace by clicking **workspace** in "Define cluster workspace" above the dropdown menu. This option will take you the workspaces editor. Create a new workspace and then navigate back to cluster settings. - -### Cluster Icon - -Lens randomly generates an icon to associate with each newly-created cluster. Use this setting to choose your own icon. - -### HTTP Proxy - -Some users will need to define an HTTP proxy for communicating with the Kubernetes API. Use this setting to do so. - -### Prometheus - -Lens can be configured to query a Prometheus server installed in the cluster. Select a query format by choosing either to auto-detect or from the following configurations: - -* Lens -* Helm Operator -* Prometheus Operator -* Stacklight - -To learn more about custom Prometheus configurations, please refer to this [guide](https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md). - -### Working Directory - -Use this field to set the terminal working directory. The default is `$HOME`. - -![Cluster settings general](images/cluster-settings-general.png) - -## Features - -Additional Lens features that can be installed by the user - -### Metrics - -Enable timeseries data visualization (Prometheus stack) for your cluster. Install this only if you don't have existing Prometheus stack installed. - -### User Mode - -User Mode feature enables non-admin users to see namespaces they have access to. This is achieved by configuring RBAC rules so that every authenticated user is granted to list namespaces. - -![Cluster settings features](images/cluster-settings-features.png) - -## Removal - -Use this setting to remove the current cluster. - -![Cluster settings removal](images/cluster-settings-removal.png) diff --git a/docs/contributing/README.md b/docs/contributing/README.md deleted file mode 100644 index 6cf7053fb8..0000000000 --- a/docs/contributing/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Contributing - -There are multiple ways you can contribute to Lens. Even if you are not a developer, you can still contribute. We are always looking for assistance with creating or updating documentation, testing the application, reporting, and troubleshooting issues. - -Here are some ways you can contribute! - -* [Development](./development.md) โ€“ Help make Lens better. -* [Maintaining the Project](./maintainers.md) โ€“ Become a community maintainer and help us maintain the project. -* [Extension Development](../extensions) โ€“ Add integrations via Lens Extensions. -* [Documentation](./documentation.md) โ€“ Help improve Lens documentation. -* [Promotion](./promotion.md) โ€“ Show your support, be an ambassador to Lens, write blogs, and make videos! - -If you are an influencer, blogger, or journalist, feel free to [spread the word](./promotion.md)! - -## Code of Conduct - -This project adheres to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct. By participating and contributing to Lens, you are expected to uphold this code. Please report unacceptable behaviour to info@k8slens.dev. diff --git a/docs/contributing/development.md b/docs/contributing/development.md deleted file mode 100644 index b92edd319e..0000000000 --- a/docs/contributing/development.md +++ /dev/null @@ -1,40 +0,0 @@ -# Development - -Thank you for taking the time to make a contribution to Lens. The following document is a set of guidelines and instructions for contributing to Lens. - -When contributing to this repository, please consider first discussing the change you wish to make by opening an issue. - -## Recommended Reading: - -- [TypeScript](https://www.typescriptlang.org/docs/home.html) (front-end/back-end) -- [ReactJS](https://reactjs.org/docs/getting-started.html) (front-end, ui) -- [MobX](https://mobx.js.org/) (app-state-management, back-end/front-end) -- [ElectronJS](https://www.electronjs.org/docs) (chrome/node) -- [NodeJS](https://nodejs.org/dist/latest-v12.x/docs/api/) (api docs) - -## Local Development Environment - -> Prerequisites: Nodejs v12, make, yarn - -* `make dev` - builds and starts the app -* `make clean` - cleanup local environment build artifacts - - -## Github Workflow - -We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes are tracked via Pull Requests. -A detailed guide on the recommended workflow can be found below: - -* [Github Workflow](./github_workflow.md) - -## Code Testing - -All submitted PRs go through a set of tests and reviews. You can run most of these tests *before* a PR is submitted. -In fact, we recommend it, because it will save on many possible review iterations and automated tests. -The testing guidelines can be found here: - -* [Contributor's Guide to Testing](./testing.md) - -## License - -By contributing, you agree that your contributions will be licensed as described in [LICENSE](https://github.com/lensapp/lens/blob/master/LICENSE). diff --git a/docs/contributing/documentation.md b/docs/contributing/documentation.md deleted file mode 100644 index 501c57779f..0000000000 --- a/docs/contributing/documentation.md +++ /dev/null @@ -1,33 +0,0 @@ -# Documentation - -We are glad to see you're interested in contributing to the Lens documentation. If this is the first Open Source project you've contributed to, we strongly suggest reading GitHub's excellent guide: [How to Contribute to Open Source](https://opensource.guide/how-to-contribute). - -## Finding Documentation Issues to Work On - -You can find a list of open documentation-related issues [here](https://github.com/lensapp/lens/issues?q=is%3Aopen+is%3Aissue+label%3Aarea%2Fdocumentation). When you find something you would like to work on: - -1. Express your interest to start working on an issue via comments. -2. One of the maintainers will assign the issue for you. -3. You can start working on the issue. When you're done, simply submit a pull request. - -## Requirements for Documentation Pull Requests - -When you create a new pull request, we expect some requirements to be met. - -* Follow this naming convention for Pull Requests: - * When adding new documentation, add `New Documentation:` before the title. E.g. `New Documentation: Getting Started` - * When fixing documentation, add `Fix Documentation:` before the title. E.g. `Fix Documentation: Getting Started` - * When updating documentation, add `Update Documentation:` before the title. E.g. `Update Documentation: Getting Started` -* If your Pull Request closes an issue, you must write `Closes #ISSUE_NUMBER` where the ISSUE_NUMBER is the number in the end of the link url or the relevent issue. This will link your pull request to the issue, and when it is merged, the issue will close. -* For each pull request made, we run tests to check if there are any broken links, the markdown formatting is valid, and the linter is passing. - - -## Testing Documentation Site Locally - -Run a local instance of `mkdocs` in a docker container for developing the Lens Documentation. - -> Prerequisites: docker, yarn - -* `make docs` - local build and serve of mkdocs with auto update enabled - -Go to [localhost:8000](http://127.0.0.1:8000). diff --git a/docs/contributing/github_workflow.md b/docs/contributing/github_workflow.md deleted file mode 100644 index 3509645b47..0000000000 --- a/docs/contributing/github_workflow.md +++ /dev/null @@ -1,148 +0,0 @@ -# Github Workflow - - -- [Fork The Project](#fork-the-project) -- [Adding the Forked Remote](#adding-the-forked-remote) -- [Create & Rebase Your Feature Branch](#create--rebase-your-feature-branch) -- [Commit & Push](#commit--push) -- [Open a Pull Request](#open-a-pull-request) - - [Get a code review](#get-a-code-review) - - [Squash commits](#squash-commits) - - [Push Your Final Changes](#push-your-final-changes) - - -This guide assumes you have already cloned the upstream repo to your system via git clone. - -## Fork The Project - -1. Go to [http://github.com/lensapp/lens](http://github.com/lensapp/lens) -2. On the top, right-hand side, click on "fork" and select your username for the fork destination. - -## Adding the Forked Remote - -``` -export GITHUB_USER={ your github's username } - -cd $WORKDIR/lens -git remote add $GITHUB_USER git@github.com:${GITHUB_USER}/lens.git - -# Prevent push to Upstream -git remote set-url --push origin no_push - -# Set your fork remote as a default push target -git push --set-upstream $GITHUB_USER master -``` - -Your remotes should look something like this: - -``` -โžœ git remote -v -origin https://github.com/lensapp/lens (fetch) -origin no_push (push) -my_fork git@github.com:{ github_username }/lens.git (fetch) -my_fork git@github.com:{ github_username }/lens.git (push) -``` - -## Create & Rebase Your Feature Branch - -Create a feature branch: - -``` -git branch -b my_feature_branch -``` - -Rebase your branch: - -``` -git fetch origin - -git rebase origin/master -Current branch my_feature_branch is up to date. -``` - -Please don't use `git pull` instead of the above `fetch / rebase`. `git pull` does a merge, which leaves merge commits. These make the commit history messy and violate the principle that commits ought to be individually understandable and useful. - -## Commit & Push - -Commit and sign your changes: - -``` -git commit -m "my commit title" --signoff -``` - -You can go back and edit/build/test some more, then `commit --amend` in a few cycles. - -When ready, push your changes to your fork's repository: - -``` -git push --set-upstream my_fork my_feature_branch -``` - -## Open a Pull Request - -See [Github Docs](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork). - -### Get a code review - -Once your pull request has been opened it will be assigned to one or more reviewers, and will go through a series of smoke tests. - -Commit changes made in response to review comments should be added to the same branch on your fork. - -Very small PRs are easy to review. Very large PRs are very difficult to review. - -### Squashing Commits -Commits on your branch should represent meaningful milestones or units of work. -Small commits that contain typo fixes, rebases, review feedbacks, etc should be squashed. - -To do that, it's best to perform an [interactive rebase](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History): - -#### Example -If you PR has 3 commits, count backwards from your last commit using `HEAD~3`: -``` -git rebase -i HEAD~3 -``` -Output would be similar to this: -``` -pick f7f3f6d Changed some code -pick 310154e fixed some typos -pick a5f4a0d made some review changes - -# Rebase 710f0f8..a5f4a0d onto 710f0f8 -# -# Commands: -# p, pick = use commit -# r, reword = use commit, but edit the commit message -# e, edit = use commit, but stop for amending -# s, squash = use commit, but meld into previous commit -# f, fixup = like "squash", but discard this commit's log message -# x, exec = run command (the rest of the line) using shell -# b, break = stop here (continue rebase later with 'git rebase --continue') -# d, drop = remove commit -# l, label