Cargo Features

[dependencies]
kubewarden-policy-sdk = { version = "0.11.2", default-features = false, features = ["cluster-context"] }
default = cluster-context

The cluster-context feature is set by default whenever kubewarden-policy-sdk is added without default-features = false somewhere in the dependency tree.

cluster-context default = k8s-openapi

Affects host_capabilities::kubernetes, kubewarden-policy-sdk::mutate_pod_spec_from_request

Features from optional dependencies

In crates that don't use the dep: syntax, optional dependencies automatically become Cargo features. These features may have been created by mistake, and this functionality may be removed in the future.

k8s-openapi cluster-context

Enables k8s-openapi

Starting from k8s-openapi v0.14, it is NOT recommended to be explicit about the kubernetes features to be used when building a library. That's because the final version of the k8s API to be supported must be made by the consumer of the library.

Otherwise it's possible to end up in situations like:

  • kubewarden-policy-sdk enables the v1_22 feature of k8s-openapi
  • consumer-foo requires k8s-openapi too but enables the v1_23 feature A build error is then raised by cargo because the same version must be picked by all the crates making use of k8s-openapi.

Because of that, no feature is chosen inside of the dependencies section. This however can lead to issues when executing commands like cargo build|check|doc. That's because the k8s-openapi is specified again inside of the dev-dependencies, this time with a k8s feature enabled