Open martin-redmaple opened 2 months ago
I could have a look.
I checked a bit the codebase and it seems that the issues traces to the case-insensitivity
from golang's encoding/json
. The encoding/json
will unmarshal both schedule
and schedUle
and therefore the argo lint
command will not complain.
We could use a json package from kubernetes-sig
project , which allows unmarshaling
with case-sensitive
field tags. That will work only on the strict mode and the spec.schedUle
will be reported as an unknown field. On non-strict it will not be reported, cause of the unknown field opt not enabled.
However since the jsonpkg
is coming from argoproj/pkg
it will always accept something like schedUle
when you submit the wf. And finally another option would be to develop a checker for the keys against the schema which will be a bit more complicated approach.
edit: argo lint
is by default running on strict mode
We could use a json package from
kubernetes-sig
project , which allowsunmarshaling
withcase-sensitive
field tags.
This seems to be directly available as json.Unmarshal
in the apimachinery
package: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/json#Unmarshal. We could use that instead of encoding/json
.
However since the
jsonpkg
is coming fromargoproj/pkg
In which part of the code? Both encoding/json
and argoproj/pkg/json
are imported in a lot of places 😅
But I imagine we can similarly just substitute in the apimachinery
package. Could potentially even add an additional wrapper method to argoproj/pkg
if needed.
In which part of the code? Both encoding/json and argoproj/pkg/json are imported in a lot of places 😅
Regarding, argo lint
is on the ParseObjects
from common/parse.go
, which calls the toWorkflowTypeJSON
. I will try to prepare an MR where we use the Unmarshal
fromapimachinery
Regarding,
argo lint
is on theParseObjects
fromcommon/parse.go
, which calls thetoWorkflowTypeJSON
.
Mmm this line only affects JSON structured inputs though, while most users and OP use YAML
Sorry my bad I was referring a bit further down where it calls the 'toWorkflowTypeYAML' which invokes the 'toWorkflowTypeJSON'. And in there you can find the jsonpkg calls as well.
Pre-requisites
:latest
image tag (i.e.quay.io/argoproj/workflow-controller:latest
) and can confirm the issue still exists on:latest
. If not, I have explained why, in detail, in my description below.What happened/what did you expect to happen?
When attempting to lint a
CronWorkflow
definition file,argo lint
does not detect keys with incorrect capitalisation. If these are applied usingkubectl
, then the cron workflow does not work as expected. Usingargo cron create
works, as this tool appears to correct the capitalisation.See example below, with upper case
U
inschedUle
. I would expectargo lint
to produce an error. Instead it produces the following:Version
v3.5.6
Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.
Logs from the workflow controller
Logs from in your workflow's wait container