Skip to content

Commit

Permalink
Update run and start to mount the policy store
Browse files Browse the repository at this point in the history
  • Loading branch information
carabasdaniel committed Apr 19, 2023
1 parent 401ff53 commit d06b02c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/aserto-dev/header v0.0.5
github.com/aserto-dev/logger v0.0.3
github.com/aserto-dev/openapi-authorizer v0.8.81
github.com/aserto-dev/runtime v0.51.1-0.20230418214425-ec2f9580583a
github.com/aserto-dev/runtime v0.51.1
github.com/fatih/color v1.14.1
github.com/fullstorydev/grpcurl v1.8.7
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/aserto-dev/logger v0.0.3 h1:lBB5LMdOsHCJKfEej2xY7s4OzCWUWCBhkhUU6RJ4L
github.com/aserto-dev/logger v0.0.3/go.mod h1:8HIZAwlf+Y0V33YnGILYZOtYh1Eue5mz1YNf1XbqPbI=
github.com/aserto-dev/openapi-authorizer v0.8.81 h1:YDxVLBssBvj71/ecgLFuvC7dkOQu5Jl/A92wA58CcX0=
github.com/aserto-dev/openapi-authorizer v0.8.81/go.mod h1:3kmTs3pjNE5aQXt1Ob71uVdqC2qC61EO9gl6O63md4U=
github.com/aserto-dev/runtime v0.51.1-0.20230418214425-ec2f9580583a h1:ELg5DgLq3+m/bcSP53HCrPaNAgenW/U+JThYo4W1ec0=
github.com/aserto-dev/runtime v0.51.1-0.20230418214425-ec2f9580583a/go.mod h1:j2RGQkslP9gsvjhaAhEekMpnMJvvlhy7YhYDK0ZagFk=
github.com/aserto-dev/runtime v0.51.1 h1:NpX0PoKtQFl2vutcfH5u0eAfIECRs01FeUhiqS0cmk4=
github.com/aserto-dev/runtime v0.51.1/go.mod h1:j2RGQkslP9gsvjhaAhEekMpnMJvvlhy7YhYDK0ZagFk=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ github.com/aserto-dev/runtime v0.47.3 h1:KEXQ5bFImIWAqUM5uIPDQ94zeHYScalhWziu+GA
github.com/aserto-dev/runtime v0.47.3/go.mod h1:0iis95JxPIOPQvdmS0+zJnhCPLrz3bkinFNzDtbwuak=
github.com/aserto-dev/runtime v0.51.0 h1:bJPCP5v0nY1NS1t4q3+1TSf6WA+wQorTXRiD8UQP+QY=
github.com/aserto-dev/runtime v0.51.0/go.mod h1:j2RGQkslP9gsvjhaAhEekMpnMJvvlhy7YhYDK0ZagFk=
github.com/aserto-dev/runtime v0.51.1 h1:NpX0PoKtQFl2vutcfH5u0eAfIECRs01FeUhiqS0cmk4=
github.com/aserto-dev/runtime v0.51.1/go.mod h1:j2RGQkslP9gsvjhaAhEekMpnMJvvlhy7YhYDK0ZagFk=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down
9 changes: 9 additions & 0 deletions pkg/cli/cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"fmt"
"os"

"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/aserto-dev/topaz/pkg/cli/dockerx"

Expand Down Expand Up @@ -46,6 +49,12 @@ func (cmd *RunCmd) Run(c *cc.CommonCtx) error {
func (cmd *RunCmd) dockerArgs() []string {
args := append([]string{}, dockerCmd...)
args = append(args, "-ti")

policyRoot := os.Getenv("POLICY_FILE_STORE_ROOT ")
if policyRoot == "" {
policyRoot = dockerx.DefaultPolicyRoot
}
dockerArgs = append(dockerArgs, "-v", fmt.Sprintf("%s:/root/.policy:ro", policyRoot))
args = append(args, dockerArgs...)

for _, env := range cmd.Env {
Expand Down
8 changes: 7 additions & 1 deletion pkg/cli/cmd/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"os"
"path"

Expand Down Expand Up @@ -75,7 +76,6 @@ var (
"-v", "$TOPAZ_CERTS_DIR/certs:/certs:rw",
"-v", "$TOPAZ_CFG_DIR/cfg:/config:ro",
"-v", "$TOPAZ_EDS_DIR/db:/db:rw",
"-v", "$HOME/.policy:/root/.policy:ro",
}

daemonArgs = []string{
Expand All @@ -97,6 +97,12 @@ var (

func (cmd *StartCmd) dockerArgs() []string {
args := append([]string{}, dockerCmd...)

policyRoot := os.Getenv("POLICY_FILE_STORE_ROOT ")
if policyRoot == "" {
policyRoot = dockerx.DefaultPolicyRoot
}
dockerArgs = append(dockerArgs, "-v", fmt.Sprintf("%s:/root/.policy:ro", policyRoot))
args = append(args, dockerArgs...)
args = append(args, daemonArgs...)

Expand Down
1 change: 1 addition & 0 deletions pkg/cli/dockerx/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
const (
Topaz = "topaz"
DefaultConfigRoot = ".config/topaz"
DefaultPolicyRoot = "$HOME/.policy"
)

var (
Expand Down

0 comments on commit d06b02c

Please sign in to comment.