Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There's a tiny little issue in the current code: since we're unsafely generating the pluralized version (used in internal Kubernetes URLs) to apply manifests, if we get an object like
kind: NetworkPolicy
, we "pluralize" it for the server as"networkpolicy" + "s"
:colony/internal/k8s/k8s.go
Line 97 in 2f990e5
This PR adds a REST unstructured mapper that can map specific objects by asking the Kubernetes API if it knows them.
Today we don't store any
NetworkPolicy
, and fortunately enoughWorkflow
orTemplate
pluralizes in English correctly by addings
at the end, but that might not always be the case especially if this functions makes its way to other parts of our code.The Unit Test includes the happy path (submitting a known resource) and the unhappy path (submitting an unknown resource). The previous error was:
And the new error is (using the example of not finding what a
NetworkPolicy
is:(A bit more verbose but it tells you what action was happening and why it couldn't be applied).
This PR also adds a unit test to pull from the API to ensure the response stays correct, although that could've probably been done in a different PR.
Related Issue(s)
Fixes #
How to test