Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(platform): Added platform functionality #89

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ globals:
SharedArrayBuffer: readonly

ignorePatterns:
- '!.*'
- '**/node_modules/.*'
- '**/dist/.*'
- '**/coverage/.*'
- '*.json'
- "!.*"
- "**/node_modules/.*"
- "**/dist/.*"
- "**/coverage/.*"
- "*.json"

parser: '@typescript-eslint/parser'
parser: "@typescript-eslint/parser"

parserOptions:
ecmaVersion: 2023
sourceType: module
project:
- './.github/linters/tsconfig.json'
- './tsconfig.json'
- "./.github/linters/tsconfig.json"
- "./tsconfig.json"

plugins:
- jest
- '@typescript-eslint'
- "@typescript-eslint"

extends:
- eslint:recommended
Expand All @@ -36,48 +36,48 @@ extends:

rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/explicit-member-accessibility':
['error', { 'accessibility': 'no-public' }],
'@typescript-eslint/explicit-function-return-type':
['error', { 'allowExpressions': true }],
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
"camelcase": "off",
"eslint-comments/no-use": "off",
"eslint-comments/no-unused-disable": "off",
"i18n-text/no-en": "off",
"import/no-namespace": "off",
"no-console": "off",
"no-unused-vars": "off",
"prettier/prettier": "error",
"semi": "off",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-member-accessibility":
["error", { "accessibility": "no-public" }],
"@typescript-eslint/explicit-function-return-type":
["error", { "allowExpressions": true }],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
}
12 changes: 10 additions & 2 deletions .github/linters/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
{

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

File ignored by default.
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
"include": [
"../../__tests__/**/*",
"../../src/**/*"
],
"exclude": [
"../../dist",
"../../node_modules",
"../../coverage",
"*.json"
]
}
6 changes: 3 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on:
branches:
- main
paths-ignore:
- '**.md'
- "**.md"
pull_request:
paths-ignore:
- '**.md'
- "**.md"
workflow_dispatch:

jobs:
Expand All @@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches:
- main
- 'releases/*'
- "releases/*"

jobs:
test-typescript:
Expand All @@ -19,7 +19,7 @@ jobs:

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
Expand Down Expand Up @@ -81,4 +81,4 @@ jobs:

- name: Print Help
id: print-help
run: vcluster --help
run: vcluster --help
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
branches:
- main
schedule:
- cron: '31 7 * * 3'
- cron: "31 7 * * 3"

jobs:
analyze:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
Expand All @@ -42,3 +42,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_JSCPD: false
VALIDATE_NATURAL_LANGUAGE: false
1 change: 1 addition & 0 deletions .textlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
[![GitHub Super-Linter](https://github.com/actions/typescript-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)
![CI](https://github.com/actions/typescript-action/actions/workflows/ci.yml/badge.svg)

This is a GitHub Action to install the vcluster CLI. Windows, Mac, and Linux runners are supported.

This is a GitHub Action to install the vcluster CLI. Windows, Mac, and Linux
runners are supported.

## Usage

This action will install the vCluster CLI for use in job steps. The default behavior installs the latest release from [vCluster Releases](https://github.com/loft-sh/vcluster/releases). Subsequent steps may run any `vcluster` CLI command.
This action will install the vCluster CLI for use in job steps. The default
behavior installs the latest release from
[vCluster Releases](https://github.com/loft-sh/vcluster/releases). Subsequent
steps may run any `vcluster` CLI command.

To avoid leaking your Loft access key onto GitHub runners, this action will remove the `~/.vcluster` directory at the end of the job.
To avoid leaking your Loft access key onto GitHub runners, this action will
remove the `~/.vcluster` directory at the end of the job.

### Example: Use a specific vCluster version

```yaml
name: loft version
on:
Expand All @@ -34,9 +39,12 @@ jobs:

## Install `kubectl`

Options are provided to install `kubectl`. Many GitHub runners now come with `kubectl` pre-installed, however this allows for controlling the version of `kubectl` if desired.
Options are provided to install `kubectl`. Many GitHub runners now come with
`kubectl` pre-installed, however this allows for controlling the version of
`kubectl` if desired.

### Example: Install the latest vCluster CLI, and install a specific kubectl version

```yaml
name: vcluster version
on:
Expand Down Expand Up @@ -64,8 +72,16 @@ jobs:

The following inputs can be used as `step.with` keys.

| Name | Type | Description |
|-----------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------|
| `version` | String | The version of vcluster CLI to install. See [Loft Releases](https://github.com/loft-sh/vcluster/releases) for available versions. Defaults to latest. |
| `kubectl-install` | Boolean | Install kubectl if not already installed. Defaults to true. |
| `kubectl-version` | String | The version of the kubectl to install. Defaults to latest stable version. |
<!-- markdownlint-disable MD013 -->

| Name | Type | Description |
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `version` | String | The version of vcluster CLI to install. See [Loft Releases](https://github.com/loft-sh/vcluster/releases) for available versions. Defaults to latest. |
| `kubectl-install` | Boolean | Install kubectl if not already installed. Defaults to true. |
| `url` | String | The URL used to access your Loft instance. |
| `access-key` | String | A Loft access key used for logging in through the CLI. See [Access Keys](https://loft.sh/docs/auth/access-keys) for help generating a Loft access key. |
| `insecure` | Boolean | Allow login into an insecure loft instance |
| `docker-login` | Boolean | If true, will log into the docker image registries the user has image pull secrets for (default true) |
| `kubectl-version` | String | The version of the kubectl to install. Defaults to latest stable version. |

<!-- markdownlint-enable MD013 -->
17 changes: 17 additions & 0 deletions __tests__/login.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, test } from '@jest/globals'

import { loginToPlatform } from '../src/login'

describe('loginToPlatform(url: string, accessKey: string)', () => {
test('with empty url', async () => {
await expect(loginToPlatform('', 'foo', false, false)).rejects.toThrow(
'No vCluster Platform url provided'
)
})

test('with empty accessKey', async () => {
await expect(
loginToPlatform('https://prod.loft.rocks', '', false, false)
).rejects.toThrow('No vCluster Platform access key provided')
})
})
34 changes: 25 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
name: vCluster CLI Install
author: loft.sh
description: Installs the vcluster CLI
description: Installs the vCluster CLI
inputs:
version:
description: 'The version of vcluster to install'
description: "The version of vCluster to install"
required: false
default: 'latest'
default: "latest"
url:
description: "The vCluster Platform URL"
required: false
default: ""
access-key:
description: "The vCluster Platform Access Key"
required: false
default: ""
insecure:
description: "Allow login into an insecure vCluster Platform instance (default false)"
required: false
default: "false"
docker-login:
description: "If true, will log into the docker image registries the user has image pull secrets for (default true)"
required: false
default: "true"
kubectl-install:
description: 'Install kubectl if not already installed'
description: "Install kubectl if not already installed"
required: false
default: 'true'
default: "true"
kubectl-version:
description: 'The version of the kubectl to install'
description: "The version of the kubectl to install"
required: false
default: 'latest'
default: "latest"
runs:
using: node20
main: 'dist/main/index.js'
post: 'dist/cleanup/index.js'
main: "dist/main/index.js"
post: "dist/cleanup/index.js"
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading