From e7f9eb42ceb161abede685373eb9575f039a0d44 Mon Sep 17 00:00:00 2001 From: tan Date: Mon, 28 Oct 2024 14:54:56 +0530 Subject: [PATCH 1/6] feat: remove dependency on OpenPolicyAgent_jll Removing hard dependency on `OpenPolicyAgent_jll`. Since we allow caller to specify an opa executable, not having a tight dependency will allow calling code to avoid installing the jll at all. So that it will not be affected if the jll is not updated/outdated. --- Project.toml | 7 +++---- docs/src/commandline.md | 6 +++--- specs/cli/gencli.jl | 4 +--- src/cli/cli.jl | 4 +--- test/runtests.jl | 5 +++-- test/test_utils.jl | 7 ++++--- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Project.toml b/Project.toml index 81e76a5..e2111bc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,12 +1,11 @@ name = "OpenPolicyAgent" uuid = "8f257efb-743c-4ebc-8197-d291a1f743b4" authors = ["JuliaHub Inc.", "Tanmay Mohapatra "] -version = "0.3.3" +version = "0.4.0" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" OpenAPI = "d5e62ea6-ddf3-4d43-8e4c-ad5e6c8bfd7d" -OpenPolicyAgent_jll = "6ea5c882-2ec3-5826-84d1-aff636352c13" TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" [compat] @@ -14,12 +13,12 @@ Dates = "1.6" OpenAPI = "0.1" TimeZones = "1" julia = "1.6" -OpenPolicyAgent_jll = "0.69" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" +OpenPolicyAgent_jll = "6ea5c882-2ec3-5826-84d1-aff636352c13" [targets] -test = ["Test", "JSON", "HTTP"] +test = ["Test", "JSON", "HTTP", "OpenPolicyAgent_jll"] diff --git a/docs/src/commandline.md b/docs/src/commandline.md index 66174b6..52b6a0b 100644 --- a/docs/src/commandline.md +++ b/docs/src/commandline.md @@ -2,14 +2,14 @@ The OPA (Open Policy Agent) command-line tool is a versatile utility that empowers users to interact with and manage OPA policies and data. It allows users to perform various tasks, such as evaluating policies, testing Rego expressions, and querying data, all from the command line. This tool is invaluable for policy development, debugging, and troubleshooting, providing an accessible way to work with OPA without the need for complex integration. It's an essential companion for developers and administrators working with OPA, simplifying the process of authoring, testing, and refining policies to ensure robust and consistent policy enforcement across software systems. -The OPA command line is made available in the `OpenPolicyAgent.CLI` module. To use, import the module. E.g.: +The OPA command line is made available in the `OpenPolicyAgent.CLI` module. To use, import the module. It needs the `opa` executable to be made available. If already instaled, it should be made available in the `PATH` environment. Otherwise, the `OpenPolicyAgent_jll` package can be used too. E.g.: ```julia -julia> using OpenPolicyAgent +julia> using OpenPolicyAgent, OpenPolicyAgent_jll julia> import OpenPolicyAgent: CLI -julia> ctx = CLI.CommandLine(); +julia> ctx = CLI.CommandLine(exec=OpenPolicyAgent_jll.opa); julia> CLI.opa(ctx; help=true); An open source project to policy-enable your service. diff --git a/specs/cli/gencli.jl b/specs/cli/gencli.jl index cee1e00..44cb4ee 100644 --- a/specs/cli/gencli.jl +++ b/specs/cli/gencli.jl @@ -5,8 +5,6 @@ const SPEC = joinpath(sdir, "opa.json") const CLIMODULE = joinpath(sdir, "..", "..", "src", "cli", "cli.jl") const custom_include = """ -using OpenPolicyAgent_jll - \"\"\" CommandLine execution context. @@ -15,7 +13,7 @@ CommandLine execution context. `pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation \"\"\" Base.@kwdef struct CommandLine - exec::Base.Function = OpenPolicyAgent_jll.opa + exec::Base.Function = ()->`opa` cmdopts::OptsType = OptsType() pipelineopts::OptsType = OptsType() runopts::OptsType = OptsType() diff --git a/src/cli/cli.jl b/src/cli/cli.jl index aeee72c..37988e0 100644 --- a/src/cli/cli.jl +++ b/src/cli/cli.jl @@ -9,8 +9,6 @@ module CLI const OptsType = Base.Dict{Base.Symbol,Base.Any} -using OpenPolicyAgent_jll - """ CommandLine execution context. @@ -19,7 +17,7 @@ CommandLine execution context. `pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation """ Base.@kwdef struct CommandLine - exec::Base.Function = OpenPolicyAgent_jll.opa + exec::Base.Function = ()->`opa` cmdopts::OptsType = OptsType() pipelineopts::OptsType = OptsType() runopts::OptsType = OptsType() diff --git a/test/runtests.jl b/test/runtests.jl index 35f7abe..388834e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,5 @@ using OpenPolicyAgent +using OpenPolicyAgent_jll using OpenAPI using JSON using HTTP @@ -18,7 +19,7 @@ function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) - cmd = OpenPolicyAgent.CLI.CommandLine(; pipelineopts=pipelineopts) + cmd = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, pipelineopts=pipelineopts) CLI.version(cmd) if Sys.iswindows() sleep(10) # Windows is slow to flush the buffers @@ -29,7 +30,7 @@ function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) - cmd = OpenPolicyAgent.CLI.CommandLine(; pipelineopts=pipelineopts) + cmd = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, pipelineopts=pipelineopts) CLI.help(cmd) if Sys.iswindows() sleep(10) # Windows is slow to flush the buffers diff --git a/test/test_utils.jl b/test/test_utils.jl index e0d520b..49cd6c0 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -2,7 +2,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "data.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(; cmdopts=Dict(:dir => data_bundle_root)), + CLI.build(OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => data_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -10,7 +10,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "policies.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(; cmdopts=Dict(:dir => policies_bundle_root)), + CLI.build(OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => policies_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -48,13 +48,14 @@ function start_opa_server(root_path; change_dir::Bool=true) joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), - cmdline = OpenPolicyAgent.CLI.CommandLine(; cmdopts=Dict(:dir => root_path)), + cmdline = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => root_path)), ) else opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), + cmdline = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa), ) end OpenPolicyAgent.Server.start!(opa_server) From 6cf5f47bb1d6c9612d5407d09ec3c89fa78a57a7 Mon Sep 17 00:00:00 2001 From: tan Date: Mon, 28 Oct 2024 18:52:42 +0530 Subject: [PATCH 2/6] require opa command to be supplied explicitly --- docs/src/commandline.md | 4 ++-- docs/src/server.md | 3 +++ src/cli/cli.jl | 15 +++++++++++---- src/server/server.jl | 13 +++++++------ test/runtests.jl | 4 ++-- test/test_utils.jl | 8 ++++---- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/docs/src/commandline.md b/docs/src/commandline.md index 52b6a0b..c9a96a1 100644 --- a/docs/src/commandline.md +++ b/docs/src/commandline.md @@ -2,14 +2,14 @@ The OPA (Open Policy Agent) command-line tool is a versatile utility that empowers users to interact with and manage OPA policies and data. It allows users to perform various tasks, such as evaluating policies, testing Rego expressions, and querying data, all from the command line. This tool is invaluable for policy development, debugging, and troubleshooting, providing an accessible way to work with OPA without the need for complex integration. It's an essential companion for developers and administrators working with OPA, simplifying the process of authoring, testing, and refining policies to ensure robust and consistent policy enforcement across software systems. -The OPA command line is made available in the `OpenPolicyAgent.CLI` module. To use, import the module. It needs the `opa` executable to be made available. If already instaled, it should be made available in the `PATH` environment. Otherwise, the `OpenPolicyAgent_jll` package can be used too. E.g.: +The OPA command line is made available in the `OpenPolicyAgent.CLI` module. To use, import the module. It needs the `opa` executable to be made available. The `OpenPolicyAgent_jll` package has the `opa` executable built-in and can be used conveniently. E.g.: ```julia julia> using OpenPolicyAgent, OpenPolicyAgent_jll julia> import OpenPolicyAgent: CLI -julia> ctx = CLI.CommandLine(exec=OpenPolicyAgent_jll.opa); +julia> ctx = CLI.CommandLine(OpenPolicyAgent_jll.opa); julia> CLI.opa(ctx; help=true); An open source project to policy-enable your service. diff --git a/docs/src/server.md b/docs/src/server.md index c4a317b..a496ae1 100644 --- a/docs/src/server.md +++ b/docs/src/server.md @@ -5,9 +5,12 @@ The OPA (Open Policy Agent) server is a critical component of the OPA ecosystem, The `OpenPolicyAgent.Server` module includes methods to help start the OPA server, monitor it for failures, and restart when required. +It needs to be supplied with the `opa` executable path. The one bundled with `OpenPolicyAgent_jll` can be used for convenience. + ```julia function start_opa_server(root_path) opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( + OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa), joinpath(root_path, "config.yaml"), stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), diff --git a/src/cli/cli.jl b/src/cli/cli.jl index 37988e0..d6c5ed2 100644 --- a/src/cli/cli.jl +++ b/src/cli/cli.jl @@ -12,17 +12,24 @@ const OptsType = Base.Dict{Base.Symbol,Base.Any} """ CommandLine execution context. -`exec`: a no argument function that provides the base command to execute in a julia `do` block. -`cmdopts`: keyword arguments that should be used to further customize the `Cmd` creation -`pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation +CommandLine(exec; cmdopts, pipelineopts, runopts) + +- `exec`: a no argument function that provides the base command to execute in a julia `do` block. +- `cmdopts`: keyword arguments that should be used to further customize the `Cmd` creation +- `pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation +- `runopts`: additional options to be passed to the `Base.run` method """ Base.@kwdef struct CommandLine - exec::Base.Function = ()->`opa` + exec::Base.Function = ()->`` cmdopts::OptsType = OptsType() pipelineopts::OptsType = OptsType() runopts::OptsType = OptsType() end +function CommandLine(exec::Base.Function; kwargs...) + return CommandLine(; exec=exec, kwargs...) +end + """ opa Run the opa command. Open Policy Agent (OPA) diff --git a/src/server/server.jl b/src/server/server.jl index 27e4613..905fd8f 100644 --- a/src/server/server.jl +++ b/src/server/server.jl @@ -7,7 +7,9 @@ import Base: Process const DEFAULT_PORT = 8181 """ - MonitoredOPAServer(configfile::String; + MonitoredOPAServer( + cmdline::CommandLine, + configfile::String; host::String = "localhost", port::Int = DEFAULT_PORT, stdout = nothing, @@ -17,6 +19,7 @@ const DEFAULT_PORT = 8181 A server that is monitored and restarted if it dies. Arguments: +- `cmdline`: The `CLI.CommandLine` instrance that wraps an opa executable. - `configfile`: The path to the OPA configuration file. Keyword arguments: @@ -37,16 +40,14 @@ struct MonitoredOPAServer stopped::Ref{Bool} lck::ReentrantLock - function MonitoredOPAServer(configfile::String; + function MonitoredOPAServer( + cmdline::CommandLine, + configfile::String; host::String = "localhost", port::Int = DEFAULT_PORT, stdout = nothing, stderr = nothing, - cmdline = nothing, ) - if isnothing(cmdline) - cmdline = CommandLine() - end cmdline.runopts[:wait] = false return new(configfile, diff --git a/test/runtests.jl b/test/runtests.jl index 388834e..1d47cbd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -19,7 +19,7 @@ function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) - cmd = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, pipelineopts=pipelineopts) + cmd = OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; pipelineopts=pipelineopts) CLI.version(cmd) if Sys.iswindows() sleep(10) # Windows is slow to flush the buffers @@ -30,7 +30,7 @@ function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) - cmd = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, pipelineopts=pipelineopts) + cmd = OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; pipelineopts=pipelineopts) CLI.help(cmd) if Sys.iswindows() sleep(10) # Windows is slow to flush the buffers diff --git a/test/test_utils.jl b/test/test_utils.jl index 49cd6c0..647dc2b 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -2,7 +2,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "data.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => data_bundle_root)), + CLI.build(OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => data_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -10,7 +10,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "policies.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => policies_bundle_root)), + CLI.build(OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => policies_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -45,17 +45,17 @@ end function start_opa_server(root_path; change_dir::Bool=true) if change_dir opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( + OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => root_path)), joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), - cmdline = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa, cmdopts=Dict(:dir => root_path)), ) else opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( + OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa), joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), - cmdline = OpenPolicyAgent.CLI.CommandLine(; exec=OpenPolicyAgent_jll.opa), ) end OpenPolicyAgent.Server.start!(opa_server) From 55c894db20ee7abc2c4cb8e222473ee743095a17 Mon Sep 17 00:00:00 2001 From: tan Date: Tue, 29 Oct 2024 06:19:04 +0530 Subject: [PATCH 3/6] do not generate CLI code that uses `opa` from path --- specs/cli/gencli.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/cli/gencli.jl b/specs/cli/gencli.jl index 44cb4ee..8dc3677 100644 --- a/specs/cli/gencli.jl +++ b/specs/cli/gencli.jl @@ -13,7 +13,7 @@ CommandLine execution context. `pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation \"\"\" Base.@kwdef struct CommandLine - exec::Base.Function = ()->`opa` + exec::Base.Function = ()->`` cmdopts::OptsType = OptsType() pipelineopts::OptsType = OptsType() runopts::OptsType = OptsType() From 7f777bd21ddb246657d3f21db7458b46e5f4ee0b Mon Sep 17 00:00:00 2001 From: tan Date: Tue, 29 Oct 2024 06:49:24 +0530 Subject: [PATCH 4/6] remove kwdef constructor for CommandLine --- src/cli/cli.jl | 18 +++++++++--------- test/runtests.jl | 4 ++-- test/test_utils.jl | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cli/cli.jl b/src/cli/cli.jl index d6c5ed2..eb9bdf3 100644 --- a/src/cli/cli.jl +++ b/src/cli/cli.jl @@ -19,15 +19,15 @@ CommandLine(exec; cmdopts, pipelineopts, runopts) - `pipelineopts`: keyword arguments that should be used to further customize the `pipeline` creation - `runopts`: additional options to be passed to the `Base.run` method """ -Base.@kwdef struct CommandLine - exec::Base.Function = ()->`` - cmdopts::OptsType = OptsType() - pipelineopts::OptsType = OptsType() - runopts::OptsType = OptsType() -end - -function CommandLine(exec::Base.Function; kwargs...) - return CommandLine(; exec=exec, kwargs...) +struct CommandLine + exec::Base.Function + cmdopts::OptsType + pipelineopts::OptsType + runopts::OptsType + + function CommandLine(exec::Base.Function; cmdopts::OptsType = OptsType(), pipelineopts::OptsType = OptsType(), runopts::OptsType = OptsType()) + return new(exec, cmdopts, pipelineopts, runopts) + end end """ opa diff --git a/test/runtests.jl b/test/runtests.jl index 1d47cbd..97f2f0e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,7 +18,7 @@ import .OPASQL: translate function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() - pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) + pipelineopts = CLI.OptsType(:stdout => iob_stdout, :stderr => iob_stderr) cmd = OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; pipelineopts=pipelineopts) CLI.version(cmd) if Sys.iswindows() @@ -29,7 +29,7 @@ function test_version_help() iob_stdout = IOBuffer() iob_stderr = IOBuffer() - pipelineopts = Dict(:stdout => iob_stdout, :stderr => iob_stderr) + pipelineopts = CLI.OptsType(:stdout => iob_stdout, :stderr => iob_stderr) cmd = OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; pipelineopts=pipelineopts) CLI.help(cmd) if Sys.iswindows() diff --git a/test/test_utils.jl b/test/test_utils.jl index 647dc2b..2718994 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -2,7 +2,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "data.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => data_bundle_root)), + CLI.build(CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=CLI.OptsType(:dir => data_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -10,7 +10,7 @@ function prepare_bundle(bundle_location::String) signed_bundle_file = joinpath(bundle_location, "policies.tar.gz") run(`rm -f $signed_bundle_file`) - CLI.build(OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => policies_bundle_root)), + CLI.build(CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=CLI.OptsType(:dir => policies_bundle_root)), "."; output=signed_bundle_file, bundle_args... @@ -45,14 +45,14 @@ end function start_opa_server(root_path; change_dir::Bool=true) if change_dir opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( - OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=Dict(:dir => root_path)), + CLI.CommandLine(OpenPolicyAgent_jll.opa; cmdopts=CLI.OptsType(:dir => root_path)), joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), ) else opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( - OpenPolicyAgent.CLI.CommandLine(OpenPolicyAgent_jll.opa), + CLI.CommandLine(OpenPolicyAgent_jll.opa), joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), From 96120546b8d970899c27f91f957c371ec3d554e6 Mon Sep 17 00:00:00 2001 From: tan Date: Tue, 29 Oct 2024 06:57:20 +0530 Subject: [PATCH 5/6] add convenience constructor for MonitoredOPAServer --- src/server/server.jl | 2 ++ test/test_utils.jl | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/server.jl b/src/server/server.jl index 905fd8f..fac3a09 100644 --- a/src/server/server.jl +++ b/src/server/server.jl @@ -62,6 +62,8 @@ struct MonitoredOPAServer end end +MonitoredOPAServer(exec::Function, configfile::String; kwargs...) = MonitoredOPAServer(CommandLine(exec), configfile; kwargs...) + function start_opa_server!(server::MonitoredOPAServer) ctx = server.cmdline if !isnothing(server.stdout) diff --git a/test/test_utils.jl b/test/test_utils.jl index 2718994..dee6aac 100644 --- a/test/test_utils.jl +++ b/test/test_utils.jl @@ -52,7 +52,7 @@ function start_opa_server(root_path; change_dir::Bool=true) ) else opa_server = OpenPolicyAgent.Server.MonitoredOPAServer( - CLI.CommandLine(OpenPolicyAgent_jll.opa), + OpenPolicyAgent_jll.opa, joinpath(root_path, "config.yaml"); stdout = joinpath(root_path, "server.stdout"), stderr = joinpath(root_path, "server.stderr"), From 353558cbfb6a312f0d8ccd65b1d5d5ffb8c43198 Mon Sep 17 00:00:00 2001 From: Tanmay Mohapatra Date: Tue, 29 Oct 2024 07:03:16 +0530 Subject: [PATCH 6/6] Update src/server/server.jl Co-authored-by: Morten Piibeleht --- src/server/server.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/server.jl b/src/server/server.jl index fac3a09..413b9f9 100644 --- a/src/server/server.jl +++ b/src/server/server.jl @@ -19,7 +19,7 @@ const DEFAULT_PORT = 8181 A server that is monitored and restarted if it dies. Arguments: -- `cmdline`: The `CLI.CommandLine` instrance that wraps an opa executable. +- `cmdline`: The `CLI.CommandLine` instance that wraps an opa executable. - `configfile`: The path to the OPA configuration file. Keyword arguments: