TykTechnologies / tyk-operator

Tyk Operator for Kubernetes
https://tyk.io
Mozilla Public License 2.0
197 stars 38 forks source link

`use_go_plugin_auth` causes a validation error when missing #499

Closed patriziobrunops closed 2 years ago

patriziobrunops commented 2 years ago

Ever since I upgraded to latest tyk-operator I've been unable to create/udpate api definitions that don't have use_go_plugin_auth or when it is set to false.

Expected Behavior

When use_go_plugin_auth is not set, should default to false

Current Behavior

When use_go_plugin_auth is not set:

error: error validating "dev-config.yaml": error validating data: ValidationError(ApiDefinition.spec): missing required field "use_go_plugin_auth" in io.tyk.tyk.v1alpha1.ApiDefinition.spec; if you choose to ignore these errors, turn validation off with --validate=false

When use_go_plugin_auth is set to false

The ApiDefinition "remote-payments-receipts-config" is invalid: spec.use_go_plugin_auth: Required value

Possible Solution

Remove omitempty from UseGoPluginAuth. Remove use_go_plugin_auth from required ApiDefinition.spec properties in crds.yaml.

Steps to Reproduce

1. 2. 3.

Screenshots/Video

Logs/Errors

Context

Your Environment

buraksekili commented 2 years ago

Hi @patriziobrunops - thank you for informing us.

This issue should be fixed with #500

patriziobrunops commented 2 years ago

Hi @patriziobrunops - thank you for informing us.

This issue should be fixed with #500

Hi @buraksekili - #500 fixes the manifest validation error, but if you set use_go_plugin_auth to false you'll get a failure from the Dashboard API, because of omitempty.

buraksekili commented 2 years ago

@patriziobrunops I tried to reproduce the following error:

The ApiDefinition "remote-payments-receipts-config" is invalid: spec.use_go_plugin_auth: Required value

Correct me if I am wrong but this error does not belong to Dashboard API but belongs to validation webhooks. This error happens because the required field spec.use_go_plugin_auth has omitempty tag. Even though CRD expects this field to present, if it is set as false, which is the nil value for boolean, your YAML file won't be validated because of omitempty tag.

So, as in #500, if CRD does not require users to provide the use_go_plugin_auth field, you can either set use_go_plugin_auth to false or not set it at all.

If you have access to the repository, you can try this approach.

This command will update Tyk CRDs and since use_go_plugin_auth is deleted from the required field, you are not required to provide it, or setting it to false won't cause any problems.

Please let me know if I wasn't clear or if you have further questions.