当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.PipelineConfigValidator类代码示例

本文整理汇总了TypeScript中@spinnaker/core.PipelineConfigValidator的典型用法代码示例。如果您正苦于以下问题:TypeScript PipelineConfigValidator类的具体用法?TypeScript PipelineConfigValidator怎么用?TypeScript PipelineConfigValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PipelineConfigValidator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: if

          toTest.clusters.forEach((cluster: any) => {
            const clusterName: string = NameUtils.getClusterName(
              cluster.application,
              cluster.stack,
              cluster.freeFormDetails,
            );
            if (clusterName === stage.cluster && cluster.account === stage.credentials && cluster.region === region) {
              regionFound = true;
            }
          });
        } else if (
          toTest.type === 'cloneServerGroup' &&
          NameUtils.getClusterName(toTest.application, toTest.stack, toTest.freeFormDetails) === stage.cluster &&
          toTest.region === region
        ) {
          regionFound = true;
        }
      });
      if (!regionFound) {
        allRegionsFound = false;
      }
    });
    if (!allRegionsFound) {
      return validator.message;
    }
    return null;
  }
}

PipelineConfigValidator.registerValidator('cfTargetImpedance', new CfTargetImpedanceValidator());
开发者ID:emjburns,项目名称:deck,代码行数:30,代码来源:cfTargetImpedance.validator.ts

示例2: validate

};

const sourceStruct = (manifest: ICloudFoundryServiceManifestSource) => {
  return manifest.direct ? 'direct' : 'artifact';
};

PipelineConfigValidator.registerValidator(
  'requiredDeployServiceField',
  new class implements IStageOrTriggerValidator {
    public validate(
      _pipeline: IPipeline,
      stage: IStage | ITrigger,
      validationConfig: IServiceFieldValidatorConfig,
    ): string {
      const serviceInput: ICloudFoundryServiceManifestSource = get(stage, 'manifest');
      if (sourceType(serviceInput, get(stage, 'userProvided')) !== validationConfig.manifestSource) {
        return null;
      }
      const manifestSource: any = get(serviceInput, sourceStruct(serviceInput));
      const content: any = get(manifestSource, validationConfig.fieldName);
      const fieldLabel = validationConfig.fieldLabel || upperFirst(validationConfig.fieldName);
      return content ? null : `<strong>${fieldLabel}</strong> is a required field for the Deploy Service stage.`;
    }
  }(),
);

