feat: support for specifying a space environment when creating a client

This commit is contained in:
Daniel Thomas 2024-11-15 16:34:22 +01:00
parent 5834ea1703
commit 2e5a02b246
2 changed files with 8 additions and 1 deletions

View File

@ -145,8 +145,14 @@ func (c *Command) execute(ctx context.Context, r *readline.Readline) error {
return errors.Wrap(err, string(out))
}
// "master" is the built-in default environment name of contentful
// fallback to it if the configuration does not ask specifically for an environment
if cfg.Environment == "" {
cfg.Environment = "master"
}
if err := shell.New(ctx, c.l, "gocontentful",
"-spaceid", cfg.SpaceID, "-cmakey", cfg.CMAKey,
"-spaceid", cfg.SpaceID, "-cmakey", cfg.CMAKey, "-environment", cfg.Environment,
"-contenttypes", strings.Join(cfg.ContentTypes, ","), dir).
Args(r.AdditionalArgs()...).
Run(); err != nil {

View File

@ -3,5 +3,6 @@ package gocontentful
type Config struct {
SpaceID string `yaml:"spaceId"`
CMAKey string `yaml:"cmaKey"`
Environment string `yaml:"environment,omitempty"`
ContentTypes []string `yaml:"contentTypes"`
}