(opts *UpdateOptions, project *projects.Project, projectVariables *variables.VariableSet)
| 180 | } |
| 181 | |
| 182 | func getVariable(opts *UpdateOptions, project *projects.Project, projectVariables *variables.VariableSet) (*variables.Variable, error) { |
| 183 | var variable *variables.Variable |
| 184 | var err error |
| 185 | if opts.Id.Value != "" { |
| 186 | possibleVariables := util.SliceFilter(projectVariables.Variables, func(v *variables.Variable) bool { |
| 187 | return strings.EqualFold(v.ID, opts.Id.Value) |
| 188 | }) |
| 189 | |
| 190 | if len(possibleVariables) == 0 { |
| 191 | return nil, fmt.Errorf("cannot find variable with id '%s'", opts.Id.Value) |
| 192 | } else if len(possibleVariables) > 1 { |
| 193 | return nil, fmt.Errorf("'%s' has matched multiple variables", opts.Id.Value) |
| 194 | } else { |
| 195 | variable = possibleVariables[0] |
| 196 | } |
| 197 | } else { |
| 198 | possibleVariables := util.SliceFilter(projectVariables.Variables, func(v *variables.Variable) bool { |
| 199 | return strings.EqualFold(v.Name, opts.Name.Value) |
| 200 | }) |
| 201 | |
| 202 | if len(possibleVariables) == 0 { |
| 203 | return nil, fmt.Errorf("cannot find variable with name '%s'", opts.Name.Value) |
| 204 | } else if len(possibleVariables) > 1 { |
| 205 | return nil, fmt.Errorf("'%s' has multiple values, supply '%s' flag", possibleVariables[0].Name, FlagId) |
| 206 | } else { |
| 207 | variable = possibleVariables[0] |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | return variable, err |
| 212 | } |
| 213 | |
| 214 | func PromptMissing(opts *UpdateOptions) error { |
| 215 | var project *projects.Project |
no test coverage detected