Consistent and more descriptive naming of parameters in index.ts (#1455)

Parameter naming has been made more descriptive and consistent:
- Change `number: number` to `pipelineNumber: number`.
- Rename `pipeline` to `pipelineNumber` when it refered to a pipeline number.
This commit is contained in:
smainz 2023-01-15 16:33:12 +01:00 committed by GitHub
parent 1cd73f0b76
commit b0fd99ec01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,14 +71,14 @@ export default class WoodpeckerClient extends ApiClient {
// Deploy triggers a deployment for an existing pipeline using the // Deploy triggers a deployment for an existing pipeline using the
// specified target environment. // specified target environment.
deployPipeline(owner: string, repo: string, number: number, options: DeploymentOptions): Promise<Pipeline> { deployPipeline(owner: string, repo: string, pipelineNumber: number, options: DeploymentOptions): Promise<Pipeline> {
const vars = { const vars = {
...options.variables, ...options.variables,
event: 'deployment', event: 'deployment',
deploy_to: options.environment, deploy_to: options.environment,
}; };
const query = encodeQueryString(vars); const query = encodeQueryString(vars);
return this._post(`/api/repos/${owner}/${repo}/pipelines/${number}?${query}`) as Promise<Pipeline>; return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}?${query}`) as Promise<Pipeline>;
} }
getPipelineList(owner: string, repo: string, opts?: Record<string, string | number | boolean>): Promise<Pipeline[]> { getPipelineList(owner: string, repo: string, opts?: Record<string, string | number | boolean>): Promise<Pipeline[]> {
@ -86,12 +86,12 @@ export default class WoodpeckerClient extends ApiClient {
return this._get(`/api/repos/${owner}/${repo}/pipelines?${query}`) as Promise<Pipeline[]>; return this._get(`/api/repos/${owner}/${repo}/pipelines?${query}`) as Promise<Pipeline[]>;
} }
getPipeline(owner: string, repo: string, number: number | 'latest'): Promise<Pipeline> { getPipeline(owner: string, repo: string, pipelineNumber: number | 'latest'): Promise<Pipeline> {
return this._get(`/api/repos/${owner}/${repo}/pipelines/${number}`) as Promise<Pipeline>; return this._get(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}`) as Promise<Pipeline>;
} }
getPipelineConfig(owner: string, repo: string, number: number): Promise<PipelineConfig[]> { getPipelineConfig(owner: string, repo: string, pipelineNumber: number): Promise<PipelineConfig[]> {
return this._get(`/api/repos/${owner}/${repo}/pipelines/${number}/config`) as Promise<PipelineConfig[]>; return this._get(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}/config`) as Promise<PipelineConfig[]>;
} }
getPipelineFeed(opts?: Record<string, string | number | boolean>): Promise<PipelineFeed[]> { getPipelineFeed(opts?: Record<string, string | number | boolean>): Promise<PipelineFeed[]> {
@ -99,16 +99,16 @@ export default class WoodpeckerClient extends ApiClient {
return this._get(`/api/user/feed?${query}`) as Promise<PipelineFeed[]>; return this._get(`/api/user/feed?${query}`) as Promise<PipelineFeed[]>;
} }
cancelPipeline(owner: string, repo: string, number: number): Promise<unknown> { cancelPipeline(owner: string, repo: string, pipelineNumber: number): Promise<unknown> {
return this._post(`/api/repos/${owner}/${repo}/pipelines/${number}/cancel`); return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}/cancel`);
} }
approvePipeline(owner: string, repo: string, pipeline: string): Promise<unknown> { approvePipeline(owner: string, repo: string, pipelineNumber: string): Promise<unknown> {
return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipeline}/approve`); return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}/approve`);
} }
declinePipeline(owner: string, repo: string, pipeline: string): Promise<unknown> { declinePipeline(owner: string, repo: string, pipelineNumber: string): Promise<unknown> {
return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipeline}/decline`); return this._post(`/api/repos/${owner}/${repo}/pipelines/${pipelineNumber}/decline`);
} }
restartPipeline( restartPipeline(