linkerd2/testutil
Eliza Weisman f6c6ff965c
inject: fix --default-inbound-policy not setting annotation (#9197)
Depends on #9195

Currently, `linkerd inject --default-inbound-policy` does not set the
`config.linkerd.io/default-inbound-policy` annotation on the injected
resource(s).

The `inject` command does _try_ to set that annotation if it's set in
the `Values` generated by `proxyFlagSet`:
14d1dbb3b7/cli/cmd/inject.go (L485-L487)

...but, the flag in the proxy `FlagSet` doesn't set
`Values.Proxy.DefaultInboundPolicy`, it sets
`Values.PolicyController.DefaultAllowPolicy`:
7c5e3aaf40/cli/cmd/options.go (L375-L379)

This is because the flag set is shared across `linkerd inject` and
`linkerd install` subcommands, and in `linkerd install`, we want to set
the default policy for the whole cluster by configuring the policy
controller. In `linkerd inject`, though, we want to add the annotation
to the injected pods only.

This branch fixes this issue by changing the flag so that it sets the
`Values.Proxy.DefaultInboundPolicy` instead of the
`Values.PolicyController.DefaultAllowPolicy` value. In `linkerd
install`, we then set `Values.PolicyController.DefaultAllowPolicy` based
on the value of `Values.Proxy.DefaultInboundPolicy`, while in `inject`,
we will now actually add the annotation.

This branch is based on PR #9195, which adds validation to reject
invalid values for `--default-inbound-policy`, rather than on `main`.
This is because the validation code added in that PR had to be moved
around a bit, since it now needs to validate the
`Values.Proxy.DefaultInboundPolicy` value rather than the
`Values.PolicyController.DefaultAllowPolicy` value. I thought using
#9195 as a base branch was better than basing this on `main` and then
having to resolve merge conflicts later. When that PR merges, this can 
be rebased onto `main`.

Fixes #9168
2022-08-18 17:16:27 -07:00
..
prommatch Use prommatch everywhere (#8674) 2022-06-21 21:48:51 -06:00
annotations.go Spelling (#6215) 2021-06-07 15:16:59 -06:00
annotations_test.go Spelling (#6215) 2021-06-07 15:16:59 -06:00
doc.go Introduce script to test multiple cloud providers (#2592) 2019-03-29 16:22:30 -07:00
inject.go Enable gocritic linting (#7906) 2022-02-17 22:45:25 +00:00
inject_validator.go inject: add `config.linkerd.io/shutdown-grace-period` annotation (#8923) 2022-07-19 14:43:38 -07:00
install.go go: Enable `errorlint` checking (#7885) 2022-02-16 18:32:19 -07:00
kubernetes_helper.go ci: Unify integration test workflows (#8964) 2022-07-25 15:51:09 -07:00
stream.go Replace time.After with time.NewTimer to avoid memory leaks (#7956) 2022-02-24 15:34:52 -08:00
tap.go viz: move sub-cmds using viz extension under viz cmd (#5485) 2021-01-13 12:11:25 +05:30
test_data_diff.go test: Diff structured YAML when possible (#8432) 2022-05-10 08:40:29 -07:00
test_helper.go inject: fix --default-inbound-policy not setting annotation (#9197) 2022-08-18 17:16:27 -07:00