Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upsteream-rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Apr 3, 2020
2 parents 83233b8 + 1982cac commit f55cf7c
Show file tree
Hide file tree
Showing 31 changed files with 361 additions and 122 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"karma-spec-reporter": "0.0.32",
"kind-of": "^6.0.3",
"lodash": "^4.17.13",
"mem": "5.1.1",
"mktemp": "^1.0.0",
Expand Down
3 changes: 3 additions & 0 deletions package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Package file notes

- 01 Apr 2020 - Added `kind-of` (^6.0.3) as a dev dependency to address security issue with 6.0.2. Can be removed when referencing package is updated.
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
import { GitSCM } from '../../../core/src/shared/data-services/scm/scm';
import {
EntityRequestActionConfig,
KnownEntityActionBuilder,
OrchestratedActionBuilderConfig,
OrchestratedActionBuilders,
} from '../../../store/src/entity-catalog/action-orchestrator/action-orchestrator';
import { GitSCM } from '../../../core/src/shared/data-services/scm/scm';
import { FetchBranchesForProject, FetchCommits } from '../actions/deploy-applications.actions';
import { FetchGitHubRepoInfo } from '../actions/github.actions';
import {
EnvVarStratosProject,
} from '../features/applications/application/application-tabs-base/tabs/build-tab/application-env-vars.service';

export const gitRepoActionBuilders = {
export interface GitRepoActionBuilders extends OrchestratedActionBuilders {
getRepoInfo: (
projectEnvVars: EnvVarStratosProject
) => FetchGitHubRepoInfo;
}

export const gitRepoActionBuilders: GitRepoActionBuilders = {
getRepoInfo: (
projectEnvVars: EnvVarStratosProject
) => new FetchGitHubRepoInfo(projectEnvVars)
} as OrchestratedActionBuilders;
};

