Skip to content

Commit

Permalink
chore(bors): merge pull request openebs#788
Browse files Browse the repository at this point in the history
788: fix(getNode): return single element in get node r=sinhaashish a=sinhaashish

There was a regression issue in which `kubectl-mayastor get node node-1-155665 -ojson` was returning an array
```
[
  {
    "id": "node-1-155665",
    "spec": {
      "grpcEndpoint": "135.181.42.41:10124",
      "id": "node-1-155665",
      "node_nqn": "nqn.2019-05.io.openebs:node-name:node-1-155665"
    },
    "state": {
      "grpcEndpoint": "135.181.42.41:10124",
      "id": "node-1-155665",
      "status": "Online",
      "node_nqn": "nqn.2019-05.io.openebs:node-name:node-1-155665"
    }
  }
]
```


Earlier in 2.5 release it was returning a single element as below:
```
{
  "id": "node-1-155665",
  "spec": {
    "grpcEndpoint": "135.181.42.41:10124",
    "id": "node-1-155665",
    "node_nqn": "nqn.2019-05.io.openebs:node-name:node-1-155665"
  },
  "state": {
    "grpcEndpoint": "135.181.42.41:10124",
    "id": "node-1-155665",
    "status": "Online",
    "node_nqn": "nqn.2019-05.io.openebs:node-name:node-1-155665"
  }
}
```

This PR fixes that 

Co-authored-by: sinhaashish <ashi.sinha.87@gmail.com>
  • Loading branch information
mayastor-bors and sinhaashish committed Mar 20, 2024
2 parents 919e1a1 + 67531ea commit 4cc26d3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions control-plane/plugin/src/resources/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,17 @@ impl GetWithArgs for Node {
type Args = GetNodeArgs;
async fn get(id: &Self::ID, args: &Self::Args, output: &utils::OutputFormat) -> PluginResult {
match RestClient::client().nodes_api().get_node(id).await {
Ok(node) => {
let node_display =
NodeDisplayLabels::new(node.clone().into_body(), args.show_labels());
match output {
OutputFormat::Yaml | OutputFormat::Json => {
print_table(output, node_display.inner);
}
OutputFormat::None => {
print_table(output, node_display);
}
Ok(node) => match output {
OutputFormat::Yaml | OutputFormat::Json => {
print_table(output, node.clone().into_body());
}
}
OutputFormat::None => {
print_table(
output,
NodeDisplayLabels::new(node.into_body(), args.show_labels()),
);
}
},
Err(e) => {
return Err(Error::GetNodeError {
id: id.to_string(),
Expand Down

0 comments on commit 4cc26d3

Please sign in to comment.