fix: allow setting variable without using --value
Created by: bradym
Description
This PR addresses #880 (closed) by simplifying and consolidating the logic for setting opts.Value
.
Currently if there are two args to the glab variable set
command, opts.Value
is set to the second arg. Then later the getValue
function is called, and further changes are made to the value.
This update:
- Removes the redundant if statement
- Removes the setting of opts.value outside of the
getValue
function - Removes the use of opts.ValueSet
- Updates the logic in the
getValue
function to enable setting the variable with or without passing--value
flag
Related Issue
Resolves #880 (closed)
How Has This Been Tested?
I ran all of the commands from the help command for glab variable set
before and after my change:
$ glen | sort -r
export ORIGINAL_WITH_ARG=""
export ORIGINAL_SERVER_TOKEN="SERVER_TOKEN_VALUE"
export ORIGINAL_FROM_FLAG="some value"
export ORIGINAL_FROM_FILE="FROM_FILE_VALUE"
export ORIGINAL_FROM_ENV_WITH_FLAG="bradym"
export ORIGINAL_FROM_ENV_WITH_ARG=""
export FIXED_WITH_ARG="some value"
export FIXED_SERVER_TOKEN="SERVER_TOKEN_VALUE"
export FIXED_FROM_FLAG="some value"
export FIXED_FROM_FILE="FROM_FILE_VALUE"
export FIXED_FROM_ENV_WITH_FLAG="bradym"
export FIXED_FROM_ENV_WITH_ARG="bradym"
I also ran tests in a docker container using golang 1.16:
docker run --rm -ti --init -v "$PWD:/app" -w /app golang:1.15-buster bash
root@6c4876a30b19:/app# bin/gotestsum --packages ./commands/variable/set
✓ commands/variable/set (cached)
DONE 18 tests in 0.255s
I tried running make test
but:
DONE 847 tests, 10 failures in 610.099s
Reviewing the errors it looks like it's due to permissions issues.
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation -
Chore (Related to CI or Packaging to platforms)