Repository navigation
api/instances: An empty list of SSH keys on creation means no key - #138
Merged
Merged
Conversation
An instance created with sshPublicKeys: [] now has the empty list written on its object, so it has none of its profile's keys; an absent field is still left out and the profile's keys apply. Say what the three cases mean in the OpenAPI and the reference page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Since phorge-fr/Hangar#434 an instance that does not say its SSH keys takes its profile's, and an instance that says
sshPublicKeys: []has none. The store wrotesshPublicKeyson creation only when the list was not empty, so[]was dropped and an instance could not opt out of its profile's keys.PATCHalready wrote[].On
POST /v1/tenants/{t}/instances:sshPublicKeysabsent ornullsshPublicKeys: []sshPublicKeys: []sshPublicKeys: [...]Go's
encoding/jsondecodes an absent field ornullinto a nil[]stringand[]into a non-nil empty one, and the strict decoder of the API (DisallowUnknownFields) does not change that, so the fix is!= nilininternal/kube/compute.goinstead oflen() > 0. No change to the request type's shape or to validation.The body of the answer is unchanged: the API still reads the keys from
spec, thenstatus, then none, and an empty list inspecis read as "no key" and does not fall through to thestatus. The body always has a list.The OpenAPI (
sshPublicKeysof the creation and of thePATCH) anddocs/reference/images-and-instances.mdsay what each case means.Console
Not changed here, it is another issue. Note that a client that always sends
sshPublicKeys: []now overrides the keys of every profile: it must send the field only when the person typed keys.Tests
internal/kube: creation with absent,[]and keys against the fake dynamic client (field left out, written empty, written), and the answer of an instance created with[]whosestatuscarries keys stays empty. These fail without the fix (checked by reverting the store change).internal/api: the route with the field absent,null,[]and keys, what reaches the store (nil, nil, empty, list) and that the body always has a list.PATCHtests are unchanged and pass.gofmt -l,go vet ./...andgo test -race ./...are clean locally.golangci-lintis not installed locally, CI runs it.Closes #133