k8snetworkplumbingwg / net-attach-def-admission-controller

An admission controller to check resources as defined by the NPWG spec
Apache License 2.0
4 stars 15 forks source link

Valid config that omits the 'name' field is rejected #73

Open tjohnes opened 3 months ago

tjohnes commented 3 months ago

Per the multi-network CRD spec, if spec.config is valid but omits the name field, then the NPWG implementation adds a name field containing the NAD name (section 3.4.2).

preprocessCNIConfig attempts to mirror this behavior, but it only adds the name if there is an error unmarshalling the config:

    if err := json.Unmarshal(config, &c); err != nil {
        if n, ok := c["name"]; !ok || n == "" {
            c["name"] = name
        }
    }

This means valid config that omits the name field is rejected by the webhook.