Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Jun 12, 2020
1 parent 955c6ff commit fc197cd
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/co
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatTextareaAutosize } from '@angular/material/input';
import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { BehaviorSubject, combineLatest, Observable, of, Subscription } from 'rxjs';
import { distinctUntilChanged, filter, first, map, pairwise, startWith, switchMap } from 'rxjs/operators';

import { AppState } from '../../../../../store/src/app-state';
import { EntityMonitorFactory } from '../../../../../store/src/monitors/entity-monitor.factory.service';
import { RequestInfoState } from '../../../../../store/src/reducers/api-request-reducer/types';
import { EndpointsService } from '../../../core/endpoints.service';
import { safeUnsubscribe } from '../../../core/utils.service';
Expand Down Expand Up @@ -60,10 +57,8 @@ export class CreateReleaseComponent implements OnInit, OnDestroy {
constructor(
private route: ActivatedRoute,
public endpointsService: EndpointsService,
private store: Store<AppState>,
private httpClient: HttpClient,
private confirmDialog: ConfirmationDialogService,
private emf: EntityMonitorFactory
) {
const chart = this.route.snapshot.params;
this.cancelUrl = `/monocular/charts/${chart.repo}/${chart.chartName}/${chart.version}`;
Expand Down
4 changes: 2 additions & 2 deletions custom-src/frontend/app/custom/helm/helm-entity-catalog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { StratosCatalogEndpointEntity, StratosCatalogEntity } from '../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity'; import { IFavoriteMetadata } from '../../../../store/src/types/user-favorites.types'; import { MonocularChart, HelmVersion } from './store/helm.types'; import { HelmChartActionBuilders, HelmVersionActionBuilders } from './store/helm.action-builders';

/**
* A strongly typed collection of Kube Catalog Entities.
* A strongly typed collection of Helm Catalog Entities.
* This can be used to access functionality exposed by each specific type, such as get, update, delete, etc
*/
export class HelmEntityCatalog {
Expand All @@ -11,7 +11,7 @@ export class HelmEntityCatalog {
}

/**
* A strongly typed collection of Kube Catalog Entities.
* A strongly typed collection of Helm Catalog Entities.
* This can be used to access functionality exposed by each specific type, such as get, update, delete, etc
*/
export const helmEntityCatalog: HelmEntityCatalog = new HelmEntityCatalog();
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

&__content {
& > * {
padding-bottom: 10px;
margin-bottom: 10px;
}
textarea {
max-height: 75px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from '../../../../store/src/entity-catalog/entity-catalog-entity/entity-catalog-entity';
import { IFavoriteMetadata } from '../../../../store/src/types/user-favorites.types';
import {
KubeAppActionBuilders,
KubeDashboardActionBuilders,
KubeDeploymentActionBuilders,
KubeNamespaceActionBuilders,
Expand All @@ -14,7 +13,6 @@ import {
KubeStatefulSetsActionBuilders,
} from './store/action-builders/kube.action-builders';
import {
KubernetesApp,
KubernetesDeployment,
KubernetesNamespace,
KubernetesNode,
Expand All @@ -29,7 +27,6 @@ import {
*/
export class KubeEntityCatalog {
public endpoint: StratosCatalogEndpointEntity;
public app: StratosCatalogEntity<IFavoriteMetadata, KubernetesApp, KubeAppActionBuilders>;
public statefulSet: StratosCatalogEntity<IFavoriteMetadata, KubernetesStatefulSet, KubeStatefulSetsActionBuilders>;
public pod: StratosCatalogEntity<IFavoriteMetadata, KubernetesPod, KubePodActionBuilders>;
public deployment: StratosCatalogEntity<IFavoriteMetadata, KubernetesDeployment, KubeDeploymentActionBuilders>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const kubernetesNamespacesEntityType = 'kubernetesNamespace';
export const kubernetesServicesEntityType = 'kubernetesService';
export const kubernetesStatefulSetsEntityType = 'kubernetesStatefulSet';
export const kubernetesDeploymentsEntityType = 'kubernetesDeployment';
export const kubernetesAppsEntityType = 'kubernetesApp';
export const kubernetesDashboardEntityType = 'kubernetesDashboard';

export const getKubeAppId = (object: KubernetesApp) => object.name;
Expand Down Expand Up @@ -57,12 +56,6 @@ entityCache[kubernetesEntityType] = new KubernetesEntitySchema(
{ idAttribute: getAPIResourceGuid }
);

entityCache[kubernetesAppsEntityType] = new KubernetesEntitySchema(
kubernetesAppsEntityType,
{},
{ idAttribute: getKubeAppId }
);

entityCache[kubernetesStatefulSetsEntityType] = new KubernetesEntitySchema(
kubernetesStatefulSetsEntityType,
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { KubernetesGKEAuthFormComponent } from './auth-forms/kubernetes-gke-auth
import { kubeEntityCatalog } from './kubernetes-entity-catalog';
import {
KUBERNETES_ENDPOINT_TYPE,
kubernetesAppsEntityType,
kubernetesDashboardEntityType,
kubernetesDeploymentsEntityType,
kubernetesEntityFactory,
Expand All @@ -34,8 +33,6 @@ import {
kubernetesStatefulSetsEntityType,
} from './kubernetes-entity-factory';
import {
KubeAppActionBuilders,
kubeAppActionBuilders,
KubeDashboardActionBuilders,
kubeDashboardActionBuilders,
KubeDeploymentActionBuilders,
Expand All @@ -52,7 +49,6 @@ import {
kubeStatefulSetsActionBuilders,
} from './store/action-builders/kube.action-builders';
import {
KubernetesApp,
KubernetesDeployment,
KubernetesNamespace,
KubernetesNode,
Expand Down Expand Up @@ -161,7 +157,6 @@ export function generateKubernetesEntities(): StratosBaseCatalogEntity[] {
};
return [
generateEndpointEntity(endpointDefinition),
generateAppEntity(endpointDefinition),
generateStatefulSetsEntity(endpointDefinition),
generatePodsEntity(endpointDefinition),
generateDeploymentsEntity(endpointDefinition),
Expand All @@ -182,18 +177,6 @@ function generateEndpointEntity(endpointDefinition: StratosEndpointExtensionDefi
return kubeEntityCatalog.endpoint;
}

function generateAppEntity(endpointDefinition: StratosEndpointExtensionDefinition) {
const definition: IStratosEntityDefinition = {
type: kubernetesAppsEntityType,
schema: kubernetesEntityFactory(kubernetesAppsEntityType),
endpoint: endpointDefinition,
};
kubeEntityCatalog.app = new StratosCatalogEntity<IFavoriteMetadata, KubernetesApp, KubeAppActionBuilders>(definition, {
actionBuilders: kubeAppActionBuilders
});
return kubeEntityCatalog.app;
}

function generateStatefulSetsEntity(endpointDefinition: StratosEndpointExtensionDefinition) {
const definition: IStratosEntityDefinition = {
type: kubernetesStatefulSetsEntityType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ import {
KubeHealthCheck,
} from '../kubernetes.actions';

export interface KubeAppActionBuilders extends OrchestratedActionBuilders {

}

export const kubeAppActionBuilders: KubeAppActionBuilders = {
}

export interface KubeStatefulSetsActionBuilders extends OrchestratedActionBuilders {
getMultiple: (
kubeGuid: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { environment } from '../../../environments/environment.prod';
import { environment } from '../../../environments/environment';
import {
BasicKubeAPIResource,
KubernetesDeployment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class KubernetesNamespacesFilterService implements OnDestroy {
public kube: KubernetesNamespacesFilterItem<EndpointModel>;
public namespace: KubernetesNamespacesFilterItem<KubernetesNamespace>;

// private isLoading$: Observable<boolean>;
private subs: Subscription[] = [];

private allNamespaces = this.getNamespacesObservable();
Expand All @@ -50,7 +49,7 @@ export class KubernetesNamespacesFilterService implements OnDestroy {
this.kube = this.createKube();
this.namespace = this.createNamespace();

// Start watching the cf/org/space plus automatically setting values only when we actually have values to auto select
// Start watching the namespace plus automatically setting values only when we actually have values to auto select
this.namespace.list$.pipe(first()).subscribe(() => this.setupAutoSelectors());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {
prefix = messageObj.data;
} else if (messageObj.kind === 'Pods') {
const pods: KubernetesPod[] = messageObj.data || [];
const podsWithInfo: KubernetesPod[] = pods.map(pod => {
const res = KubernetesPodExpandedStatusHelper.updatePodWithExpandedStatus(pod);
res.metadata.kubeId = this.helmReleaseHelper.endpointGuid;
return res;
});
const podsWithInfo: KubernetesPod[] = pods.map(pod => KubernetesPodExpandedStatusHelper.updatePodWithExpandedStatus(pod));
const releasePodsAction = kubeEntityCatalog.pod.actions.getInWorkload(
this.helmReleaseHelper.endpointGuid,
this.helmReleaseHelper.releaseTitle
Expand All @@ -127,7 +123,6 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {
// Store ALL resources for the release
manifest.forEach(resource => {
if (resource.kind === 'Service' && prefix) {
resource.metadata.kubeId = this.helmReleaseHelper.endpointGuid;
svcs.push(resource);
}
});
Expand Down Expand Up @@ -170,7 +165,6 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {

private populateList(action: KubePaginationAction, resources: any) {
const entity = entityCatalog.getEntity(action);
const entityKey = entity.entityKey;
const newResources = {};
resources.forEach(resource => {
const newResource: HelmReleasePod | HelmReleaseService = {
Expand All @@ -179,12 +173,14 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {
...resource
};
newResource.metadata.kubeId = action.kubeGuid;
const entityId = entity.getSchema(action.schemaKey).getId(resource)
// The service entity from manifest is missing this, but apply here to ensure any others are caught
newResource.metadata.namespace = this.helmReleaseHelper.namespace;
const entityId = action.entity[0].getId(resource)
newResources[entityId] = newResource;
});

const releasePods = {
entities: { [entityKey]: newResources },
entities: { [entity.entityKey]: newResources },
result: Object.keys(newResources)
};
const successWrapper = new WrapperRequestActionSuccess(releasePods, action, 'fetch', releasePods.result.length, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ export class HelmReleaseHelperService {

public fetchReleaseResources(): Observable<HelmReleaseResource> {
// Get helm release
return workloadsEntityCatalog.resource.store.getPaginationMonitor(
this.endpointGuid,
null,
{ releaseTitle: this.releaseTitle }
).currentPage$.pipe(
const action = workloadsEntityCatalog.resource.actions.get(this.releaseTitle, this.endpointGuid)
return workloadsEntityCatalog.resource.store.getEntityMonitor(
action.guid
).entity$.pipe(
filter(resources => !!resources)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { WorkloadGraphBuilders, WorkloadReleaseBuilders, WorkloadResourceBuilder
import { HelmRelease, HelmReleaseGraph, HelmReleaseResource } from './workload.types';

/**
* A strongly typed collection of Kube Catalog Entities.
* A strongly typed collection of Workload Catalog Entities.
* This can be used to access functionality exposed by each specific type, such as get, update, delete, etc
*/
export class WorkloadsEntityCatalog {
Expand All @@ -14,7 +14,7 @@ export class WorkloadsEntityCatalog {
}

/**
* A strongly typed collection of Kube Catalog Entities.
* A strongly typed collection of Workload Catalog Entities.
* This can be used to access functionality exposed by each specific type, such as get, update, delete, etc
*/
export const workloadsEntityCatalog: WorkloadsEntityCatalog = new WorkloadsEntityCatalog();
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ <h1>Backup Endpoints</h1>
<button mat-raised-button color="primary" [disabled]="disableSelectNone$ | async"
(click)="service.selectNone()">Select None</button>
</div>
<!-- 77px is the min height given Connection details drop down. In some cases it's missing, those rows would be
shorter without the min height here -->
<app-table [dataSource]="endpointDataSource" [columns]="columns" [minRowHeight]="'77px'"></app-table>
</div>
<ng-template #noEndpoints>
Expand Down

0 comments on commit fc197cd

Please sign in to comment.