Skip to content

Commit

Permalink
Merge pull request #203 from vmware-tanzu/add-kctrl
Browse files Browse the repository at this point in the history
feat: add support for kctrl
  • Loading branch information
jbrunton authored Jul 8, 2022
2 parents f00b575 + a8d1a05 commit 9f2e1ca
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
- run: npm ci
- name: check all apps installed
if: matrix.os != 'windows-latest'
run: npm run verify:installed ytt kbld kapp kwt imgpkg vendir
run: npm run verify:installed ytt kbld kapp kwt imgpkg vendir kctrl
- name: check all apps installed (windows)
if: matrix.os == 'windows-latest'
run: npm run verify:installed ytt kbld kapp imgpkg vendir
run: npm run verify:installed ytt kbld kapp imgpkg vendir kctrl
- name: check apps are usable
run: |
npm run verify:output "ytt -f ./test/e2e/ytt-example" "greeting: Hello, World"
Expand All @@ -51,7 +51,7 @@ jobs:
- name: check specific apps are installs
run: |
npm run verify:installed ytt kbld
npm run verify:not:installed kapp kwt imgpkg vendir
npm run verify:not:installed kapp kwt imgpkg vendir kctrl
test-e2e-exclude-apps:
runs-on: ubuntu-latest
Expand All @@ -64,7 +64,7 @@ jobs:
- run: npm ci
- name: check specific apps are installed
run: |
npm run verify:installed ytt kbld kapp imgpkg
npm run verify:installed ytt kbld kapp imgpkg kctrl
npm run verify:not:installed kwt vendir
test-e2e-specific-version:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
[![Build Status](https://github.com/vmware-tanzu/carvel-setup-action/workflows/build/badge.svg?branch=develop)](https://github.com/vmware-tanzu/carvel-setup-action/actions?query=branch%3Adevelop+workflow%3Abuild)
[![Release Status](https://github.com/vmware-tanzu/carvel-setup-action/workflows/release/badge.svg)](https://github.com/vmware-tanzu/carvel-setup-action/actions?query=workflow%3Arelease)

A [Github Action](https://github.com/features/actions) to install [Carvel apps](https://carvel.dev/) (ytt, kbld, kapp, kwt, imgpkg and vendir).
A [Github Action](https://github.com/features/actions) to install [Carvel apps](https://carvel.dev/) (ytt, kbld, kapp, kwt, imgpkg, vendir and kctrl).

- Slack: [#carvel in Kubernetes slack](https://slack.kubernetes.io)

## Usage

By default, installs latest versions of `ytt`, `kbld`, `kapp`, `kwt`, `imgpkg` and `vendir`:
By default, installs latest versions of `ytt`, `kbld`, `kapp`, `kwt`, `imgpkg`, `vendir` and `kctrl`:

```yaml
steps:
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ inputs:
description: vendir version
required: false
default: latest
kctrl:
description: kctrl version
required: false
default: latest
runs:
using: 'node12'
main: 'dist/index.js'
21 changes: 19 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9219,9 +9219,18 @@ class CarvelReleasesService extends gha_installer_1.GitHubReleasesService {
}
exports.CarvelReleasesService = CarvelReleasesService;
function getRepo(app) {
return { owner: 'vmware-tanzu', repo: `carvel-${app.name}` };
return {
owner: 'vmware-tanzu',
repo: getRepoName(app)
};
}
exports.getRepo = getRepo;
function getRepoName(app) {
if (app.name === 'kctrl') {
return 'carvel-kapp-controller';
}
return `carvel-${app.name}`;
}
function getAssetName(platform, app) {
return `${app.name}-${getAssetSuffix(platform)}`;
}
Expand Down Expand Up @@ -14506,7 +14515,15 @@ exports.restEndpointMethods = restEndpointMethods;

Object.defineProperty(exports, "__esModule", { value: true });
exports.Inputs = exports.carvelApps = void 0;
exports.carvelApps = ['ytt', 'kbld', 'kapp', 'kwt', 'imgpkg', 'vendir'];
exports.carvelApps = [
'ytt',
'kbld',
'kapp',
'kwt',
'imgpkg',
'vendir',
'kctrl'
];
class Inputs {
constructor(core, env) {
this._core = core;
Expand Down
12 changes: 11 additions & 1 deletion src/carvel_releases_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ export class CarvelReleasesService extends GitHubReleasesService {
}

export function getRepo(app: AppInfo): ReposListReleasesParameters {
return {owner: 'vmware-tanzu', repo: `carvel-${app.name}`}
return {
owner: 'vmware-tanzu',
repo: getRepoName(app)
}
}

function getRepoName(app: AppInfo): string {
if (app.name === 'kctrl') {
return 'carvel-kapp-controller'
}
return `carvel-${app.name}`
}

export function getAssetName(platform: string, app: AppInfo): string {
Expand Down
10 changes: 9 additions & 1 deletion src/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {ActionsCore, Environment} from '@jbrunton/gha-installer/lib/interfaces'
import {AppInfo} from '@jbrunton/gha-installer'

export const carvelApps = ['ytt', 'kbld', 'kapp', 'kwt', 'imgpkg', 'vendir']
export const carvelApps = [
'ytt',
'kbld',
'kapp',
'kwt',
'imgpkg',
'vendir',
'kctrl'
]

export class Inputs {
private _apps?: AppInfo[]
Expand Down
36 changes: 36 additions & 0 deletions test/unit/carvel_releases_service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { AppInfo } from "@jbrunton/gha-installer";
import { getAssetName, getRepo } from "../../src/carvel_releases_service";

describe('CarvelReleasesService', () => {
const kbldInfo: AppInfo = {
name: "kbld",
version: "latest"
};

const kctrlInfo: AppInfo = {
name: "kctrl",
version: "latest"
};

describe('getRepo', () => {
it("returns the name of the repo for the app", () => {
expect(getRepo(kbldInfo)).toEqual({
owner: "vmware-tanzu",
repo: "carvel-kbld"
})
// kctrl is a special case
expect(getRepo(kctrlInfo)).toEqual({
owner: "vmware-tanzu",
repo: "carvel-kapp-controller"
})
})
})

describe('getAssetName', () => {
it("returns the asset name for the given platform", () => {
expect(getAssetName("darwin", kbldInfo)).toEqual("kbld-darwin-amd64")
expect(getAssetName("win32", kbldInfo)).toEqual("kbld-windows-amd64.exe")
expect(getAssetName("linux", kbldInfo)).toEqual("kbld-linux-amd64")
})
})
});
12 changes: 8 additions & 4 deletions test/unit/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('Inputs', () => {
{ name: "kapp", "version": "latest" },
{ name: "kwt", "version": "latest" },
{ name: "imgpkg", "version": "latest" },
{ name: "vendir", "version": "latest" }
{ name: "vendir", "version": "latest" },
{ name: "kctrl", "version": "latest" }
])
})

Expand All @@ -39,7 +40,8 @@ describe('Inputs', () => {
{ name: "kbld", "version": "latest" },
{ name: "kapp", "version": "latest" },
{ name: "imgpkg", "version": "latest" },
{ name: "vendir", "version": "latest" }
{ name: "vendir", "version": "latest" },
{ name: "kctrl", "version": "latest" },
])
})

Expand All @@ -54,7 +56,8 @@ describe('Inputs', () => {
{ name: "kapp", "version": "latest" },
{ name: "kwt", "version": "latest" },
{ name: "imgpkg", "version": "latest" },
{ name: "vendir", "version": "latest" }
{ name: "vendir", "version": "latest" },
{ name: "kctrl", "version": "latest" }
])
})

Expand Down Expand Up @@ -89,7 +92,8 @@ describe('Inputs', () => {
{ name: "kbld", "version": "latest" },
{ name: "kapp", "version": "0.34.0" },
{ name: "imgpkg", "version": "latest" },
{ name: "vendir", "version": "latest" }
{ name: "vendir", "version": "latest" },
{ name: "kctrl", "version": "latest" }
])
})

Expand Down

0 comments on commit 9f2e1ca

Please sign in to comment.