#Viper, getting keys

11 messages · Page 1 of 1 (latest)

hexed valley
#

Heyo, so i have a config.json file looking like this

{
    "clouds": {    
        "gcp": {},
        "hetzner": {},
        "aws": {
            "AWS_ACCESS_KEY_ID": "",
            "AWS_SECRET_ACCESS_KEY": ""
        },
        "azure": {}
    },
}

I was wondering if i could somehow extract "gcp", "hetzner", "aws" and "azure" from it easily? like just a slice with those 4 keys.

I've tried creating a subviper on it and running AllKeys, but that returns AWS_ACCESS_KEY_ID too, and GetStringSlice returns nil.

stark pelican
#

possible can i see ur structure ur using to parse that ?

hexed valley
#

Not parsing it into a structure yet, would that be the way to go?

stark pelican
#

wait are u trying to add a value to those keys ?

#

so like update the json file with a value inside of sum like AWS_ACCESS_KEY_ID": "",

hexed valley
#

Nope, i'm just trying to extract the keys, loop over them, creating the clients needed to spawn servers on them.

stark pelican
#

basically parse them rite ?

hexed valley
#

yeah, preferably using viper as its rather nice for config management

stark pelican
#

but i honestly recommend structures

#

but that package should work just fine