Skip to content

Variables parsing in VariableGroup #186

Open
@yacine-learning

Description

@yacine-learning

Currently this is how variables in VariableGroup are parsed

type VariableGroup struct {
        .....
	// Gets or sets variables contained in the variable group.
	Variables **map[string]interface{} `json:"variables,omitempty"`
}

In order to get the value of a specific variable, we need to some type assertion:

for key, variable := range *variableGroup.Variables {
		value := variable.(map[string]interface{})["value"]
		log.Printf("Variable Name: %v, Value: %v", key, value)
}

Could we not do this instead?

type VariableGroup struct {
        .....
	// Gets or sets variables contained in the variable group.
	Variables *map[string]map[string]interface{} `json:"variables,omitempty"`
}

Therefore we could get the value, this way:

for key, variable := range *variableGroup.Variables {
		vari := variable["value"]
		log.Printf("Variable Name: %v, Value: %v", key, vari)
}

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