Skip to content

Commit 9f2e1ca

Browse files
authored
Merge pull request #203 from vmware-tanzu/add-kctrl
feat: add support for kctrl
2 parents f00b575 + a8d1a05 commit 9f2e1ca

File tree

8 files changed

+93
-14
lines changed

8 files changed

+93
-14
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
- run: npm ci
3232
- name: check all apps installed
3333
if: matrix.os != 'windows-latest'
34-
run: npm run verify:installed ytt kbld kapp kwt imgpkg vendir
34+
run: npm run verify:installed ytt kbld kapp kwt imgpkg vendir kctrl
3535
- name: check all apps installed (windows)
3636
if: matrix.os == 'windows-latest'
37-
run: npm run verify:installed ytt kbld kapp imgpkg vendir
37+
run: npm run verify:installed ytt kbld kapp imgpkg vendir kctrl
3838
- name: check apps are usable
3939
run: |
4040
npm run verify:output "ytt -f ./test/e2e/ytt-example" "greeting: Hello, World"
@@ -51,7 +51,7 @@ jobs:
5151
- name: check specific apps are installs
5252
run: |
5353
npm run verify:installed ytt kbld
54-
npm run verify:not:installed kapp kwt imgpkg vendir
54+
npm run verify:not:installed kapp kwt imgpkg vendir kctrl
5555
5656
test-e2e-exclude-apps:
5757
runs-on: ubuntu-latest
@@ -64,7 +64,7 @@ jobs:
6464
- run: npm ci
6565
- name: check specific apps are installed
6666
run: |
67-
npm run verify:installed ytt kbld kapp imgpkg
67+
npm run verify:installed ytt kbld kapp imgpkg kctrl
6868
npm run verify:not:installed kwt vendir
6969
7070
test-e2e-specific-version:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
[![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)
44
[![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)
55

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

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

1010
## Usage
1111

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

1414
```yaml
1515
steps:

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ inputs:
4141
description: vendir version
4242
required: false
4343
default: latest
44+
kctrl:
45+
description: kctrl version
46+
required: false
47+
default: latest
4448
runs:
4549
using: 'node12'
4650
main: 'dist/index.js'

dist/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9219,9 +9219,18 @@ class CarvelReleasesService extends gha_installer_1.GitHubReleasesService {
92199219
}
92209220
exports.CarvelReleasesService = CarvelReleasesService;
92219221
function getRepo(app) {
9222-
return { owner: 'vmware-tanzu', repo: `carvel-${app.name}` };
9222+
return {
9223+
owner: 'vmware-tanzu',
9224+
repo: getRepoName(app)
9225+
};
92239226
}
92249227
exports.getRepo = getRepo;
9228+
function getRepoName(app) {
9229+
if (app.name === 'kctrl') {
9230+
return 'carvel-kapp-controller';
9231+
}
9232+
return `carvel-${app.name}`;
9233+
}
92259234
function getAssetName(platform, app) {
92269235
return `${app.name}-${getAssetSuffix(platform)}`;
92279236
}
@@ -14506,7 +14515,15 @@ exports.restEndpointMethods = restEndpointMethods;
1450614515

1450714516
Object.defineProperty(exports, "__esModule", { value: true });
1450814517
exports.Inputs = exports.carvelApps = void 0;
14509-
exports.carvelApps = ['ytt', 'kbld', 'kapp', 'kwt', 'imgpkg', 'vendir'];
14518+
exports.carvelApps = [
14519+
'ytt',
14520+
'kbld',
14521+
'kapp',
14522+
'kwt',
14523+
'imgpkg',
14524+
'vendir',
14525+
'kctrl'
14526+
];
1451014527
class Inputs {
1451114528
constructor(core, env) {
1451214529
this._core = core;

src/carvel_releases_service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ export class CarvelReleasesService extends GitHubReleasesService {
6767
}
6868

6969
export function getRepo(app: AppInfo): ReposListReleasesParameters {
70-
return {owner: 'vmware-tanzu', repo: `carvel-${app.name}`}
70+
return {
71+
owner: 'vmware-tanzu',
72+
repo: getRepoName(app)
73+
}
74+
}
75+
76+
function getRepoName(app: AppInfo): string {
77+
if (app.name === 'kctrl') {
78+
return 'carvel-kapp-controller'
79+
}
80+
return `carvel-${app.name}`
7181
}
7282

7383
export function getAssetName(platform: string, app: AppInfo): string {

src/inputs.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import {ActionsCore, Environment} from '@jbrunton/gha-installer/lib/interfaces'
22
import {AppInfo} from '@jbrunton/gha-installer'
33

4-
export const carvelApps = ['ytt', 'kbld', 'kapp', 'kwt', 'imgpkg', 'vendir']
4+
export const carvelApps = [
5+
'ytt',
6+
'kbld',
7+
'kapp',
8+
'kwt',
9+
'imgpkg',
10+
'vendir',
11+
'kctrl'
12+
]
513

614
export class Inputs {
715
private _apps?: AppInfo[]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { AppInfo } from "@jbrunton/gha-installer";
2+
import { getAssetName, getRepo } from "../../src/carvel_releases_service";
3+
4+
describe('CarvelReleasesService', () => {
5+
const kbldInfo: AppInfo = {
6+
name: "kbld",
7+
version: "latest"
8+
};
9+
10+
const kctrlInfo: AppInfo = {
11+
name: "kctrl",
12+
version: "latest"
13+
};
14+
15+
describe('getRepo', () => {
16+
it("returns the name of the repo for the app", () => {
17+
expect(getRepo(kbldInfo)).toEqual({
18+
owner: "vmware-tanzu",
19+
repo: "carvel-kbld"
20+
})
21+
// kctrl is a special case
22+
expect(getRepo(kctrlInfo)).toEqual({
23+
owner: "vmware-tanzu",
24+
repo: "carvel-kapp-controller"
25+
})
26+
})
27+
})
28+
29+
describe('getAssetName', () => {
30+
it("returns the asset name for the given platform", () => {
31+
expect(getAssetName("darwin", kbldInfo)).toEqual("kbld-darwin-amd64")
32+
expect(getAssetName("win32", kbldInfo)).toEqual("kbld-windows-amd64.exe")
33+
expect(getAssetName("linux", kbldInfo)).toEqual("kbld-linux-amd64")
34+
})
35+
})
36+
});

test/unit/inputs.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('Inputs', () => {
2525
{ name: "kapp", "version": "latest" },
2626
{ name: "kwt", "version": "latest" },
2727
{ name: "imgpkg", "version": "latest" },
28-
{ name: "vendir", "version": "latest" }
28+
{ name: "vendir", "version": "latest" },
29+
{ name: "kctrl", "version": "latest" }
2930
])
3031
})
3132

@@ -39,7 +40,8 @@ describe('Inputs', () => {
3940
{ name: "kbld", "version": "latest" },
4041
{ name: "kapp", "version": "latest" },
4142
{ name: "imgpkg", "version": "latest" },
42-
{ name: "vendir", "version": "latest" }
43+
{ name: "vendir", "version": "latest" },
44+
{ name: "kctrl", "version": "latest" },
4345
])
4446
})
4547

@@ -54,7 +56,8 @@ describe('Inputs', () => {
5456
{ name: "kapp", "version": "latest" },
5557
{ name: "kwt", "version": "latest" },
5658
{ name: "imgpkg", "version": "latest" },
57-
{ name: "vendir", "version": "latest" }
59+
{ name: "vendir", "version": "latest" },
60+
{ name: "kctrl", "version": "latest" }
5861
])
5962
})
6063

@@ -89,7 +92,8 @@ describe('Inputs', () => {
8992
{ name: "kbld", "version": "latest" },
9093
{ name: "kapp", "version": "0.34.0" },
9194
{ name: "imgpkg", "version": "latest" },
92-
{ name: "vendir", "version": "latest" }
95+
{ name: "vendir", "version": "latest" },
96+
{ name: "kctrl", "version": "latest" }
9397
])
9498
})
9599

0 commit comments

Comments
 (0)