Skip to content

hcloud context: add JSON output #1347

@martinvonwittich

Description

@martinvonwittich

TL;DR

I want to iterate over all contexts I have set up in hcloud. Unfortunately hcloud context list does not support JSON output:

server ~ # hcloud context list -o json
hcloud: invalid output option: json

So in the past I improvised by parsing the normal output:

server ~ # hcloud context list --output noheader -o columns=name | head -n1
Hosting             

This worked fine in hcloud 1.43:

server ~ # hcloud-1.43.1 context list --output noheader -o columns=name | head -n1 | cat -A
Hosting$

But with hcloud 1.61 the output is now padded with spaces, which broke my parsing:

server ~ # hcloud-1.61.0 context list --output noheader -o columns=name | head -n1 | cat -A 
Hosting             $

I think JSON output would be the sensible solution here.

Expected behavior

I want cleanly parseable output that doesn't break when the human-readable output format is changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions