Skip to content

OPA Client Implementation#1

Merged
TomerShor merged 2 commits intonuclio:mainfrom
TomerShor:opa-init
Jul 2, 2025
Merged

OPA Client Implementation#1
TomerShor merged 2 commits intonuclio:mainfrom
TomerShor:opa-init

Conversation

@TomerShor
Copy link
Contributor

Implements a complete OPA (Open Policy Agent) client library for Go.

Key features:

  • HTTP client with single and multi-resource permission queries
  • Factory pattern supporting HTTP, mock, and no-op implementations
  • Simplified verbose logging configuration
  • User-Agent headers and version management
  • Comprehensive documentation and examples
  • Linting configuration and code quality tools
  • CI workflow

This provides a production-ready OPA client following Go best practices.

Copy link

@quaark quaark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Copy link

@liranbg liranbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very well, minor fixes

- typecheck
- gocritic
- unused
- gci
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing import order on gci

http.go Outdated
Comment on lines +113 to +115
c.logger.InfoWith("Sending request to OPA",
"requestBody", string(requestBody),
"requestURL", requestURL)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c.logger.InfoWith("Sending request to OPA",
"requestBody", string(requestBody),
"requestURL", requestURL)
c.logger.InfoWithCtx(ctx, "Sending request to OPA",
"requestBody", string(requestBody),
"requestURL", requestURL)

http.go Outdated
Comment on lines +137 to +138
c.logger.ErrorWith("Failed to send HTTP request to OPA",
"err", errors.GetErrorStackString(err, 10))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well, log with ctx

@TomerShor TomerShor requested a review from liranbg July 1, 2025 08:28
@TomerShor TomerShor merged commit abe4173 into nuclio:main Jul 2, 2025
@TomerShor TomerShor deleted the opa-init branch July 2, 2025 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants