當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。