feat(groups): add always_on Duo availability value

Adds DuoAvailabilityAlwaysOn ("always_on") to the DuoAvailabilityValue constants. This was asked for in gitlab-org/terraform-provider-gitlab!3322.

The groups API accepts four values for duo_availability on create and update: always_on, default_on, default_off, and never_on. client-go only had constants for the last three. always_on turns Duo on for the group and locks it, so subgroups and projects cannot turn it off.

This is where GitLab defines the values:

  • ee/app/models/ee/namespace_setting.rb:8: DUO_AVAILABILITY_VALUES = %w[always_on default_on default_off never_on]
  • ee/lib/ee/api/helpers/groups_helpers.rb:32: the group params use that list, with the description "One of default_on, default_off, never_on or always_on"

The groups API docs (doc/api/groups.md) still list only three values, so the docs are behind the code here.

Users could already send always_on with new(gitlab.DuoAvailabilityValue("always_on")). The constant only gives it a name like the other values. Nothing else changes.

How I tested

I added a test that updates a group with DuoAvailabilityAlwaysOn and checks that the request body has "duo_availability": "always_on".

gofumpt -l types.go groups_test.go
go build ./...
go vet .
go test . -run 'DuoAvailability|TestUpdateGroup$|TestCreateGroup_FullAttributes|TestGetGroup$' -count=1 -v

gofumpt lists no files, the build and go vet are clean, and the tests pass:

--- PASS: TestGetGroup (0.00s)
--- PASS: TestUpdateGroup (0.00s)
--- PASS: TestUpdateGroupWithDuoAvailabilityAlwaysOn (0.00s)
--- PASS: TestCreateGroup_FullAttributes (0.00s)
PASS
ok  	gitlab.com/gitlab-org/api/client-go/v3	0.023s

The rest runs in the pipeline.

Implemented with AI assistance; I reviewed and tested the changes.

Merge request reports

Loading
Loading