Skip to content

Config file is being saved on every invocation of the CLI #153

Closed
@Kumm-Kai

Description

@Kumm-Kai

Currently, the STACKIT CLI calls the config.InitConfig function on every invocation.

On the very first call of the binary (no .stackit directory exists), it creates the directory and a config file (with default values).
On every following binary call the config file is being read and directly written to disk again.

This is probably only problematic in some small edge cases, like calling stackit multiple times in one command using process substiution (e.g., <(stackit xyz)). In this case the CLI fails because viper.WriteConfigAs is not concurrency-safe.

This can be solved by either:

  1. Only creating the directory & config file if it is actually needed, e.g., when calling stackit config set/unset
  2. Only writing the config file when necessary (e.g., file on disk differs from config in memory)

From my point of view the first solution would be the best one because in my opinion there is no need to create a config file if the user didn't change the defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions