Skip to content

Commit

Permalink
change max parallelism to pull dynamic value from api (#561)
Browse files Browse the repository at this point in the history
* change max parallelism to pull dynamic value from api
  • Loading branch information
sei-aschlackman authored Apr 22, 2024
1 parent 5bf61b5 commit 71f6fee
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
*ngIf="versionResult$ | async as versionResult"
[directory]="directory$ | async"
[terraformVersions]="versionResult"
[maxParallelism]="maxParallelism$ | async"
(updateDirectory)="onUpdateDirectory($event)"
></cas-directory-edit>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class DirectoryEditContainerComponent implements OnInit {

public directory$: Observable<Directory>;
public versionResult$: Observable<TerraformVersionsResult>;
public maxParallelism$: Observable<number>;

constructor(
private directoryService: DirectoryService,
Expand All @@ -39,6 +40,7 @@ export class DirectoryEditContainerComponent implements OnInit {
ngOnInit(): void {
this.directory$ = this.directoryQuery.selectEntity(this.id);
this.versionResult$ = this.terraformService.getTerraformVersions();
this.maxParallelism$ = this.terraformService.getTerraformMaxParallelism();
}

onUpdateDirectory(directory: Partial<Directory>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h2 class="center">Edit Directory</h2>
formControlName="parallelism"
type="number"
matInput
[max]="25"
[max]="maxParallelism"
[min]="1"
autocomplete="off"
/>
Expand All @@ -54,7 +54,7 @@ <h2 class="center">Edit Directory</h2>
<ng-container
*ngIf="parallelism.hasError('min') || parallelism.hasError('max')"
>
Must be between 1 and 25
Must be between 1 and {{ maxParallelism }}
</ng-container>
</mat-error>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { MatCheckboxChange } from '@angular/material/checkbox';
export class DirectoryEditComponent implements OnInit {
@Input() directory: Directory;
@Input() terraformVersions: TerraformVersionsResult;
@Input() maxParallelism: number;

@Output() updateDirectory = new EventEmitter<Partial<Directory>>();

Expand All @@ -46,7 +47,7 @@ export class DirectoryEditComponent implements OnInit {
this.form = this.formBuilder.group({
name: [],
terraformVersion: [],
parallelism: [Validators.min(1), Validators.max(25)],
parallelism: [Validators.min(1), Validators.max(this.maxParallelism)],
azureDestroyFailureThreshold: [Validators.min(1), Validators.max(10)],
azureDestroyFailureThresholdEnabled: [],
});
Expand Down
63 changes: 63 additions & 0 deletions src/app/generated/caster-api/api/terraform.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,69 @@ export class TerraformService {
return httpParams;
}

/**
* Get the maximum allowed parallelism setting value
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTerraformMaxParallelism(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext}): Observable<number>;
public getTerraformMaxParallelism(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext}): Observable<HttpResponse<number>>;
public getTerraformMaxParallelism(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext}): Observable<HttpEvent<number>>;
public getTerraformMaxParallelism(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'text/plain' | 'application/json' | 'text/json', context?: HttpContext}): Observable<any> {

let localVarHeaders = this.defaultHeaders;

let localVarCredential: string | undefined;
// authentication (oauth2) required
localVarCredential = this.configuration.lookupCredential('oauth2');
if (localVarCredential) {
localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential);
}

let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (localVarHttpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'text/plain',
'application/json',
'text/json'
];
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}

let localVarHttpContext: HttpContext | undefined = options && options.context;
if (localVarHttpContext === undefined) {
localVarHttpContext = new HttpContext();
}


let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}

let localVarPath = `/api/terraform/max-parallelism`;
return this.httpClient.request<number>('get', `${this.configuration.basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* List all available Terraform versions.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
*ngIf="versionResult$ | async as versionResult"
[workspace]="workspace$ | async"
[terraformVersions]="versionResult"
[maxParallelism]="maxParallelism$ | async"
(updateWorkspace)="onUpdateWorkspace($event)"
></cas-workspace-edit>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class WorkspaceEditContainerComponent implements OnInit {

public workspace$: Observable<Workspace>;
public versionResult$: Observable<TerraformVersionsResult>;
public maxParallelism$: Observable<number>;

constructor(
private workspaceService: WorkspaceService,
Expand All @@ -39,6 +40,7 @@ export class WorkspaceEditContainerComponent implements OnInit {
ngOnInit(): void {
this.workspace$ = this.workspaceQuery.selectEntity(this.id);
this.versionResult$ = this.terraformService.getTerraformVersions();
this.maxParallelism$ = this.terraformService.getTerraformMaxParallelism();
}

onUpdateWorkspace(workspace: Partial<Workspace>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h2>Edit Workspace</h2>
formControlName="parallelism"
type="number"
matInput
[max]="25"
[max]="maxParallelism"
[min]="1"
autocomplete="off"
/>
Expand All @@ -57,7 +57,7 @@ <h2>Edit Workspace</h2>
<ng-container
*ngIf="parallelism.hasError('min') || parallelism.hasError('max')"
>
Must be between 1 and 25
Must be between 1 and {{ maxParallelism }}
</ng-container>
</mat-error>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ValidatorPatterns } from 'src/app/shared/models/validator-patterns';
export class WorkspaceEditComponent implements OnInit {
@Input() workspace: Workspace;
@Input() terraformVersions: TerraformVersionsResult;
@Input() maxParallelism: number;

@Output() updateWorkspace = new EventEmitter<Partial<Workspace>>();

Expand Down Expand Up @@ -59,7 +60,7 @@ export class WorkspaceEditComponent implements OnInit {
],
],
terraformVersion: [],
parallelism: [Validators.min(1), Validators.max(25)],
parallelism: [Validators.min(1), Validators.max(this.maxParallelism)],
azureDestroyFailureThreshold: [Validators.min(1), Validators.max(10)],
});
}
Expand Down

0 comments on commit 71f6fee

Please sign in to comment.