Module: Equilibrium::Schemas

Defined in:
lib/equilibrium/schemas/catalog.rb,
lib/equilibrium/schemas/registry_api.rb,
lib/equilibrium/schemas/analyzer_output.rb,
lib/equilibrium/schemas/expected_actual.rb

Constant Summary collapse

CATALOG =

JSON Schema for catalog output format Used by catalog command

Example output: { "repository_url": "gcr.io/datadoghq/apm-inject", "repository_name": "apm-inject", "images": [ { "tag": "latest", "digest": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "canonical_version": "0.43.2" }, { "tag": "0", "digest": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "canonical_version": "0.43.2" }, { "tag": "0.43", "digest": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "canonical_version": "0.43.1" } ] }

{
  "$schema" => "https://json-schema.org/draft/2020-12/schema",
  "title" => "Tag Resolver Schema",
  "description" => "Schema for Resolve tag",
  "type" => "object",
  "required" => ["repository_url", "repository_name", "images"],
  "properties" => {
    "repository_url" => {
      "type" => "string",
      "description" => "Full repository URL (e.g., 'gcr.io/project-id/image-name')",
      "minLength" => 1,
      "pattern" => "^[a-zA-Z0-9.-]+(/[a-zA-Z0-9._-]+)*$"
    },
    "repository_name" => {
      "type" => "string",
      "description" => "Repository name extracted from URL (e.g., 'apm-inject')",
      "minLength" => 1,
      "pattern" => "^[a-zA-Z0-9._-]+$"
    },
    "images" => {
      "type" => "array",
      "items" => {
        "type" => "object",
        "required" => [
          "tag",
          "digest",
          "canonical_version"
        ],
        "properties" => {
          "tag" => {
            "type" => "string",
            "description" => "The mutable tag of the image"
          },
          "digest" => {
            "type" => "string",
            "description" => "The full digest of the image",
            "pattern" => "^sha256:[a-f0-9]{64}$"
          },
          "canonical_version" => {
            "type" => "string",
            "description" => "The canonical semantic version for this mutable tag",
            "pattern" => "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
          }
        },
        "additionalProperties" => false
      }
    }
  },
  "additionalProperties" => false
}.freeze
REGISTRY_API_RESPONSE =

JSON Schema for Docker Registry v2 API tags/list endpoint response Used by RegistryClient to validate API responses Endpoint: https://docs.docker.com/registry/spec/api/#listing-image-tags

Example response: { "name": "datadoghq/apm-inject", "tags": ["0.42.0", "0.42.1", "0.43.0", "latest"], "manifest": { "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c": { "tag": ["latest", "0.43.0", "0"] }, "sha256:c7a822d271eb72e6c3bee2aaf579c8a3732eda9710d27effdca6beb3f5f63b0e": { "tag": ["0.42.1", "0.42"] } } }

{
  "$schema" => "https://json-schema.org/draft/2020-12/schema",
  "title" => "Docker Registry v2 Tags List Response Schema",
  "description" => "Schema for response from Docker Registry v2 API /v2/{name}/tags/list endpoint",
  "type" => "object",
  "required" => ["name", "tags", "manifest"],
  "properties" => {
    "name" => {
      "type" => "string",
      "description" => "Repository name"
    },
    "tags" => {
      "type" => "array",
      "description" => "List of tag names",
      "items" => {
        "type" => "string"
      }
    },
    "manifest" => {
      "type" => "object",
      "description" => "Manifest data mapping digests to tag metadata",
      "patternProperties" => {
        "^sha256:[a-f0-9]{64}$" => {
          "type" => "object",
          "properties" => {
            "tag" => {
              "type" => "array",
              "items" => {
                "type" => "string"
              }
            }
          },
          "additionalProperties" => true
        }
      },
      "additionalProperties" => false
    }
  },
  "additionalProperties" => true
}.freeze
ANALYZER_OUTPUT =

JSON Schema for analyzer output format Used by equilibrium analyze --format=json command

Example output (perfect equilibrium): { "repository_url": "gcr.io/datadoghq/apm-inject", "repository_name": "apm-inject", "expected_count": 28, "actual_count": 28, "missing_tags": {}, "unexpected_tags": {}, "mismatched_tags": {}, "status": "perfect" }

Example output (with discrepancies): { "repository_url": "gcr.io/datadoghq/example", "repository_name": "example", "expected_count": 3, "actual_count": 2, "missing_tags": { "latest": { "expected": "sha256:abc123ef456789...", "actual": "" } }, "unexpected_tags": { "dev": { "expected": "", "actual": "sha256:xyz789ab123456..." } }, "mismatched_tags": { "0.1": { "expected": "sha256:def456ab789123...", "actual": "sha256:old123ef456789..." } }, "status": "missing_tags" }

