Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/collect-keyless-params.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= collect-keyless-params

Version: 0.1
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec

Conforma CLI
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_compare.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec compare

Compare two Conforma Policy specs for equivalence
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_fetch.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec fetch

Fetch remote resources
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_fetch_policy.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec fetch policy

Fetch policy rules from a git repository or other source
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_init.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec init

Initialize a directory for use
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_init_policies.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec init policies

Initialize a directory with minimal EC scaffolding
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_inspect.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec inspect

Inspect policy rules
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_inspect_policy-data.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec inspect policy-data

Read policy data from source urls and displays the data
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_inspect_policy.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec inspect policy

Read policies from source urls and show information about the rules inside them
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_blob.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.blob

Fetch a blob from an OCI registry.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_blob_files.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.blob_files

Fetch structured files (YAML or JSON) from within a blob tar archive.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_descriptor.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.descriptor

Fetch a raw Image from an OCI registry.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_files.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_files

Fetch structured files (YAML or JSON) from within an image.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_index.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_index

Fetch an Image Index from an OCI registry.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_manifest.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_manifest

Fetch an Image Manifest from an OCI registry.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_manifests.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_manifests

Fetch Image Manifests from an OCI registry in parallel.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_referrers.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_referrers

Discover artifacts attached to an image via OCI Referrers API.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_image_tag_refs.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.image_tag_refs

Discover artifacts attached to an image via legacy tag-based discovery (cosign .sig, .att, .sbom suffixes).
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_oci_parsed_blob.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.oci.parsed_blob

Fetch a blob from an OCI registry and return the parsed JSON value. Results are cached per component.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa

Open Policy Agent (OPA) (embedded)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_bench.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa bench

Benchmark a Rego query
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_build.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa build

Build an OPA bundle
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_capabilities.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa capabilities

Print the capabilities of OPA
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_check.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa check

Check Rego source files
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_deps.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa deps

Analyze Rego query dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_eval.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa eval

Evaluate a Rego query
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_exec.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa exec

Execute against input files
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_fmt.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa fmt

Format Rego source files
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_inspect.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa inspect

Inspect OPA bundle(s)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_parse.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa parse

Parse Rego source file
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_run.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa run

Start OPA in interactive or server mode
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_sign.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa sign

Generate an OPA bundle signature
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_test.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa test

Execute Rego test cases
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_opa_version.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec opa version

Print the version of OPA
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_purl_is_valid.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.purl.is_valid

Determine whether or not a given PURL is valid.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_purl_parse.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.purl.parse

Parse a valid PURL into an object.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_sigstore.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec sigstore

Perform certain sigstore operations
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_sigstore_initialize.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec sigstore initialize

Initializes Sigstore root to retrieve trusted certificate and key targets for verification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.sigstore.verify_attestation

Use sigstore to verify the attestation of an image.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_sigstore_verify_image.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec.sigstore.verify_image

Use sigstore to verify the signature of an image.
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_test.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec test

Test your configuration files using Open Policy Agent
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_track.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec track

Record resource references for tracking purposes
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_track_bundle.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec track bundle

Record tracking information about Tekton bundles
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec validate

Validate conformance with the provided policies
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_image.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec validate image

Validate conformance of container images with the provided policies
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_input.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec validate input

Validate arbitrary JSON or yaml file input conformance with the provided policies
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_policy.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec validate policy

Validate the provided EnterpriseContractPolicy spec
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_validate_vsa.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec validate vsa

Validate VSA (Verification Summary Attestation)
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/ec_version.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec version

Print version information
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/rego_builtins.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= ec rego functions reference documentation

The EC CLI provides custom rego builtin functions in addition to the
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/verify-conforma-konflux-ta.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= verify-conforma-konflux-ta

Version: 0.1
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/verify-enterprise-contract.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Generated by conforma CLI documentation tooling. DO NOT EDIT.
= verify-enterprise-contract

Version: 0.1
Expand Down
88 changes: 84 additions & 4 deletions internal/documentation/asciidoc/asciidoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,105 @@
package asciidoc

import (
_ "embed"
"bufio"
"fmt"
"os"
"path/filepath"
"strings"

"github.com/conforma/cli/internal/documentation/asciidoc/cli"
"github.com/conforma/cli/internal/documentation/asciidoc/rego"
"github.com/conforma/cli/internal/documentation/asciidoc/tekton"
)

// GeneratedMarker is the comment placed at the top of generated Asciidoc files
// to distinguish them from handwritten documentation.
const GeneratedMarker = "// Generated by conforma CLI documentation tooling. DO NOT EDIT."

func GenerateAsciidoc(module string) error {
if err := cli.GenerateCommandLineDocumentation(module); err != nil {
var generated []string

cliGenerated, err := cli.GenerateCommandLineDocumentation(module)
if err != nil {
return err
}
generated = append(generated, cliGenerated...)

regoGenerated, err := rego.GenerateRegoReference(module)
if err != nil {
return err
}
generated = append(generated, regoGenerated...)

if err := rego.GenerateRegoReference(module); err != nil {
tektonGenerated, err := tekton.GenerateTektonDocumentation(module)
if err != nil {
return err
}
generated = append(generated, tektonGenerated...)

if err := tekton.GenerateTektonDocumentation(module); err != nil {
if err := removeAbandonedPages(module, generated); err != nil {
return err
}

return nil
}

// removeAbandonedPages removes generated Asciidoc page files that were not
// produced in the current generation run. A file is considered generated if its
// first line matches the GeneratedMarker. Handwritten files are left untouched.
func removeAbandonedPages(module string, generated []string) error {
generatedSet := make(map[string]struct{}, len(generated))
for _, p := range generated {
generatedSet[p] = struct{}{}
}

pagesDir := filepath.Join(module, "pages")
entries, err := os.ReadDir(pagesDir)
if err != nil {
return fmt.Errorf("reading pages directory %q: %w", pagesDir, err)
}

for _, entry := range entries {
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".adoc") {
continue
}

path := filepath.Join(pagesDir, entry.Name())
if _, ok := generatedSet[path]; ok {
// File was just generated, keep it.
continue
}

isGenerated, err := hasGeneratedMarker(path)
if err != nil {
return fmt.Errorf("checking generated marker in %q: %w", path, err)
}
if !isGenerated {
// Handwritten file, leave it alone.
continue
}

if err := os.Remove(path); err != nil {
return fmt.Errorf("removing abandoned file %q: %w", path, err)
}
}

return nil
}

// hasGeneratedMarker reports whether the first line of the file matches
// GeneratedMarker.
func hasGeneratedMarker(path string) (bool, error) {
f, err := os.Open(path)
if err != nil {
return false, err
}
defer f.Close()

scanner := bufio.NewScanner(f)
if scanner.Scan() {
return scanner.Text() == GeneratedMarker, nil
}

return false, scanner.Err()
}
Loading
Loading