Skip to content

Commit

Permalink
feat(cmx): add create-cluster license-id input for embedded cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh committed Mar 13, 2024
1 parent 70c01ba commit e6882bd
Show file tree
Hide file tree
Showing 43 changed files with 191 additions and 100 deletions.
14 changes: 11 additions & 3 deletions archive-channel/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30432,7 +30432,7 @@ async function findChannelDetailsInOutput(channels, { slug, name }) {
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
class Cluster {
}
exports.Cluster = Cluster;
Expand All @@ -30447,13 +30447,20 @@ class StatusError extends Error {
}
exports.StatusError = StatusError;
async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
return await createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, "", clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags);
}
exports.createCluster = createCluster;
async function createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, licenseId, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
const http = await vendorPortalApi.client();
const reqBody = {
"name": clusterName,
"kubernetes_distribution": k8sDistribution,
"kubernetes_version": k8sVersion,
"ttl": clusterTTL,
};
if (licenseId) {
reqBody['license_id'] = licenseId;
}
if (diskGib) {
reqBody['disk_gib'] = diskGib;
}
Expand Down Expand Up @@ -30490,7 +30497,7 @@ async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sV
const body = JSON.parse(await res.readBody());
return { name: body.cluster.name, id: body.cluster.id, status: body.cluster.status };
}
exports.createCluster = createCluster;
exports.createClusterWithLicense = createClusterWithLicense;
async function pollForStatus(vendorPortalApi, clusterId, expectedStatus, timeout = 120, sleeptimeMs = 5000) {
// get clusters from the api, look for the status of the id to be ${status}
// if it's not ${status}, sleep for 5 seconds and try again
Expand Down Expand Up @@ -30777,7 +30784,7 @@ exports.getUsedKubernetesDistributions = getUsedKubernetesDistributions;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
var configuration_1 = __nccwpck_require__(4995);
Object.defineProperty(exports, "VendorPortalApi", ({ enumerable: true, get: function () { return configuration_1.VendorPortalApi; } }));
var applications_1 = __nccwpck_require__(3770);
Expand All @@ -30790,6 +30797,7 @@ Object.defineProperty(exports, "archiveChannel", ({ enumerable: true, get: funct
var clusters_1 = __nccwpck_require__(5230);
Object.defineProperty(exports, "ClusterVersion", ({ enumerable: true, get: function () { return clusters_1.ClusterVersion; } }));
Object.defineProperty(exports, "createCluster", ({ enumerable: true, get: function () { return clusters_1.createCluster; } }));
Object.defineProperty(exports, "createClusterWithLicense", ({ enumerable: true, get: function () { return clusters_1.createClusterWithLicense; } }));
Object.defineProperty(exports, "pollForStatus", ({ enumerable: true, get: function () { return clusters_1.pollForStatus; } }));
Object.defineProperty(exports, "getKubeconfig", ({ enumerable: true, get: function () { return clusters_1.getKubeconfig; } }));
Object.defineProperty(exports, "removeCluster", ({ enumerable: true, get: function () { return clusters_1.removeCluster; } }));
Expand Down
2 changes: 1 addition & 1 deletion archive-channel/dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions archive-channel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion archive-channel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@actions/core": "^1.10.0",
"esbuild-jest": "^0.5.0",
"replicated-lib": "^0.0.1-beta.10",
"replicated-lib": "^0.0.1-beta.12",
"ts-node": "^10.9.1"
},
"devDependencies": {
Expand Down
14 changes: 11 additions & 3 deletions archive-customer/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30431,7 +30431,7 @@ async function findChannelDetailsInOutput(channels, { slug, name }) {
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
class Cluster {
}
exports.Cluster = Cluster;
Expand All @@ -30446,13 +30446,20 @@ class StatusError extends Error {
}
exports.StatusError = StatusError;
async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
return await createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, "", clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags);
}
exports.createCluster = createCluster;
async function createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, licenseId, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
const http = await vendorPortalApi.client();
const reqBody = {
"name": clusterName,
"kubernetes_distribution": k8sDistribution,
"kubernetes_version": k8sVersion,
"ttl": clusterTTL,
};
if (licenseId) {
reqBody['license_id'] = licenseId;
}
if (diskGib) {
reqBody['disk_gib'] = diskGib;
}
Expand Down Expand Up @@ -30489,7 +30496,7 @@ async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sV
const body = JSON.parse(await res.readBody());
return { name: body.cluster.name, id: body.cluster.id, status: body.cluster.status };
}
exports.createCluster = createCluster;
exports.createClusterWithLicense = createClusterWithLicense;
async function pollForStatus(vendorPortalApi, clusterId, expectedStatus, timeout = 120, sleeptimeMs = 5000) {
// get clusters from the api, look for the status of the id to be ${status}
// if it's not ${status}, sleep for 5 seconds and try again
Expand Down Expand Up @@ -30776,7 +30783,7 @@ exports.getUsedKubernetesDistributions = getUsedKubernetesDistributions;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
var configuration_1 = __nccwpck_require__(4995);
Object.defineProperty(exports, "VendorPortalApi", ({ enumerable: true, get: function () { return configuration_1.VendorPortalApi; } }));
var applications_1 = __nccwpck_require__(3770);
Expand All @@ -30789,6 +30796,7 @@ Object.defineProperty(exports, "archiveChannel", ({ enumerable: true, get: funct
var clusters_1 = __nccwpck_require__(5230);
Object.defineProperty(exports, "ClusterVersion", ({ enumerable: true, get: function () { return clusters_1.ClusterVersion; } }));
Object.defineProperty(exports, "createCluster", ({ enumerable: true, get: function () { return clusters_1.createCluster; } }));
Object.defineProperty(exports, "createClusterWithLicense", ({ enumerable: true, get: function () { return clusters_1.createClusterWithLicense; } }));
Object.defineProperty(exports, "pollForStatus", ({ enumerable: true, get: function () { return clusters_1.pollForStatus; } }));
Object.defineProperty(exports, "getKubeconfig", ({ enumerable: true, get: function () { return clusters_1.getKubeconfig; } }));
Object.defineProperty(exports, "removeCluster", ({ enumerable: true, get: function () { return clusters_1.removeCluster; } }));
Expand Down
2 changes: 1 addition & 1 deletion archive-customer/dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions archive-customer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion archive-customer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@actions/core": "^1.10.0",
"esbuild-jest": "^0.5.0",
"replicated-lib": "^0.0.1-beta.10",
"replicated-lib": "^0.0.1-beta.12",
"ts-node": "^10.9.1"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions create-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ create_cluster["Create Cluster"]
api_token["api-token"]
kubernetes_distribution["kubernetes-distribution"]
kubernetes_version["kubernetes-version"]
license_id["license-id"]
cluster_name["cluster-name"]
ttl["ttl"]
disk["disk"]
Expand All @@ -26,6 +27,7 @@ cluster_kubeconfig["cluster-kubeconfig"]
api_token ---> create_cluster
kubernetes_distribution ---> create_cluster
kubernetes_version ---> create_cluster
license_id ---> create_cluster
cluster_name ---> create_cluster
ttl ---> create_cluster
disk ---> create_cluster
Expand All @@ -47,6 +49,7 @@ create_cluster ---> cluster_kubeconfig
| api-token | | True | API Token. |
| kubernetes-distribution | | True | Kubernetes distribution of the cluster to provision. |
| kubernetes-version | | False | Kubernetes version to provision (format is distribution dependent). |
| license-id | | False | License ID to use for the installation (required for Embedded Cluster distribution). |
| cluster-name | | True | Name of the cluster to provision |
| ttl | | False | Cluster TTL (duration, max 48h) |
| disk | | False | Disk size in GiB |
Expand Down
3 changes: 3 additions & 0 deletions create-cluster/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
kubernetes-version:
description: 'Kubernetes version to provision (format is distribution dependent).'
required: false
license-id:
description: 'License ID to use for the installation (required for Embedded Cluster distribution).'
required: false
cluster-name:
description: 'Name of the cluster to provision'
required: true
Expand Down
17 changes: 13 additions & 4 deletions create-cluster/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function run() {
const name = core.getInput('cluster-name');
const k8sDistribution = core.getInput('kubernetes-distribution');
const k8sVersion = core.getInput('kubernetes-version');
const licenseId = core.getInput('license-id');
const k8sTTL = core.getInput('ttl');
const diskGib = +(core.getInput('disk'));
const nodeCount = +(core.getInput('nodes'));
Expand All @@ -48,7 +49,7 @@ function run() {
}
const tagsArray = processTags(tags);
const nodeGroupsArray = processNodeGroups(nodeGroups);
let cluster = yield (0, replicated_lib_1.createCluster)(apiClient, name, k8sDistribution, k8sVersion, k8sTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroupsArray, tagsArray);
let cluster = yield (0, replicated_lib_1.createClusterWithLicense)(apiClient, name, k8sDistribution, k8sVersion, licenseId, k8sTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroupsArray, tagsArray);
core.info(`Created cluster ${cluster.id} - waiting for it to be ready...`);
core.setOutput('cluster-id', cluster.id);
cluster = yield (0, replicated_lib_1.pollForStatus)(apiClient, cluster.id, 'running', timeoutMinutes * 60);
Expand Down Expand Up @@ -30516,7 +30517,7 @@ async function findChannelDetailsInOutput(channels, { slug, name }) {
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.StatusError = exports.ClusterVersion = exports.Cluster = void 0;
class Cluster {
}
exports.Cluster = Cluster;
Expand All @@ -30531,13 +30532,20 @@ class StatusError extends Error {
}
exports.StatusError = StatusError;
async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
return await createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, "", clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags);
}
exports.createCluster = createCluster;
async function createClusterWithLicense(vendorPortalApi, clusterName, k8sDistribution, k8sVersion, licenseId, clusterTTL, diskGib, nodeCount, minNodeCount, maxNodeCount, instanceType, nodeGroups, tags) {
const http = await vendorPortalApi.client();
const reqBody = {
"name": clusterName,
"kubernetes_distribution": k8sDistribution,
"kubernetes_version": k8sVersion,
"ttl": clusterTTL,
};
if (licenseId) {
reqBody['license_id'] = licenseId;
}
if (diskGib) {
reqBody['disk_gib'] = diskGib;
}
Expand Down Expand Up @@ -30574,7 +30582,7 @@ async function createCluster(vendorPortalApi, clusterName, k8sDistribution, k8sV
const body = JSON.parse(await res.readBody());
return { name: body.cluster.name, id: body.cluster.id, status: body.cluster.status };
}
exports.createCluster = createCluster;
exports.createClusterWithLicense = createClusterWithLicense;
async function pollForStatus(vendorPortalApi, clusterId, expectedStatus, timeout = 120, sleeptimeMs = 5000) {
// get clusters from the api, look for the status of the id to be ${status}
// if it's not ${status}, sleep for 5 seconds and try again
Expand Down Expand Up @@ -30861,7 +30869,7 @@ exports.getUsedKubernetesDistributions = getUsedKubernetesDistributions;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
exports.reportCompatibilityResult = exports.promoteRelease = exports.createReleaseFromChart = exports.createRelease = exports.getUsedKubernetesDistributions = exports.createCustomer = exports.archiveCustomer = exports.KubernetesDistribution = exports.getClusterVersions = exports.upgradeCluster = exports.removeCluster = exports.getKubeconfig = exports.pollForStatus = exports.createClusterWithLicense = exports.createCluster = exports.ClusterVersion = exports.archiveChannel = exports.getChannelDetails = exports.createChannel = exports.Channel = exports.getApplicationDetails = exports.VendorPortalApi = void 0;
var configuration_1 = __nccwpck_require__(4995);
Object.defineProperty(exports, "VendorPortalApi", ({ enumerable: true, get: function () { return configuration_1.VendorPortalApi; } }));
var applications_1 = __nccwpck_require__(3770);
Expand All @@ -30874,6 +30882,7 @@ Object.defineProperty(exports, "archiveChannel", ({ enumerable: true, get: funct
var clusters_1 = __nccwpck_require__(5230);
Object.defineProperty(exports, "ClusterVersion", ({ enumerable: true, get: function () { return clusters_1.ClusterVersion; } }));
Object.defineProperty(exports, "createCluster", ({ enumerable: true, get: function () { return clusters_1.createCluster; } }));
Object.defineProperty(exports, "createClusterWithLicense", ({ enumerable: true, get: function () { return clusters_1.createClusterWithLicense; } }));
Object.defineProperty(exports, "pollForStatus", ({ enumerable: true, get: function () { return clusters_1.pollForStatus; } }));
Object.defineProperty(exports, "getKubeconfig", ({ enumerable: true, get: function () { return clusters_1.getKubeconfig; } }));
Object.defineProperty(exports, "removeCluster", ({ enumerable: true, get: function () { return clusters_1.removeCluster; } }));
Expand Down
2 changes: 1 addition & 1 deletion create-cluster/dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit e6882bd

Please sign in to comment.