import ( "github.com/juju/juju/environs/configstore" "github.com/juju/juju/environs/configstore/configstoretesting" ) func main() { fakeConfigstore := configstoretesting.NewMemStore() environs := EnvironInfo{ Cloud: "aws", Region: "us-east-1", Endpoint: "https://ec2.amazonaws.com", AccessKey: "accesskey", SecretKey: "secretkey", } fakeConfigstore.AddEnviron("env1", environs.ToParams()) provider, err := configstore.GetEnvironInfo(fakeConfigstore, "env1") if err != nil { // handle error } fmt.Println(provider.Cloud) // "aws" }
import ( "github.com/juju/juju/environs/configstore" "github.com/juju/juju/environs/configstore/configstoretesting" ) func main() { fakeConfigstore := configstoretesting.NewMemStore() environs := EnvironInfo{ Cloud: "aws", Region: "us-east-1", Endpoint: "https://ec2.amazonaws.com", AccessKey: "accesskey", SecretKey: "secretkey", } fakeConfigstore.AddEnviron("env1", environs.ToParams()) newCreds := EnvironInfo{ AccessKey: "newaccesskey", SecretKey: "newsecretkey", } updatedParams := newCreds.ToParams() _, err := fakeConfigstore.UpdateEnviron("env1", updatedParams) if err != nil { // handle error } }Overall, the EnvironInfo package in the Juju configstore library is useful for managing environment configuration information in a consistent and easily retrievable way.