Skip to content
This repository was archived by the owner on Jun 23, 2026. It is now read-only.

feat: add opal subcommands for pipeline linting and reference - #8

Open
beengud wants to merge 1 commit into
observeinc:mainfrom
beengud:upstream/feat-opal-commands
Open

feat: add opal subcommands for pipeline linting and reference#8
beengud wants to merge 1 commit into
observeinc:mainfrom
beengud:upstream/feat-opal-commands

Conversation

@beengud

@beengud beengud commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Adds observe opal subcommands for OPAL pipeline validation and language reference:

Command Description
observe opal check <pipeline> Lint an OPAL pipeline string using the checkQueries API
observe opal check --file <path> Lint from a file
observe opal verbs List all OPAL verbs with descriptions
observe opal functions List all OPAL built-in functions
observe opal validate-ingest --dataset <id> <expr> Validate an ingest filter expression

These commands are useful for CI/CD pipelines that validate OPAL before deploying dataset changes, and for developers looking up OPAL syntax without leaving the terminal.

GraphQL schema notes (verified against live tenant)

  • checkQueries result fields: col/row/text (not line/column/message)
  • verbsAndFunctions: uses categories [] array (not a category string)
  • validateIngestFilterExpression: returns only { message } (no span info)

Files

  • cmd_opal.go — CLI command handlers
  • cmd_opal_validate.go — ingest validation subcommand
  • ot_opal.go / ot_opal_test.go — GraphQL operations and unit tests
  • cmd_opal_test.go / cmd_opal_extra_test.go — handler unit tests
  • cmd_opal_integration_test.go — integration tests (build tag: integration)
  • cmd_opal_validate_test.go — validate unit tests
  • docs/opal.md — usage documentation

* feat: implement observe opal check command

Adds the opal command with check subcommand that validates OPAL pipelines
using the checkQueries GraphQL API. Also includes skeleton implementations
of opal verbs, opal functions, and opal validate-ingest to enable
compilation (full implementations follow in issues #6 and #7).

- cmd_opal.go: command registration, opal check implementation
- ot_opal.go: verbsAndFunctions query, verbs/functions subcommands
- cmd_opal_validate.go: validateIngestFilterExpression query/subcommand
- cmd_opal_test.go: unit tests with mock HTTP client
- docs/opal.md: command documentation

Closes #5

* feat: implement observe opal verbs and opal functions subcommands

Adds verbsAndFunctions query implementation in ot_opal.go and unit tests
in ot_opal_test.go. Both subcommands query the Observe verbsAndFunctions
GraphQL API and output results sorted alphabetically in tab-separated columns.

- opal verbs: name | category | description
- opal functions: name | category | returnType | description

Closes #6

* test: add edge case unit tests and integration test stub for opal commands

Reviews existing opal test coverage (issues #5, #6) and adds:
- cmd_opal_extra_test.go: edge cases (empty pipeline, multiple errors,
  network errors for all subcommands, validate-ingest warning handling)
- cmd_opal_integration_test.go: stub with build tag //go:build integration
  documenting the integration test plan for issue #9
- cmd_opal.go: move --dataset flag to parent opal flagset for correct parsing
- cmd_opal_validate.go: update to use parent flagset flagOpalDataset

Closes #8

* feat: add integration tests and fix GraphQL schema for opal commands (#9)

Correct all three GQL queries to match the live Observe API schema
(checkQueries uses col/row/text array response, verbsAndFunctions uses
categories array, validateIngestFilterExpression only returns message).
Add full integration test suite under //go:build integration.
Fix global flagOpalFile leak between unit tests causing TestCmdOpalCheckEmptyTextError
to fail when run after TestCmdOpalCheckFile.

---------

Co-authored-by: Aaron Brewbaker <abrewbaker@nhl.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant