Skip to content

Commit 91b5504

Browse files
feat: abstract client URL configuration for CLI
Co-Authored-By: Dan Lynch <[email protected]>
1 parent dd67e08 commit 91b5504

File tree

11 files changed

+24
-11
lines changed

11 files changed

+24
-11
lines changed

packages/cli/src/commands.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const commands = async (argv: Partial<ParsedArgs>, prompter: Inquirerer,
6767
command = answer.command;
6868
}
6969

70-
// Prompt for working directory
70+
// Prompt for working directory and client URL
7171
newArgv = await prompter.prompt(newArgv, [
7272
{
7373
type: 'text',
@@ -76,6 +76,14 @@ export const commands = async (argv: Partial<ParsedArgs>, prompter: Inquirerer,
7676
required: false,
7777
default: process.cwd(),
7878
useDefault: true
79+
},
80+
{
81+
type: 'text',
82+
name: 'clientUrl',
83+
message: 'Kubernetes API URL',
84+
required: false,
85+
default: 'http://127.0.0.1:8001',
86+
useDefault: true
7987
}
8088
]);
8189

packages/cli/src/commands/apply.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default async (
106106
) => {
107107
try {
108108
const client = new KubernetesClient({
109-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
109+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
110110
});
111111

112112
const filePath = argv.f || argv._?.[0] || await promptYamlFilePath(prompter, argv);

packages/cli/src/commands/cluster-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default async (
1010
) => {
1111
try {
1212
const client = new KubernetesClient({
13-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
13+
restEndpoint: _argv.clientUrl || 'http://127.0.0.1:8001'
1414
});
1515

1616
console.log(chalk.blue('Kubernetes cluster info:'));

packages/cli/src/commands/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default async (
4848
) => {
4949
try {
5050
const client = new KubernetesClient({
51-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
51+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
5252
});
5353

5454
const subcommand = argv._?.[0];

packages/cli/src/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export default async (
196196
try {
197197
// Initialize Kubernetes client
198198
const client = new KubernetesClient({
199-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
199+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
200200
});
201201

202202
// Create deployment

packages/cli/src/commands/exec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default async (
141141
) => {
142142
try {
143143
const client = new KubernetesClient({
144-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
144+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
145145
});
146146

147147
const namespace = argv.n || argv.namespace || getCurrentNamespace();

packages/cli/src/commands/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default async (
127127
) => {
128128
try {
129129
const client = new KubernetesClient({
130-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
130+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
131131
});
132132

133133
const namespace = argv.n || argv.namespace || getCurrentNamespace();

packages/cli/src/commands/logs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default async (
9999
) => {
100100
try {
101101
const client = new KubernetesClient({
102-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
102+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
103103
});
104104

105105
const namespace = argv.n || argv.namespace || getCurrentNamespace();

packages/cli/src/commands/port-forward.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default async (
144144
) => {
145145
try {
146146
const client = new KubernetesClient({
147-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
147+
restEndpoint: argv.clientUrl || 'http://127.0.0.1:8001'
148148
});
149149

150150
const namespace = argv.n || argv.namespace || getCurrentNamespace();

packages/cli/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export const options: Partial<CLIOptions> = {
77
minimistOpts: {
88
alias: {
99
v: 'version',
10-
h: 'help'
10+
h: 'help',
11+
c: 'clientUrl'
1112
}
1213
}
1314
};
@@ -19,4 +20,4 @@ app.run().then(()=> {
1920
}).catch(error => {
2021
console.error(error);
2122
process.exit(1);
22-
});
23+
});

0 commit comments

Comments
 (0)