Skip to content

fix: casing of applyToHttpsOptions #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export class KubeConfig implements SecurityAuthentication {
this.makePathsAbsolute(rootDirectory);
}

public async applytoFetchOptions(opts: https.RequestOptions): Promise<RequestInit> {
await this.applytoHTTPSOptions(opts);
public async applyToFetchOptions(opts: https.RequestOptions): Promise<RequestInit> {
await this.applyToHTTPSOptions(opts);
const headers = new Headers();
for (const [key, val] of Object.entries(opts.headers || {})) {
if (Array.isArray(val)) {
Expand All @@ -170,7 +170,7 @@ export class KubeConfig implements SecurityAuthentication {
};
}

public async applytoHTTPSOptions(opts: https.RequestOptions): Promise<void> {
public async applyToHTTPSOptions(opts: https.RequestOptions): Promise<void> {
const user = this.getCurrentUser();

await this.applyOptions(opts);
Expand Down
50 changes: 25 additions & 25 deletions src/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ describe('KubeConfig', () => {
list: ['a', 'b'],
},
};
const requestInit = await kc.applytoFetchOptions(opts);
const requestInit = await kc.applyToFetchOptions(opts);
const expectedCA = Buffer.from('CADATA2', 'utf-8');
const expectedAgent = new https.Agent({
ca: expectedCA,
Expand All @@ -279,7 +279,7 @@ describe('KubeConfig', () => {
kc.loadFromFile(kcFileName);

const opts: https.RequestOptions = {};
kc.applytoHTTPSOptions(opts);
kc.applyToHTTPSOptions(opts);

expect(opts).to.deep.equal({
headers: {},
Expand All @@ -300,7 +300,7 @@ describe('KubeConfig', () => {
};
const rc = new RequestContext(testServerName1, HttpMethod.GET);
await kc.applySecurityAuthentication(rc);
await kc.applytoHTTPSOptions(opts);
await kc.applyToHTTPSOptions(opts);
const expectedCA = Buffer.from('CADATA2', 'utf-8');
const expectedAgent = new https.Agent({
ca: expectedCA,
Expand Down Expand Up @@ -705,7 +705,7 @@ describe('KubeConfig', () => {

config.loadFromClusterAndUser({} as Cluster, { username: user, password: passwd } as User);
const opts = {} as https.RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);

expect(opts.auth).to.equal(`${user}:${passwd}`);
});
Expand All @@ -725,7 +725,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);

/* tslint:disable no-unused-expression*/
expect(opts.auth).to.not.be.undefined;
Expand All @@ -740,7 +740,7 @@ describe('KubeConfig', () => {
config.loadFromClusterAndUser({ skipTLSVerify: false } as Cluster, {} as User);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);

expect(opts.rejectUnauthorized).to.equal(undefined);
});
Expand All @@ -755,7 +755,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand All @@ -778,14 +778,14 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
}
opts.headers = {};
opts.headers.Host = 'foo.com';
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
});

Expand All @@ -805,7 +805,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand All @@ -828,7 +828,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.rejectUnauthorized).to.equal(false);
});

Expand All @@ -850,7 +850,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.rejectUnauthorized).to.equal(undefined);
});

Expand All @@ -869,7 +869,7 @@ describe('KubeConfig', () => {
);
const opts = {} as RequestOptions;

return expect(config.applytoHTTPSOptions(opts)).to.eventually.be.rejectedWith(
return expect(config.applyToHTTPSOptions(opts)).to.eventually.be.rejectedWith(
'Token is expired!',
);
});
Expand All @@ -890,7 +890,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
return expect(config.applytoHTTPSOptions(opts)).to.eventually.be.rejectedWith(
return expect(config.applyToHTTPSOptions(opts)).to.eventually.be.rejectedWith(
/Failed to refresh token/,
);
});
Expand Down Expand Up @@ -919,7 +919,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -950,7 +950,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -980,7 +980,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1009,7 +1009,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1038,7 +1038,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1074,7 +1074,7 @@ describe('KubeConfig', () => {
);
// TODO: inject the exec command here and validate env vars?
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1110,7 +1110,7 @@ describe('KubeConfig', () => {
);
// TODO: inject the exec command here?
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1141,7 +1141,7 @@ describe('KubeConfig', () => {
);
// TODO: inject the exec command here?
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
expect(opts.headers).to.not.be.undefined;
if (opts.headers) {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
Expand Down Expand Up @@ -1173,7 +1173,7 @@ describe('KubeConfig', () => {
);
// TODO: inject the exec command here?
const opts = {} as RequestOptions;
await config.applytoHTTPSOptions(opts);
await config.applyToHTTPSOptions(opts);
const execAuthenticator = (KubeConfig as any).authenticators.find(
(authenticator) => authenticator instanceof ExecAuth,
);
Expand All @@ -1194,7 +1194,7 @@ describe('KubeConfig', () => {
} as User,
);
const opts = {} as RequestOptions;
return expect(config.applytoHTTPSOptions(opts)).to.eventually.be.rejectedWith(
return expect(config.applyToHTTPSOptions(opts)).to.eventually.be.rejectedWith(
'No command was specified for exec authProvider!',
);
});
Expand Down Expand Up @@ -1493,7 +1493,7 @@ describe('KubeConfig', () => {

it('should apply to request', async () => {
const opts = {} as RequestOptions;
await emptyConfig.applytoHTTPSOptions(opts);
await emptyConfig.applyToHTTPSOptions(opts);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Log {
searchParams.set('container', containerName);
AddOptionsToSearchParams(options, searchParams);

const requestInit = await this.config.applytoFetchOptions({});
const requestInit = await this.config.applyToFetchOptions({});

const controller = new AbortControllerCtor();
requestInit.signal = controller.signal;
Expand Down
2 changes: 1 addition & 1 deletion src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Metrics {

const requestURL = cluster.server + path;

const requestInit = await this.config.applytoFetchOptions({});
const requestInit = await this.config.applyToFetchOptions({});
requestInit.method = 'GET';

return fetch(requestURL, requestInit)
Expand Down
2 changes: 1 addition & 1 deletion src/proto-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ProtoClient {
hostname: u.hostname,
protocol: u.protocol,
};
await this.config.applytoHTTPSOptions(options);
await this.config.applyToHTTPSOptions(options);
const req = http.request(options);

const result = await new Promise<any>((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Watch {
}
}

const requestInit = await this.config.applytoFetchOptions({});
const requestInit = await this.config.applyToFetchOptions({});

const controller = new AbortControllerCtor();
requestInit.signal = controller.signal;
Expand Down
2 changes: 1 addition & 1 deletion src/web-socket-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class WebSocketHandler implements WebSocketInterface {

const opts: WebSocket.ClientOptions = {};

await this.config.applytoHTTPSOptions(opts);
await this.config.applyToHTTPSOptions(opts);

return await new Promise<WebSocket>((resolve, reject) => {
const client = this.socketFactory
Expand Down