feature: add variable update command
Created by: bradym
Description
This PR addresses #899 (closed) by adding a new glab variable update
command. The ticket originally mentioned just adding update functionality to the set command, but this turned out to be the easier way to go. I think it's also more consistent with other existing commands.
In addition to adding the update command I did the following:
- Moved getValue function from set.go to variableutils/value.go and refactored to be reusable
- Updated set.go to use new variableutils.GetValue function
- Fixed a couple incorrect comments in set.go
- Updated set.go to include scope in success message
How Has This Been Tested?
I've updated environment variables in a repo on gitlab.com using these changes. I successfully updated group variables and project variables. With project variables I verified that scoped changes are made correctly. I also ran existing and new tests in a docker container locally:
root@0d8d63f7e504:/app# bin/gotestsum --packages ./commands/variable ✓ commands/variable (10ms)
DONE 1 tests in 1.062s
root@0d8d63f7e504:/app# bin/gotestsum --packages ./commands/variable/set ✓ commands/variable/set (10ms)
DONE 11 tests in 0.766s
root@0d8d63f7e504:/app# bin/gotestsum --packages ./commands/variable/variableutils ✓ commands/variable/variableutils (8ms)
DONE 7 tests in 0.680s
root@0d8d63f7e504:/app# bin/gotestsum --packages ./commands/variable/update ✓ commands/variable/update (11ms)
DONE 11 tests in 0.787s
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)