Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/discovery: ensure discovery doesn't erase its own config #6070

Conversation

blacksails
Copy link
Contributor

@blacksails blacksails commented Jun 30, 2023

When the discovery plugin receives a a discovery bundle which omits the
discovery configuration, it deletes its own configuration from the
manager. In turn this means that GET /v1/config doesn't show the
configuration of the discovery plugin.

This change ensures that the plugin will never overwrite the discovery
configuration on the manager.

Signed-off-by: Benjamin Nørgaard mail@blacksails.dev

@blacksails blacksails marked this pull request as ready for review June 30, 2023 12:51
@blacksails blacksails force-pushed the ensure-discovery-config-remains branch from aeb98ee to 02aff38 Compare June 30, 2023 12:55
@blacksails
Copy link
Contributor Author

fixes #6046

@ashutosh-narkar
Copy link
Member

@blacksails the changes look fine. Can you please fix the broken tests. Thanks.

@charlieegan3
Copy link
Contributor

(I think this is all you need)

diff --git a/sdk/opa_test.go b/sdk/opa_test.go
index 5fbe773c0..63e89bc76 100644
--- a/sdk/opa_test.go
+++ b/sdk/opa_test.go
@@ -161,7 +161,8 @@ func TestHookOnConfigDiscovery(t *testing.T) {
                        "foo":     "baz",
                        "fox":     "quz",
                },
-               Plugins: map[string]json.RawMessage{"test_plugin": json.RawMessage("{}")},
+               Plugins:   map[string]json.RawMessage{"test_plugin": json.RawMessage("{}")},
+               Discovery: json.RawMessage(`{"service":"disco", "resource": "disco.tar.gz"}`),
        }
        act := th1.c // doesn't matter which hook, they only mutate the config via its pointer
        if diff := cmp.Diff(exp, act, cmpopts.IgnoreFields(config.Config{}, "DefaultDecision", "DefaultAuthorizationDecision")); diff != "" {

When the discovery plugin receives a a discovery bundle which omits the
discovery configuration, it deletes its own configuration from the
manager. In turn this means that `GET /v1/config` doesn't show the
configuration of the discovery plugin.

This change ensures that the plugin will never overwrite the discovery
configuration on the manager.

Signed-off-by: Benjamin Nørgaard <mail@blacksails.dev>
@blacksails blacksails force-pushed the ensure-discovery-config-remains branch from 19f39c8 to 8f55f40 Compare July 6, 2023 13:50
@netlify
Copy link

netlify bot commented Jul 6, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 19f39c8
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/64a6c69450491c0008df0642
😎 Deploy Preview https://deploy-preview-6070--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@blacksails
Copy link
Contributor Author

blacksails commented Jul 6, 2023

Sorry about the delay. Fixed test and rebased.

Copy link
Contributor

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

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

This looks good to me 🙂. I'll let Ash have a final check before we merge. Thanks for working on it!

Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

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

LGTM

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.

None yet

3 participants