Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Add a command to select the current context #89

Closed
vieiralucas opened this issue Sep 13, 2023 · 3 comments · Fixed by #96
Closed

Add a command to select the current context #89

vieiralucas opened this issue Sep 13, 2023 · 3 comments · Fixed by #96
Assignees

Comments

@vieiralucas
Copy link
Member

Introduce a new command layerform config use-context <name> that will change the current selected context:

For example, if we have a config file like this:

currentContext: foo
contexts:
    bar:
        type: local
        dir: test
    baz:
        type: local
        dir: test
    foo:
        type: s3
        bucket: bucket
        region: us-east-1

Current context is foo

Running layerform config use-context bar, should set the current context to bar, changing the config file to:

currentContext: bar
contexts:
    bar:
        type: local
        dir: test
    baz:
        type: local
        dir: test
    foo:
        type: s3
        bucket: bucket
        region: us-east-1
@vieiralucas vieiralucas mentioned this issue Sep 13, 2023
2 tasks
@rafiramadhana
Copy link
Contributor

@vieiralucas Can I work in this issue?

I think the implementation is similar to setting the cfg.CurrentContext in set_context.go.

@rafiramadhana
Copy link
Contributor

btw what if the given context (<name>) is the one currently active (currentContext)?

do we return error, or treat it as success

layerform config use-context bar

currentContext: bar
contexts:
    bar:
        type: local
        dir: test

@vieiralucas
Copy link
Member Author

vieiralucas commented Sep 13, 2023

Hi @rafiramadhana, please go ahead. Thank you.

I think the implementation is similar to setting the cfg.CurrentContext in set_context.go.

^ Yes

btw what if the given context (<name>) is the one currently active (currentContext)?

do we return error, or treat it as success

layerform config use-context bar

currentContext: bar
contexts:
    bar:
        type: local
        dir: test

^ We treat it as a success, just check that the given context exists, if it exists, set and save (don't care if it is already current), if it does not exist, then error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants