Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Support JSON manifest files #2755

Closed
bricef opened this issue Jan 16, 2020 · 9 comments
Closed

Support JSON manifest files #2755

bricef opened this issue Jan 16, 2020 · 9 comments

Comments

@bricef
Copy link
Contributor

bricef commented Jan 16, 2020

Describe the bug
When deciding what files to pass to kubectl, flux ignores .json files in its target repository/branch/path.

To Reproduce
Set up a cluster with flux. Add a valid namespace manifest file such as the one below to the target git repo/branch/path and name it *.json

{
  "apiVersion": "v1",
  "kind": "Namespace",
  "metadata": {
    "namespace": "test-namespace"
  }
}

Expected behavior
Flux should pick up this file and apply it to the cluster under management.

What actually happens
Flux notices that the git repo has changed, and re-runs kubectl, but omits the JSON file from the things it passes to kubectl's stdin.

Additional notes
.yaml, .yml and .json files are all accepted by kubectl, and flux should mirror this behaviour.

@bricef bricef added blocked-needs-validation Issue is waiting to be validated before we can proceed bug labels Jan 16, 2020
@2opremio
Copy link
Contributor

Flux doesn't support json, just yaml files.

@2opremio 2opremio changed the title Flux does incorrectly ignores valid json manifests Support JSON manifest files Jan 16, 2020
@2opremio 2opremio added enhancement help wanted and removed blocked-needs-validation Issue is waiting to be validated before we can proceed bug labels Jan 16, 2020
@bricef
Copy link
Contributor Author

bricef commented Jan 16, 2020

@2opremio I noticed :) Is there any underlying reason why that is?

@stefanprodan
Copy link
Member

@bricef Flux needs to parse and modify Kubernetes manifests, for this reason only YAML is supported as the patching is done with a library specialised in YAML only.
Ref:

@2opremio
Copy link
Contributor

2opremio commented Jan 16, 2020

Ah, I mentioned it since you opened a bug and not a feature request.

Legacy reasons. There isn't enough explicit community demand either (or they silently accept the status quo). It comes up from time to time but not enough to justify the effort, given the constrained manpower.

@2opremio
Copy link
Contributor

2opremio commented Jan 16, 2020

Well, we maintain kubeyaml because we want to preserve comments, see #2660 . JSON doesn't have that problem, making things easier.

I guess that's the reason why the community prefers YAMLs too.

@bricef
Copy link
Contributor Author

bricef commented Jan 16, 2020

@stefanprodan Valid JSON is also valid YAML, and can be parsed as such since YAML is a JSON superset. Kubeyaml should work with json files without issue. In fact, I just tried the underlying ruamel.yaml library with JSON and it works fine:

>>> from ruamel.yaml import YAML
>>> yaml=YAML()
>>> json="""
... {"menu": {
...   "id": "file",
...   "value": "File",
...   "popup": {
...     "menuitem": [
...       {"value": "New", "onclick": "CreateNewDoc()"},
...       {"value": "Open", "onclick": "OpenDoc()"},
...       {"value": "Close", "onclick": "CloseDoc()"}
...     ]
...   }
... }}
... """
>>> yaml.load(json)
ordereddict([('menu', ordereddict([('id', 'file'), ('value', 'File'), ('popup', ordereddict([('menuitem', [ordereddict([('value', 'New'), ('onclick', 'CreateNewDoc()')]), ordereddict([('value', 'Open'), ('onclick', 'OpenDoc()')]), ordereddict([('value', 'Close'), ('onclick', 'CloseDoc()')])])]))]))])
>>>

This is a false limitation and should be fixed :)

@2opremio
Copy link
Contributor

2opremio commented Jan 16, 2020

This is a false limitation and should be fixed :)

Should is subjective, but I will happily accept a PR.

@squaremo
Copy link
Member

squaremo commented Feb 6, 2020

I'm not sure I would trust ruamel to output valid JSON given a JSON input. JSON-is-YAML works in your favour for the input, but not the output.

@kingdonb
Copy link
Member

Flux v1 is in maintenance mode now, and is not adding any new features unless they are critical.

As Flux contrib efforts have been focused on Flux v2, the Flux project has moved to a new repo, fluxcd/flux2

In the interest of reducing the number of open issues not directly related to supporting Flux v1 in maintenance mode, and respecting you may have moved on already, I will go ahead and close out this issue for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants