Skip to content

Commit 7091554

Browse files
committed
add null check
1 parent d98897c commit 7091554

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

src/lib/clusters/clusters.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ export function registerClusters(program: Command) {
2828
users
2929
.command("add")
3030
.description("Add a user to a cluster")
31-
.requiredOption("--cluster <cluster_id>", "ID of the cluster")
31+
.requiredOption("--cluster <cluster>", "name of the cluster")
3232
.requiredOption("--user <username>", "Username to add")
3333
.option("--json", "Output in JSON format")
3434
.action(async (options) => {
3535
await addClusterUserAction({
36-
clusterId: options.cluster,
36+
clusterName: options.cluster,
3737
username: options.user,
3838
});
3939
});
@@ -82,28 +82,22 @@ async function listClustersAction({ returnJson }: { returnJson?: boolean }) {
8282
}
8383

8484
async function addClusterUserAction({
85-
clusterId,
85+
clusterName,
8686
username,
8787
}: {
88-
clusterId: string;
88+
clusterName: string;
8989
username: string;
9090
}) {
9191
const api = await apiClient();
92-
93-
if (!clusterId.startsWith("clus_")) {
94-
return logAndQuit(
95-
`Invalid cluster ID ${clusterId}, it should start with 'clus_'`,
96-
);
97-
}
98-
9992
const { publicKey } = await getKeys();
10093

10194
const { data, error, response } = await api.POST("/v0/credentials", {
10295
body: {
96+
username,
97+
label: "foo",
98+
cluster: clusterName,
10399
object: "k8s_credential",
104100
pubkey: publicKey,
105-
username,
106-
cluster_id: clusterId,
107101
}
108102
});
109103

src/schema.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,6 @@ export interface operations {
17401740
cluster: {
17411741
/** @constant */
17421742
object: "kubernetes_cluster";
1743-
id: string;
17441743
kubernetes_api_url?: string;
17451744
name: string;
17461745
kubernetes_namespace: string;
@@ -1768,7 +1767,6 @@ export interface operations {
17681767
cluster: {
17691768
/** @constant */
17701769
object: "kubernetes_cluster";
1771-
id: string;
17721770
kubernetes_api_url?: string;
17731771
name: string;
17741772
kubernetes_namespace: string;
@@ -1796,7 +1794,6 @@ export interface operations {
17961794
cluster: {
17971795
/** @constant */
17981796
object: "kubernetes_cluster";
1799-
id: string;
18001797
kubernetes_api_url?: string;
18011798
name: string;
18021799
kubernetes_namespace: string;
@@ -1893,7 +1890,7 @@ export interface operations {
18931890
} | {
18941891
username: string;
18951892
label?: string;
1896-
cluster_id: string;
1893+
cluster: string;
18971894
/** @constant */
18981895
object: "k8s_credential";
18991896
pubkey: string;
@@ -1906,7 +1903,7 @@ export interface operations {
19061903
} | {
19071904
username: string;
19081905
label?: string;
1909-
cluster_id: string;
1906+
cluster: string;
19101907
/** @constant */
19111908
object: "k8s_credential";
19121909
pubkey: string;
@@ -1919,7 +1916,7 @@ export interface operations {
19191916
} | {
19201917
username: string;
19211918
label?: string;
1922-
cluster_id: string;
1919+
cluster: string;
19231920
/** @constant */
19241921
object: "k8s_credential";
19251922
pubkey: string;
@@ -1948,7 +1945,6 @@ export interface operations {
19481945
cluster: {
19491946
/** @constant */
19501947
object: "kubernetes_cluster";
1951-
id: string;
19521948
kubernetes_api_url?: string;
19531949
name: string;
19541950
kubernetes_namespace: string;
@@ -1971,7 +1967,6 @@ export interface operations {
19711967
cluster: {
19721968
/** @constant */
19731969
object: "kubernetes_cluster";
1974-
id: string;
19751970
kubernetes_api_url?: string;
19761971
name: string;
19771972
kubernetes_namespace: string;
@@ -1994,7 +1989,6 @@ export interface operations {
19941989
cluster: {
19951990
/** @constant */
19961991
object: "kubernetes_cluster";
1997-
id: string;
19981992
kubernetes_api_url?: string;
19991993
name: string;
20001994
kubernetes_namespace: string;
@@ -2104,7 +2098,6 @@ export interface operations {
21042098
data: {
21052099
/** @constant */
21062100
object: "kubernetes_cluster";
2107-
id: string;
21082101
kubernetes_api_url?: string;
21092102
name: string;
21102103
kubernetes_namespace: string;
@@ -2118,7 +2111,6 @@ export interface operations {
21182111
data: {
21192112
/** @constant */
21202113
object: "kubernetes_cluster";
2121-
id: string;
21222114
kubernetes_api_url?: string;
21232115
name: string;
21242116
kubernetes_namespace: string;
@@ -2132,7 +2124,6 @@ export interface operations {
21322124
data: {
21332125
/** @constant */
21342126
object: "kubernetes_cluster";
2135-
id: string;
21362127
kubernetes_api_url?: string;
21372128
name: string;
21382129
kubernetes_namespace: string;

0 commit comments

Comments
 (0)