Merge pull request #5712 from overbool/feat/cmds/add-config-helper

cmds/env: add a config path helper
This commit is contained in:
Steven Allen 2018-11-02 09:37:59 -07:00 committed by GitHub
commit 8736202417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,3 +40,13 @@ func GetConfig(env cmds.Environment) (*config.Config, error) {
return ctx.GetConfig()
}
// GetConfigRoot extracts the config root from the environment
func GetConfigRoot(env cmds.Environment) (string, error) {
ctx, ok := env.(*commands.Context)
if !ok {
return "", fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
}
return ctx.ConfigRoot, nil
}