{
  "$schema" => "https://json-schema.org/draft/2020-12/schema",
  "title" => "Equilibrium Analyzer Output Schema",
  "description" => "Schema for output from 'equilibrium analyze --format=json' command",
  "type" => "object",
  "required" => [
    "repository_url",
    "repository_name", "expected_count", "actual_count", "missing_tags", "unexpected_tags", "mismatched_tags", "status"
  ],
  "properties" => {
    "repository_url" => {"type" => "string"},
    "repository_name" => {"type" => "string"},
    "expected_count" => {"type" => "integer", "minimum" => 0},
    "actual_count" => {"type" => "integer", "minimum" => 0},
    "status" => {"enum" => ["perfect", "missing_tags", "mismatched", "extra_tags"]},
    "missing_tags" => {
      "type" => "object",
      "patternProperties" => {
        ".*" => {
          "type" => "object",
          "required" => ["expected", "actual"],
          "properties" => {
            "expected" => {"type" => "string", "pattern" => "^sha256:[a-f0-9]{64}$"},
            "actual" => {"type" => "string", "enum" => [""]}
          }
        }
      }
    },
    "unexpected_tags" => {
      "type" => "object",
      "patternProperties" => {
        ".*" => {
          "type" => "object",
          "required" => ["expected", "actual"],
          "properties" => {
            "expected" => {"type" => "string", "enum" => [""]},
            "actual" => {"type" => "string", "pattern" => "^sha256:[a-f0-9]{64}$"}
          }
        }
      }
    },
    "mismatched_tags" => {
      "type" => "object",
      "patternProperties" => {
        ".*" => {
          "type" => "object",
          "required" => ["expected", "actual"],
          "properties" => {
            "expected" => {"type" => "string", "pattern" => "^sha256:[a-f0-9]{64}$"},
            "actual" => {"type" => "string", "pattern" => "^sha256:[a-f0-9]{64}$"}
          }
        }
      }
    }
  }
}.freeze
EXPECTED_ACTUAL =

JSON Schema for expected/actual command output format Used by expected, actual and uncatalog commands

Example output: { "repository_url": "gcr.io/datadoghq/apm-inject", "repository_name": "apm-inject", "digests": { "latest": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "0": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "0.43": "sha256:5fcfe7ac14f6eeb0fe086ac7021d013d764af573b8c2d98113abf26b4d09b58c", "0.42": "sha256:c7a822d271eb72e6c3bee2aaf579c8a3732eda9710d27effdca6beb3f5f63b0e" }, "canonical_versions": { "latest": "0.43.2", "0": "0.43.2", "0.43": "0.43.1", "0.42": "0.42.3" } }

{
  "$schema" => "https://json-schema.org/draft/2020-12/schema",
  "title" => "Equilibrium Expected/Actual Output Schema",
  "description" => "Schema for output from 'equilibrium expected' and 'equilibrium actual' commands",
  "type" => "object",
  "required" => ["repository_url", "repository_name", "digests", "canonical_versions"],
  "properties" => {
    "repository_url" => {
      "type" => "string",
      "description" => "Full repository URL (e.g., 'gcr.io/project-id/image-name', 'registry.example.com/namespace/repository')",
      "minLength" => 1,
      "pattern" => "^[a-zA-Z0-9.-]+(/[a-zA-Z0-9._-]+)*$"
    },
    "repository_name" => {
      "type" => "string",
      "description" => "Repository name extracted from URL (e.g., 'apm-inject')",
      "minLength" => 1,
      "pattern" => "^[a-zA-Z0-9._-]+$"
    },
    "digests" => {
      "type" => "object",
      "description" => "Mapping of mutable tags to their SHA256 digests",
      "minProperties" => 1,
      "patternProperties" => {
        "^(latest|[0-9]+(\\.[0-9]+)*)$" => {
          "type" => "string",
          "description" => "SHA256 digest for the tag",
          "pattern" => "^sha256:[a-f0-9]{64}$"
        }
      },
      "additionalProperties" => false
    },
    "canonical_versions" => {
      "type" => "object",
      "description" => "Mapping of mutable tags to their canonical semantic versions",
      "minProperties" => 1,
      "patternProperties" => {
        "^(latest|[0-9]+(\\.[0-9]+)*)$" => {
          "type" => "string",
          "description" => "Canonical semantic version for the mutable tag",
          "pattern" => "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
        }
      },
      "additionalProperties" => false
    }
  },
  "additionalProperties" => false
}.freeze