PipelineConfigValidator.registerValidator(
  'validDeployServiceParameterJson',
  new class implements IStageOrTriggerValidator {
    private validationMessage(validationConfig: IServiceFieldValidatorConfig): string {
      return (
开发者ID:emjburns,项目名称:deck,代码行数:31,代码来源:cloudfoundryDeployServiceStage.module.ts

示例3: validate

};

const sourceStruct = (manifest: ICloudFoundryServiceManifestSource) => {
  return manifest && manifest.direct ? 'direct' : 'artifact';
};

PipelineConfigValidator.registerValidator(
  'requiredDeployServiceField',
  new class implements IStageOrTriggerValidator {
    public validate(
      _pipeline: IPipeline,
      stage: IStage | ITrigger,
      validationConfig: IServiceFieldValidatorConfig,
    ): string {
      const serviceInput: ICloudFoundryServiceManifestSource = get(stage, 'manifest');
      if (sourceType(serviceInput, get(stage, 'userProvided')) !== validationConfig.manifestSource) {
        return null;
      }
      const manifestSource: any = get(serviceInput, sourceStruct(serviceInput));
      const content: any = get(manifestSource, validationConfig.fieldName);
      const fieldLabel = validationConfig.fieldLabel || upperFirst(validationConfig.fieldName);
      return content ? null : `<strong>${fieldLabel}</strong> is a required field for the Deploy Service stage.`;
    }
  }(),
);

PipelineConfigValidator.registerValidator(
  'validDeployServiceParameterJsonOrYaml',
  new class implements IStageOrTriggerValidator {
    private isJson(value: string): boolean {
      try {
开发者ID:spinnaker,项目名称:deck,代码行数:31,代码来源:cloudfoundryDeployServiceStage.module.ts

示例4: if

    if (hasMin) {
      if (hasMax) {
        message = `<strong>${fieldLabel}</strong> should be from ${min} to ${max} in ${pipeline.name}.`;
      } else {
        message = `<strong>${fieldLabel}</strong> should be at least ${min} in ${pipeline.name}.`;
      }
    } else if (hasMax) {
      message = `<strong>${fieldLabel}</strong> should be no more than ${max} in ${pipeline.name}.`;
    }
    return validationConfig.message || message;
  }

  protected printableFieldLabel(config: IInstanceFieldSizeValidationConfig): string {
    const fieldLabel: string = config.fieldLabel || config.fieldName;
    return upperFirst(fieldLabel);
  }

  protected fieldIsValid(stage: IStage | ITrigger, config: IInstanceFieldSizeValidationConfig): boolean {
    const fieldExists = has(stage, config.fieldName);
    const field: any = get(stage, config.fieldName);
    const hasMax: boolean = has(config, 'max');
    const hasMin: boolean = has(config, 'min');
    const max: number = get(config, 'max');
    const min: number = get(config, 'min');

    return fieldExists && ((!hasMax || (hasMax && field <= max)) && (!hasMin || (hasMin && field >= min)));
  }
}

PipelineConfigValidator.registerValidator('cfInstanceSizeField', new CfInstanceSizeFieldValidator());
开发者ID:emjburns,项目名称:deck,代码行数:30,代码来源:instanceSize.validator.ts

示例5: validate

  PipelineConfigValidator,
} from '@spinnaker/core';

export interface IStageWithManifestSelector extends IStage {
  manifestName: string;
  location: string;
}

export class ManifestSelectorValidator implements IStageOrTriggerValidator {
  public validate(
    _pipeline: IPipeline,
    stage: IStageWithManifestSelector,
    _validator: IValidatorConfig,
    _config: IStageOrTriggerTypeConfig,
  ): string {
    const [kind, name] = (stage.manifestName || '').split(' ');
    if (!name && !kind) {
      return `<strong>Name</strong> and <strong>Kind</strong> are required fields.`;
    }
    if (!name) {
      return `<strong>Name</strong> is a required field.`;
    }
    if (!kind) {
      return `<strong>Kind</strong> is a required field.`;
    }
    return null;
  }
}

PipelineConfigValidator.registerValidator('manifestSelector', new ManifestSelectorValidator());
开发者ID:emjburns,项目名称:deck,代码行数:30,代码来源:manifestSelector.validator.ts

示例6: validate

import { get } from 'lodash';

import { IPipeline, IStage, IStageOrTriggerValidator, ITrigger, PipelineConfigValidator } from '@spinnaker/core';

export class CfRequiredRoutesFieldValidator implements IStageOrTriggerValidator {
  public validate(_pipeline: IPipeline, stage: IStage | ITrigger, validationConfig: any): string {
    const routes: string[] = get(stage, validationConfig.fieldName);
    const routeErrors = routes
      .map((route: string) => {
        const regex = /^([-\w]+)\.([-.\w]+)(:\d+)?([-/\w]+)?$/gm;
        route = route || '';
        if (regex.exec(route) === null) {
          return `"${route}" did not match the expected format "host.some.domain[:9999][/some/path]"`;
        }
        return null;
      })
      .filter(err => err != null);
    return (routeErrors && routeErrors.length && routeErrors[0]) || null;
  }
}

PipelineConfigValidator.registerValidator('cfRequiredRoutesField', new CfRequiredRoutesFieldValidator());
开发者ID:emjburns,项目名称:deck,代码行数:22,代码来源:requiredRoutes.validator.ts


注:本文中的@spinnaker/core.PipelineConfigValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。