Skip to content

Commit

Permalink
Merge pull request #85 from datawire/rlane/fix-get-provider
Browse files Browse the repository at this point in the history
Cluster clients are created as needed
  • Loading branch information
rick-a-lane-ii authored Mar 11, 2024
2 parents 0dde4c3 + 4e734f6 commit 0905a32
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
35 changes: 20 additions & 15 deletions .github/actions/provision-cluster/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
'use strict';
"use strict";

const gke = require('./gke.js')
const kubeception = require('./kubeception.js')
const gke = require("./gke.js");
const kubeception = require("./kubeception.js");

const CLUSTER_NAME = 'CLUSTER_NAME'
const clusterZone = 'us-central1-b'
const CLUSTER_NAME = "CLUSTER_NAME";
const clusterZone = "us-central1-b";

const distributions = {
"gke": new gke.Client(clusterZone),
"kubeception": new kubeception.Client(kubeception.getHttpClient())
}
const DistributionType = {
GKE: "gke",
KUBECEPTION: "kubeception",
};

function getProvider(distribution) {
let result = distributions[distribution.toLowerCase()]
if (typeof result === typeof undefined) {
throw new Error(`unknown distribution: ${distribution}`)
const lowerCaseDistribution = distribution.toLowerCase();

switch (lowerCaseDistribution) {
case DistributionType.GKE:
return new gke.Client(clusterZone);
case DistributionType.KUBECEPTION:
return new kubeception.Client(kubeception.getHttpClient());
default:
throw new Error(`unknown distribution: ${distribution}`);
}
return result
}

module.exports = {
getProvider,
CLUSTER_NAME
}
CLUSTER_NAME,
};
7 changes: 5 additions & 2 deletions .github/workflows/matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
cluster_telepresence_version: ["none"]

runs-on: ${{ matrix.client_os }}-${{ matrix.client_arch }}
env:
KUBECEPTION_TOKEN: ${{ secrets.KUBECEPTION_TOKEN }}
GKE_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
steps:
- uses: actions/checkout@v4
- name: Kubectl tool installer
Expand All @@ -54,8 +57,8 @@ jobs:
distribution: ${{ matrix.clusters.distribution }}
version: ${{ matrix.clusters.version }}
kubeconfig: kubeconfig.yaml
kubeceptionToken: ${{ secrets.KUBECEPTION_TOKEN }}
gkeCredentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
kubeceptionToken: ${{ matrix.clusters.distribution == 'Kubeception' && env.KUBECEPTION_TOKEN }}
gkeCredentials: ${{ matrix.clusters.distribution == 'GKE' && env.GKE_CREDENTIALS }}
gkeConfig: ${{ matrix.clusters.config }}

- run: |
Expand Down

0 comments on commit 0905a32

Please sign in to comment.