bug: create ApisixRoute failed by k8s dynamic client-go
Current Behavior
func buildK8sApisixRoute(name, namespace string, port int32) *apisixv2.ApisixRoute {
return &apisixv2.ApisixRoute{
TypeMeta: metav1.TypeMeta{
APIVersion: "apisix.apache.org/v2",
Kind: "ApisixRoute",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: apisixv2.ApisixRouteSpec{
HTTP: []apisixv2.ApisixRouteHTTP{
{
Name: name,
Match: apisixv2.ApisixRouteHTTPMatch{
Hosts: []string{"xxx"},
Paths: []string{"/*"},
},
Backends: []apisixv2.ApisixRouteHTTPBackend{
{
ServiceName: name,
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: port,
},
},
},
},
},
},
}
}
Expected Behavior
success
Error Logs
ApisixRoute.apisix.apache.org "demo" is invalid: spec.http[0].authentication.type: Unsupported value: "": supported values: "basicAuth", "keyAuth", "jwtAuth", "wolfRBAC", "hmacAuth", "ldapAuth"
Steps to Reproduce
- create apisixroutes cr
- failed
Environment
- APISIX Ingress controller version (run
apisix-ingress-controller version --long) - Kubernetes cluster version (run
kubectl version) - OS version if running APISIX Ingress controller in a bare-metal environment (run
uname -a)
if wrote:
func buildK8sApisixRoute(name, namespace string, port int32) *apisixv2.ApisixRoute {
return &apisixv2.ApisixRoute{
TypeMeta: metav1.TypeMeta{
APIVersion: "apisix.apache.org/v2",
Kind: "ApisixRoute",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: apisixv2.ApisixRouteSpec{
HTTP: []apisixv2.ApisixRouteHTTP{
{
Name: name,
Match: apisixv2.ApisixRouteHTTPMatch{
Hosts: []string{"xxx"},
Paths: []string{"/*"},
},
Backends: []apisixv2.ApisixRouteHTTPBackend{
{
ServiceName: name,
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: port,
},
},
},
Authentication: apisixv2.ApisixRouteAuthentication{
Enable: false,
Type: "basicAuth",
},
},
},
},
}
}
will success.
the following code is necessary, but useless, if we should use pointers to avoid mandatory parameters?
Authentication: apisixv2.ApisixRouteAuthentication{
Enable: false,
Type: "basicAuth",
}
There's a lot more of these that have omitempty but can can't marshall from Go as nil values. Would suggest we fix these in a big swoop (being mindful of possible NPE) since it breaks other library API consumers.
@acuteaura I think the change is meaningful enough that we can introduce it even if it is breaking. Replacing these fields as pointers looks good to me. The consumers should be able to upgrade to newer version with code changes. @AlinsRan What do you think?
This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
@Revolyssup removing the stale label. Please check and triage.
This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.