Skip to content

Document crossplane resource validate --output flag and programmatic validate API #1101

@jcogilvie

Description

@jcogilvie

What problem are you facing?

The CLI gains a -o/--output text|json|yaml flag on crossplane resource validate (per crossplane/cli#62), and validate's logic is also exposed as a programmatic Go API for downstream consumers like crossplane-diff. The user-facing changes need documentation in docs.crossplane.io.

This issue tracks the docs work for the corresponding cli PR (filed in tandem; will link once it's open against crossplane/cli).

How could Crossplane help solve your problem?

Update the validate-related docs to cover:

1. The new --output flag.

  • Default text is byte-identical to the historical output.

  • json and yaml emit a structured payload with per-resource status and field-level error details (type, field path, message, bad value).

  • Suggested example for the docs (mirrors the --output json | jq idiom in the new CLI help):

    crossplane resource validate extensions.yaml resources.yaml --output json | jq '.summary'
  • --skip-success-results is text-only; in JSON/YAML mode it's ignored (success entries remain in the structured payload so consumers filter themselves).

2. The structured JSON/YAML schema so users can write reliable filters/scripts:

{
  "summary": { "total": 2, "valid": 1, "invalid": 1, "missingSchemas": 0 },
  "resources": [
    {
      "apiVersion": "...", "kind": "...", "name": "...", "namespace": "...",
      "status": "valid" | "invalid" | "missingSchema" | "defaultingFailed",
      "errors": [
        {
          "type": "schema" | "cel" | "unknownField" | "defaulting",
          "field": "spec.replicas",
          "message": "...",
          "value": "..."
        }
      ]
    }
  ]
}

3. Programmatic Go API (a contributor-facing note, possibly under contributing/integration docs rather than user docs).

The cli now ships a cmd/crossplane/pkg/validate package that returns a *ValidationResult directly, and a sibling cmd/crossplane/pkg/validate/render package that converts it to text/JSON/YAML. Tools that previously parsed validate's stdout (notably crossplane-diff) can switch to importing the Go API — worth a callout for downstream tool authors.

Pointers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions