Exemplo n.º 1
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
      # ... from base.json ...
      libs = jobObj.get("library")
      for lib in libs:
          manifests.append(Manifest(lib.manipath))

      # ... or default location.
      if not manifests:
          manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = mnfst.validateAgainst(Manifest.schema_v1_0())

        if errors:
            console.warn("Errors found in " + mnfst.path)
            console.indent()
            for error in errors:
                console.warn(error["msg"] + " in '%s' (JSONPath)" % __convertToJSONPath(error["path"]))
            console.outdent()
        else:
            console.log("%s validates successful against used JSON Schema." % mnfst.path)
Exemplo n.º 2
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
        # ... from base.json ...
        libs = jobObj.get("library")
        for lib in libs:
            manifests.append(Manifest(lib.manipath))

        # ... or default location.
        if not manifests:
            manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = mnfst.validateAgainst(Manifest.schema_v1_0())

        if errors:
            console.warn("Errors found in " + mnfst.path)
            console.indent()
            for error in errors:
                console.warn(error["msg"] + " in '%s' (JSONPath)" %
                             __convertToJSONPath(error["path"]))
            console.outdent()
        else:
            console.log("%s validates successful against used JSON Schema." %
                        mnfst.path)
Exemplo n.º 3
0
def validateManifest(jobconf, confObj):
    """ Validates Manifest and prints to stdOut.

    :param jobconf: generator.config.Job.Job
    :param confObj: generator.config.Config.Config
    """
    errors = []
    console = Context.console

    mnfst = None
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        mnfst = Manifest(global_let["ARGS"][0])
    else:
        mnfst = Manifest("Manifest.json")

    errors = mnfst.validateAgainst(Manifest.schema_v1_0())

    if errors:
        for error in errors:
            console.warn(error["msg"] + " in '%s' (JSONPath)" % __convertToJSONPath(error["path"]))
    else:
        console.log("%s validates successful against used JSON Schema." % mnfst.path)
Exemplo n.º 4
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
        # ... from base.json ...
        libs = jobObj.get("library")
        if libs:
            for lib in libs:
                manifests.append(Manifest(lib.manipath))

        # ... or default location.
        if not manifests:
            manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = __validate(mnfst._manifest, Manifest.schema_v1_0())
        __printResults(console, errors, mnfst.path)
Exemplo n.º 5
0
def validateManifest(jobObj, confObj):
    errors = []
    console = Context.console

    manifests = []

    # detect manifest path(s) as cli arg, ...
    global_let = confObj.get("let")
    if "ARGS" in global_let and len(global_let["ARGS"]) == 1:
        manifests.append(Manifest(global_let["ARGS"][0]))
    else:
        # ... from base.json ...
        libs = jobObj.get("library")
        if libs:
            for lib in libs:
                manifests.append(Manifest(lib.manipath))

        # ... or default location.
        if not manifests:
            manifests.append(Manifest("Manifest.json"))

    for mnfst in manifests:
        errors = __validate(mnfst._manifest, Manifest.schema_v1_0())
        __printResults(console, errors, mnfst.path)