Skip to content

Commit

Permalink
opa build: provide an option to preserve print statements for Wasm (o…
Browse files Browse the repository at this point in the history
…pen-policy-agent#7194) (open-policy-agent#7195)

Signed-off-by: Andrii Kurochka <aki.viper@gmail.com>
  • Loading branch information
me-viper authored Nov 30, 2024
1 parent 270f31f commit 4ea1dde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type buildParams struct {
v0Compatible bool
v1Compatible bool
followSymlinks bool
wasmIncludePrint bool
}

func newBuildParams() buildParams {
Expand Down Expand Up @@ -241,6 +242,7 @@ against OPA v0.22.0:
buildCommand.Flags().StringVarP(&buildParams.outputFile, "output", "o", "bundle.tar.gz", "set the output filename")
buildCommand.Flags().StringVar(&buildParams.ns, "partial-namespace", "partial", "set the namespace to use for partially evaluated files in an optimized bundle")
buildCommand.Flags().BoolVar(&buildParams.followSymlinks, "follow-symlinks", false, "follow symlinks in the input set of paths when building the bundle")
buildCommand.Flags().BoolVar(&buildParams.wasmIncludePrint, "wasm-include-print", false, "enable print statements inside of WebAssembly modules compiled by the compiler")

addBundleModeFlag(buildCommand.Flags(), &buildParams.bundleMode, false)
addIgnoreFlag(buildCommand.Flags(), &buildParams.ignore)
Expand Down Expand Up @@ -334,6 +336,10 @@ func dobuild(params buildParams, args []string) error {
compiler = compiler.WithEnablePrintStatements(true)
}

if params.target.String() == compile.TargetWasm {
compiler = compiler.WithEnablePrintStatements(params.wasmIncludePrint)
}

err = compiler.Build(context.Background())
if err != nil {
return err
Expand Down

0 comments on commit 4ea1dde

Please sign in to comment.