interface GitMeta {
export interface GitMeta {
projectName: string;
scm: GitSCM;
commitId?: string;
commitSha?: string;
}

export interface GitCommitActionBuildersConfig extends OrchestratedActionBuilderConfig {
Expand All @@ -35,7 +41,7 @@ export interface GitCommitActionBuilders extends OrchestratedActionBuilders {

export const gitCommitActionBuilders: GitCommitActionBuildersConfig = {
get: new EntityRequestActionConfig<KnownEntityActionBuilder<GitMeta>>(
(id, endpointGuid, meta) => meta.scm.getCommitApiUrl(meta.projectName, meta.commitId),
(id, endpointGuid, meta) => meta.scm.getCommitApiUrl(meta.projectName, meta.commitSha),
{
externalRequest: true
}
Expand All @@ -56,5 +62,5 @@ export const gitBranchActionBuilders: GitBranchActionBuilders = {
guid: string,
endpointGuid: string,
meta: GitMeta
) => new FetchBranchesForProject(meta.scm, guid)
) => new FetchBranchesForProject(meta.scm, meta.projectName)
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import { Observable, of as observableOf, Subscription } from 'rxjs';
import { distinctUntilChanged, filter, map, take, tap } from 'rxjs/operators';

import { GitCommit, GitRepo } from '../../../../../../../../cloud-foundry/src/store/types/git.types';
import { entityCatalog } from '../../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { EntityService } from '../../../../../../../../store/src/entity-service';
import { EntityServiceFactory } from '../../../../../../../../store/src/entity-service-factory.service';
import {
GithubCommitsListConfigServiceAppTab,
} from '../../../../../../../../core/src/shared/components/list/list-types/github.ghproxy.topmits/github.ghproxy.topmits-list-config-app-tab.service';
import { ListConfig } from '../../../../../../../../core/src/shared/components/list/list.component.types';
import { GitSCMService, GitSCMType } from '../../../../../../../../core/src/shared/data-services/scm/scm.service';
import { CF_ENDPOINT_TYPE } from '../../../../../../cf-types';
import { entityCatalog } from '../../../../../../../../store/src/entity-catalog/entity-catalog.service';
import { EntityService } from '../../../../../../../../store/src/entity-service';
import { EntityServiceFactory } from '../../../../../../../../store/src/entity-service-factory.service';
import { FetchGitHubRepoInfo } from '../../../../../../actions/github.actions';
import { CFAppState } from '../../../../../../cf-app-state';
import { gitBranchesEntityType, gitCommitEntityType, gitRepoEntityType } from '../../../../../../cf-entity-types';
import { CF_ENDPOINT_TYPE } from '../../../../../../cf-types';
import { GitMeta } from '../../../../../../entity-action-builders/git-action-builder';
import { GitBranch } from '../../../../../../store/types/github.types';
import { ApplicationService } from '../../../../application.service';
import { EnvVarStratosProject } from '../build-tab/application-env-vars.service';
Expand Down Expand Up @@ -81,15 +82,15 @@ export class GitSCMTabComponent implements OnInit, OnDestroy {
take(1),
tap((stProject: EnvVarStratosProject) => {
const projectName = stProject.deploySource.project;
const commitId = stProject.deploySource.commit.trim();
const commitSha = stProject.deploySource.commit.trim();

// Fallback to type if scm is not set (legacy support)
const scmType = stProject.deploySource.scm || stProject.deploySource.type;
const scm = this.scmService.getSCM(scmType as GitSCMType);

// Ensure the SCM type is included in the key
const repoEntityID = `${scmType}-${projectName}`;
const commitEntityID = `${repoEntityID}-${commitId}`;
const commitEntityID = `${repoEntityID}-${commitSha}`;

const gitRepoEntity = entityCatalog.getEntity(CF_ENDPOINT_TYPE, gitRepoEntityType);
const getRepoActionBuilder = gitRepoEntity.actionOrchestrator.getActionBuilder('getRepoInfo');
Expand All @@ -99,11 +100,12 @@ export class GitSCMTabComponent implements OnInit, OnDestroy {
getRepoAction
);

const gitMeta: GitMeta = { projectName: stProject.deploySource.project, scm, commitSha };
this.gitCommitEntityService = this.entityServiceFactory.create(
{
endpointType: CF_ENDPOINT_TYPE,
entityType: gitCommitEntityType,
actionMetadata: { projectName: stProject.deploySource.project, scm, commitId },
actionMetadata: gitMeta,
entityGuid: commitEntityID,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,37 @@ export interface FileTransferStatus {
fileName: string;
}

interface DeploySource {
type: string;
}

interface GitSCMSourceInfo extends DeploySource {
project: string;
branch: string;
url: string;
commit: string;
scm: string;
}

// Structure used to provide metadata about the Git Url source
interface GitUrlSourceInfo extends DeploySource {
branch: string;
url: string;
}

// DockerImageSourceInfo - Structure used to provide metadata about the docker source
interface DockerImageSourceInfo extends DeploySource {
applicationName: string;
dockerImage: string;
dockerUsername: string;
}

interface FolderSourceInfo extends DeploySource {
wait: boolean;
files: number;
folders: string[];
}

export class DeployApplicationDeployer {

isRedeploy: string;
Expand Down Expand Up @@ -204,7 +235,7 @@ export class DeployApplicationDeployer {
}

sendGitSCMSourceMetadata = (appSource: DeployApplicationSource) => {
const gitscm = {
const gitscm: GitSCMSourceInfo = {
project: appSource.gitDetails.projectName,
branch: appSource.gitDetails.branch.name,
type: appSource.type.group,
Expand All @@ -222,7 +253,7 @@ export class DeployApplicationDeployer {
}

sendGitUrlSourceMetadata = (appSource: DeployApplicationSource) => {
const gitUrl = {
const gitUrl: GitUrlSourceInfo = {
url: appSource.gitDetails.projectName,
branch: appSource.gitDetails.branch.name,
type: appSource.type.id
Expand All @@ -237,7 +268,7 @@ export class DeployApplicationDeployer {
}

sendDockerImageMetadata = (appSource: DeployApplicationSource) => {
const dockerInfo = {
const dockerInfo: DockerImageSourceInfo = {
applicationName: appSource.dockerDetails.applicationName,
dockerImage: appSource.dockerDetails.dockerImage,
dockerUsername: appSource.dockerDetails.dockerUsername,
Expand Down Expand Up @@ -392,7 +423,7 @@ export class DeployApplicationDeployer {

this.fileTransferStatus$.next(this.fileTransferStatus);

const transferMetadata = {
const transferMetadata: FolderSourceInfo = {
files: metadata.files.length,
folders: metadata.folders,
type: 'filefolder',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
<b *ngIf="canDeployType$ | async"> {{ stepperText }}</b>
<b *ngIf="stepperText$ | async as stepperText">{{ stepperText }}</b>
<form novalidate #sourceSelectionForm="ngForm" class="stepper-form">
<div *ngIf="(canDeployType$ | async) === true">
<div class="deploy-step2-form">
<!-- This can be flipped when we add other deploy types -->
<mat-form-field *ngIf="!selectedSourceType && sourceTypes.length > 1">
<mat-select class="reset-margin" [disabled]="isRedeploy" placeholder="Source Type" name="sourceType"
[(ngModel)]="sourceType" (selectionChange)="setSourceType($event.value)" required>
<mat-option *ngFor="let sourceType of sourceTypes" [value]="sourceType">
{{ sourceType.name }}
</mat-option>
</mat-select>
</mat-form-field>
<p *ngIf="!selectedSourceType && sourceType && sourceType.helpText"> {{sourceType.helpText}} </p>
<div *ngIf="(sourceType$ | async) as sourceType">
<app-deploy-application-fs #fsChooser [hideTitle]='true'
*ngIf="sourceType.id === DEPLOY_TYPES_IDS.FILE || sourceType.id === DEPLOY_TYPES_IDS.FOLDER"
Expand Down Expand Up @@ -62,7 +52,8 @@
</mat-option>
</mat-select>
</mat-form-field>
<div *ngIf="isRedeploy && commitInfo" class="deploy-step2-form__project-info-group">
<div *ngIf="isRedeploy && commitInfo"
class="deploy-step2-form__project-info-group deploy-step2-form__commit">
<div>
<img src="{{commitInfo.author.avatar_url}}">
</div>
Expand Down
Loading

0 comments on commit f55cf7c

Please sign in to comment.