(opts *UpdateOptions)
| 108 | } |
| 109 | |
| 110 | func updateRun(opts *UpdateOptions) error { |
| 111 | if opts.Unscoped.Value && scopesProvided(opts) { |
| 112 | return fmt.Errorf("cannot provide '%s' and scope flags together", opts.Unscoped.Name) |
| 113 | } |
| 114 | |
| 115 | if !opts.NoPrompt { |
| 116 | err := PromptMissing(opts) |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | project, err := opts.GetProjectCallback(opts.Project.Value) |
| 123 | if err != nil { |
| 124 | return err |
| 125 | } |
| 126 | |
| 127 | var projectVariables *variables.VariableSet |
| 128 | if project.IsVersionControlled && opts.GitRef.Value != "" { |
| 129 | projectVariables, err = opts.GetProjectVariablesByGitRef(opts.Space.GetID(), project.GetID(), opts.GitRef.Value) |
| 130 | } else { |
| 131 | projectVariables, err = opts.GetProjectVariables(project.GetID()) |
| 132 | } |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | |
| 137 | variable, err := getVariable(opts, project, projectVariables) |
| 138 | if err != nil { |
| 139 | return err |
| 140 | } |
| 141 | |
| 142 | if variable.IsSensitive { |
| 143 | opts.Value.Secure = true |
| 144 | } |
| 145 | |
| 146 | updatedScope, err := sharedProjectVariable.ToVariableScope(projectVariables, opts.ScopeFlags, project) |
| 147 | if err != nil { |
| 148 | return err |
| 149 | } |
| 150 | |
| 151 | if opts.Value.Value != "" { |
| 152 | variable.Value = opts.Value.Value |
| 153 | } |
| 154 | |
| 155 | if opts.Unscoped.Value { |
| 156 | variable.Scope = variables.VariableScope{} |
| 157 | } else { |
| 158 | if !updatedScope.IsEmpty() { |
| 159 | variable.Scope = *updatedScope |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | if opts.GitRef.Value != "" { |
| 164 | _, err = opts.Client.ProjectVariables.UpdateByGitRef(opts.Space.GetID(), project.GetID(), opts.GitRef.Value, projectVariables) |
| 165 | } else { |
| 166 | _, err = opts.Client.Variables.UpdateSingle(project.GetID(), variable) |
| 167 | } |
no test coverage detected