Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): subject condition set CLI CRUD #78

Merged
merged 6 commits into from
Mar 28, 2024
Merged

Conversation

jakedoublev
Copy link
Contributor

@jakedoublev jakedoublev commented Mar 26, 2024

Adds CRUD for subject condition sets, with the JSON relation of []*policy.SubjectSets passed via a string flag or found in a .json file with the filepath/name provided in a flag on CREATE, and validation that only one is provided at once. On UPDATE, only a JSON string is allowed.

There is an open pflags issue (since 2022) which is the library under Cobra's flags implementation which affects the Subject Condition Sets (SCSs) flag API: spf13/pflag#370.

Unfortunately, this issue means we cannot allow a slice of individual SCSs passed via CLI as we do with --label where each individual label passed with --label populates a []string of all labels. In this case, if we attempt --subject-set <single subject set json> to populate a []string where each index is a JSON string for a single SCS, we get an error flag: parse error on line 1, column 3: bare " in non-quoted-field. Because of this, we must expect all SCSs being created via JSON in the CLI to already be joined into the single array and passed as a single string flag --subject-sets <json array of all subject sets in the SCS>.

There is already support added in this PR for reading from a JSON file to create the SCS, and any time there is JSON in the CLI it is likely it will be added via script instead of manually.

See new issue around admin UX of testing Subject Condition Sets before creating.

Note

This PR was going to introduce reading Subject Sets from a YAML file as well, but yaml struct tags are not generated in the proto-built types. If this is needed, it should be discussed further and separately how the platform could expose YAML tags so consumers do not reimplement them repeatedly and potentially mistakenly. Perhaps a new proto plugin could be utilized.

@jakedoublev jakedoublev marked this pull request as ready for review March 26, 2024 16:03
@jakedoublev
Copy link
Contributor Author

See demo in: #79 (comment)

@jrschumacher jrschumacher merged commit 26f6fcc into main Mar 28, 2024
5 checks passed
@jrschumacher jrschumacher deleted the feat/scs-crud branch March 28, 2024 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow creation of Subject Condition Set during simultaneous creation of Subject Mapping
2 participants