Repository navigation
refactor: adopt cinc-api search and node helpers - #263
Merged
Merged
Conversation
Point cinc-api at the local combined branch so the CLI can adopt its new search, node and run-list helpers before they are released. That branch also changes Policies.PushRevision to return a PushResult, so policy push now reads the revision from it; adopting the rest of PushResult is left to the change that owns policy push. Drop the replace directive once cinc-api is tagged. Signed-off-by: Tim Smith <tsmith84@proton.me>
…son too
cinc-api now owns the search wire details: UnwrapSearchRow strips the
partial-search {url, data} envelope and the Chef::DataBagItem wrapper a
full data bag search returns, WithPartialPaths builds the -a projection,
and SearchResult, DataBagItem.Content and Node.AttributeString replace
the CLI's copies. searchResult, partialProjection, unwrapDataBagItem and
the explore view's hand-rolled envelope check are gone.
--format json now emits the unwrapped rows as well. The table already
showed the objects, while the JSON showed the envelopes, so a script
had to know which of two wire shapes each index returns and dig through
"data" or "raw_data" itself. It is also the knife-compatible choice:
Chef's search client hands partial rows back as the projected data,
never the url/data envelope, and search(:bag) yields data bag items, not
their wrappers. total, start and rows keep their shape.
The node table's PLATFORM column now reads platform with Chef attribute
precedence rather than from automatic alone, matching node show.
Signed-off-by: Tim Smith <tsmith84@proton.me>
node ssh and node status decoded search rows themselves, and status did it with its own attribute walker that swallowed decode errors, so a row that wasn't a node became a blank line. Both now iterate cinc-api's Search.Nodes and fail on a row that doesn't decode. status reads the check-in with Node.LastCheckin (keeping fractional ohai_time) and its host facts with Node.AttributeString, so an fqdn or platform set outside automatic shows the way node[...] would read it. lookupAttribute and attributeString are gone. A node missing the --attribute host now names the node and suggests --attribute, instead of "search row missing SSH attribute". node show reads the environment with Node.EnvironmentName. Signed-off-by: Tim Smith <tsmith84@proton.me>
…g changed
run-list, tag, environment-set, policy-set and the node edit form each
fetched the node, changed it, patched up a nil run list and PUT it back,
even when the change left the node as it was, and then reported the copy
they had sent. They now go through cinc-api's Nodes.Modify, which skips
the PUT when the node's JSON is unchanged. A no-op says so ("Node "web01"
already has that run list, so there's nothing to change: ..."), and a
real change reports the node the server answered with.
Run-list entries now follow the Chef Server's normalization: a bare
"nginx" is recipe[nginx], so add no longer appends "nginx" beside a
stored recipe[nginx], remove "nginx" drops recipe[nginx], and set stores
qualified entries.
The run-list and tag sub-groups were two copies of one builder; they are
now one nodeListField table each over a shared builder. tag list and
run-list list print [] rather than null under --format json for a node
with none. gatherCSVArgs sits beside splitCSV, and the nil run-list
guards in node and role create/edit are gone, since cinc-api always
encodes run_list as an array.
Signed-off-by: Tim Smith <tsmith84@proton.me>
Signed-off-by: Tim Smith <tsmith84@proton.me>
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.
Second of four cinc-api v0.15.0 adoption PRs. The search envelopes and node read-modify-write logic now live in the library.
Search
searchResult,partialProjection,unwrapDataBagItem, and thepartialflag threaded through the rendering are gone. Search usescinc.SearchResult,WithPartialPaths(always projectingnameandid),UnwrapSearchRow,DataBagItem.Content(), andNode.AttributeStringfor the platform column.searchRowIdentityshrinks to a few lines onUnwrapSearchRow.--format jsonnow emits the unwrapped objects the table shows, which is what knife does. A partial row is its projected data, and a data bag search yields the items rather thanChef::DataBagItemenvelopes. Thetotal/start/rowsshape is unchanged.Nodes
node sshandnode statususeSearch.Nodes.statususesNode.LastCheckin, and a row that isn't a node now fails the command instead of silently printing a blank line. The hand-written attribute walkers are deleted.run-list,tag,environment-set,policy-setand thenode editform go throughNodes.Modify. An edit that changes nothing sends no PUT and says so. After a real change, the output shows the node the server returned, not the local copy.remove nginxdrops a storedrecipe[nginx], andadd nginxdoesn't duplicate it.tag list --format jsonprints[]rather thannullfor a node with no tags.Test plan
go test ./apps/... ./cli/explore/ ./cli/client/,go vet ./...,gofmtmake test-integration(cinc-server-ng): pass. The cases that dug into.dataorraw_dataare updated for the unwrapped JSON.