Skip to content

Commit 5549294

Browse files
authored
fix: pass agent parameter to container config endpoint (#12)
1 parent b59ba3e commit 5549294

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class OneCLI {
2929
/**
3030
* Fetch the raw container configuration from OneCLI.
3131
*/
32-
getContainerConfig = (): Promise<ContainerConfig> => {
33-
return this.containerClient.getContainerConfig();
32+
getContainerConfig = (agent?: string): Promise<ContainerConfig> => {
33+
return this.containerClient.getContainerConfig(agent);
3434
};
3535

3636
/**

src/container/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export class ContainerClient {
1616
/**
1717
* Fetch the raw container configuration from OneCLI.
1818
*/
19-
getContainerConfig = async (): Promise<ContainerConfig> => {
20-
const url = `${this.baseUrl}/api/container-config`;
19+
getContainerConfig = async (agent?: string): Promise<ContainerConfig> => {
20+
const url = agent
21+
? `${this.baseUrl}/api/container-config?agent=${encodeURIComponent(agent)}`
22+
: `${this.baseUrl}/api/container-config`;
2123

2224
try {
2325
const headers: Record<string, string> = {};
@@ -60,11 +62,12 @@ export class ContainerClient {
6062
args: string[],
6163
options?: ApplyContainerConfigOptions,
6264
): Promise<boolean> => {
63-
const { combineCaBundle = true, addHostMapping = true } = options ?? {};
65+
const { combineCaBundle = true, addHostMapping = true, agent } =
66+
options ?? {};
6467

6568
let config: ContainerConfig;
6669
try {
67-
config = await this.getContainerConfig();
70+
config = await this.getContainerConfig(agent);
6871
} catch {
6972
return false;
7073
}

src/container/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ export interface ApplyContainerConfigOptions {
1818
* @default true
1919
*/
2020
addHostMapping?: boolean;
21+
22+
/**
23+
* Agent identifier to fetch config for. Uses the default agent if omitted.
24+
*/
25+
agent?: string;
2126
}

0 commit comments

Comments
 (0)