Skip to content

Do not consider environment variables from viper for CLI commands #12

@Gerrit91

Description

@Gerrit91

At the moment, a user can export env variables, which will then be available through viper and impact a lot of code, like:

// from admin/v1/tenant.go
...
	if viper.IsSet("admitted") {
		req.Admitted = pointer.Pointer(viper.GetBool("admitted"))
	}
	if viper.IsSet("limit") {
		req.Paging = &apiv1.Paging{
			Count: pointer.Pointer(viper.GetUint64("limit")),
			Page:  nextpage,
		}
	}
	if viper.IsSet("provider") {
		return nil, fmt.Errorf("unimplemented filter by provider")
	}

So if a user exports METAL_STACK_CLOUD_ADMITTED it will influence the output of the command, which I do not think should be possible. In this example it is maybe not so dangerous but for deletion or update commands this could lead to unexpected problems. We should therefore only consider --admitted parsed directly from the command line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions