Skip to content

Commit 797e8ac

Browse files
committed
chore: update variable names
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 2b58f31 commit 797e8ac

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ jobs:
116116
- name: Set Rego file path
117117
run: echo "REGO_FILE_PATH=${{ github.workspace }}/sample.rego" >> $GITHUB_ENV
118118
- name: Start finch-daemon with opa Authz
119-
run: sudo bin/finch-daemon --debug --enable-opa --rego-file ${{ github.workspace }}/sample.rego --socket-owner $UID &
119+
run: sudo bin/finch-daemon --debug --enable-middleware --rego-file ${{ github.workspace }}/sample.rego --socket-owner $UID &
120120
- name: Run opa e2e tests
121121
run: sudo -E make test-e2e-opa

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ test-e2e: linux
118118
test-e2e-opa: linux
119119
DOCKER_HOST="unix:///run/finch.sock" \
120120
DOCKER_API_VERSION="v1.43" \
121-
OPA_E2E=1 \
121+
MIDDLEWARE_E2E=1 \
122122
TEST_E2E=1 \
123123
$(GINKGO) $(GFLAGS) ./e2e/...
124124

cmd/finch-daemon/main.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ const (
4343
)
4444

4545
type DaemonOptions struct {
46-
debug bool
47-
socketAddr string
48-
socketOwner int
49-
debugAddress string
50-
configPath string
51-
pidFile string
52-
regoFilePath string
53-
enableOpa bool
54-
regoFileLock *flock.Flock
46+
debug bool
47+
socketAddr string
48+
socketOwner int
49+
debugAddress string
50+
configPath string
51+
pidFile string
52+
regoFilePath string
53+
enableMiddleware bool
54+
regoFileLock *flock.Flock
5555
}
5656

5757
var options = new(DaemonOptions)
@@ -71,7 +71,7 @@ func main() {
7171
rootCmd.Flags().StringVar(&options.configPath, "config-file", defaultConfigPath, "Daemon Config Path")
7272
rootCmd.Flags().StringVar(&options.pidFile, "pidfile", defaultPidFile, "pid file location")
7373
rootCmd.Flags().StringVar(&options.regoFilePath, "rego-file", "", "Rego Policy Path")
74-
rootCmd.Flags().BoolVar(&options.enableOpa, "enable-opa", false, "turn on opa allowlisting")
74+
rootCmd.Flags().BoolVar(&options.enableMiddleware, "enable-middleware", false, "turn on middleware for allowlisting")
7575
if err := rootCmd.Execute(); err != nil {
7676
log.Printf("got error: %v", err)
7777
log.Fatal(err)
@@ -236,7 +236,7 @@ func newRouter(options *DaemonOptions, logger *flog.Logrus) (http.Handler, error
236236
}
237237

238238
var regoFilePath string
239-
if options.enableOpa {
239+
if options.enableMiddleware {
240240
regoFilePath, err = sanitizeRegoFile(options)
241241
if err != nil {
242242
return nil, err
@@ -319,16 +319,16 @@ func checkRegoFileValidity(filePath string) error {
319319
// and sets rego file to be read-only.
320320
func sanitizeRegoFile(options *DaemonOptions) (string, error) {
321321
if options.regoFilePath != "" {
322-
if !options.enableOpa {
323-
return "", fmt.Errorf("rego file path was provided without the --enable-opa flag, please provide the --enable-opa flag") // todo, can we default to setting this flag ourselves is this better UX?
322+
if !options.enableMiddleware {
323+
return "", fmt.Errorf("rego file path was provided without the --enable-middleware flag, please provide the --enable-middleware flag") // todo, can we default to setting this flag ourselves is this better UX?
324324
}
325325

326326
if err := checkRegoFileValidity(options.regoFilePath); err != nil {
327327
return "", err
328328
}
329329
}
330330

331-
if options.enableOpa && options.regoFilePath == "" {
331+
if options.enableMiddleware && options.regoFilePath == "" {
332332
return "", fmt.Errorf("rego file path not provided, please provide the policy file path using the --rego-file flag")
333333
}
334334

docs/opa-middleware.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Use the [Rego playground](https://play.openpolicyagent.org/) to fine tune your r
3434

3535
## Enable OPA Middleware
3636

37-
Once you are ready with your policy document, use the `--enable-opa` flag to tell the finch-daemon to enable the OPA middleware. The daemon will then look for the policy document provided by the `--rego-file` flag.
37+
Once you are ready with your policy document, use the `--enable-middleware` flag to tell the finch-daemon to enable the OPA middleware. The daemon will then look for the policy document provided by the `--rego-file` flag.
3838

39-
Note: The `--rego-file` flag is required when `--enable-opa` is set.
39+
Note: The `--rego-file` flag is required when `--enable-middleware` is set.
4040

4141
Example:
42-
`sudo bin/finch-daemon --debug --socket-owner $UID --socket-addr /run/finch-test.sock --pidfile /run/finch-test.pid --enable-opa --rego-file /<path-to>/finch-daemon/sample.rego &`
42+
`sudo bin/finch-daemon --debug --socket-owner $UID --socket-addr /run/finch-test.sock --pidfile /run/finch-test.pid --enable-middleware --rego-file /<path-to>/finch-daemon/sample.rego &`

e2e/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ var SubjectPrefix = flag.String("daemon-context-subject-prefix", "", `A string w
2626
var PrefixedSubjectEnv = flag.String("daemon-context-subject-env", "", `Environment to add when running a prefixed subject, in the form of a string like "EXAMPLE=foo EXAMPLE2=bar"`)
2727

2828
func TestRun(t *testing.T) {
29-
if os.Getenv("OPA_E2E") == "1" {
29+
if os.Getenv("MIDDLEWARE_E2E") == "1" {
3030
runOPATests(t)
3131
} else if os.Getenv("TEST_E2E") == "1" {
3232
runE2ETests(t)
3333
} else {
34-
t.Skip("E2E tests skipped. Set TEST_E2E=1 to run regular E2E tests or OPA_E2E=1 to run OPA middleware tests")
34+
t.Skip("E2E tests skipped. Set TEST_E2E=1 to run regular E2E tests or MIDDLEWARE_E2E=1 to run OPA middleware tests")
3535
}
3636

3737
if err := parseTestFlags(); err != nil {

0 commit comments

Comments
 (0)