Skip to content

Commit 8dacdc7

Browse files
feat: abstract client URL configuration for CLI
Co-Authored-By: Dan Lynch <[email protected]>
1 parent 1512ccb commit 8dacdc7

File tree

14 files changed

+32
-13
lines changed

14 files changed

+32
-13
lines changed

packages/cli/src/commands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ParsedArgs } from 'minimist';
33

44
import { readAndParsePackageJson } from './package';
55
import { extractFirst, usageText } from './utils';
6+
import { getClientUrl } from './config';
67

78
// Commands
89
import deploy from './commands/deploy';
@@ -87,7 +88,10 @@ export const commands = async (argv: Partial<ParsedArgs>, prompter: Inquirerer,
8788
process.exit(1);
8889
}
8990

90-
await commandFn(newArgv, prompter, options);
91+
const clientUrl = getClientUrl(newArgv);
92+
const extendedOptions = { ...options, clientUrl };
93+
94+
await commandFn(newArgv, prompter, extendedOptions);
9195
prompter.close();
9296

9397
return argv;

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: (_options as any).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: (_options as any).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
@@ -46,7 +46,7 @@ export default async (
4646
) => {
4747
try {
4848
const client = new KubernetesClient({
49-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
49+
restEndpoint: (_options as any).clientUrl || 'http://127.0.0.1:8001'
5050
});
5151

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

packages/cli/src/commands/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export default async (
206206
) => {
207207
try {
208208
const client = new KubernetesClient({
209-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
209+
restEndpoint: (_options as any).clientUrl || 'http://127.0.0.1:8001'
210210
});
211211

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

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: (_options as any).clientUrl || 'http://127.0.0.1:8001'
200200
});
201201

202202
// Create deployment

packages/cli/src/commands/describe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default async (
202202
) => {
203203
try {
204204
const client = new KubernetesClient({
205-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
205+
restEndpoint: (_options as any).clientUrl || 'http://127.0.0.1:8001'
206206
});
207207

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

packages/cli/src/commands/exec.ts

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

144144
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: (_options as any).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
@@ -96,7 +96,7 @@ export default async (
9696
) => {
9797
try {
9898
const client = new KubernetesClient({
99-
restEndpoint: 'http://localhost:8001' // Default kube-proxy endpoint
99+
restEndpoint: (_options as any).clientUrl || 'http://127.0.0.1:8001'
100100
});
101101

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

0 commit comments

Comments
 (0)