Skip to content

The priority of configuration files and command lines in Karmadactl init. #925

@luyb177

Description

@luyb177

Why do you think this document is needed:

The content of this article may need modifications: Article Path

The following content may be incorrect:

Overriding Configuration File Values

If necessary, command line flags can still be used in conjunction with the configuration file. The parameters specified via the command line will override those in the configuration file. For example, to override the number of API server replicas, you could use:

karmadactl init --config /path/to/karmada-init.yaml --karmada-apiserver-replicas 5

According to the code implementation:

setIfNotZeroInt32(&i.KarmadaAPIServerReplicas, apiServer.CommonSettings.Replicas)
// setIfNotEmpty checks if the source string is not empty, and if so, assigns its value to the destination string.
func setIfNotEmpty(dest *string, src string) {
  if src != "" {
  	*dest = src
  }
}

Since the assignment of i.KarmadaAPIServerReplicas using the command line occurs earlier than the assignment from parsing the configuration file, it will override the value passed from the command line, rather than the command line value overriding the value passed from the configuration file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions