Loading docs/release-3.0-migration.md +82 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,88 @@ _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_fea }) ``` ## Replaced "ProjectFeatureFlagScope" with create and update options variants `FeatureFlagStrategyOptions`, now replaced by `CreateProjectFeatureFlagOptions` and `UpdateProjectFeatureFlagOptions` used `ProjectFeatureFlagScope` for its `Scopes` field, which exposed fields on the create endpoint that only the update endpoint accepts. The struct is now split so each endpoint only offers the attributes its API documentation lists. **Changes:** - Added: `CreateProjectFeatureFlagScopeOptions`, used by `CreateFeatureFlagStrategyOptions` - Added: `UpdateProjectFeatureFlagScopeOptions`, used by `UpdateFeatureFlagStrategyOptions` `CreateProjectFeatureFlagScopeOptions` omits the `ID` and `Destroy` fields, as the create endpoint documents neither `scopes:id` nor `scopes:_destroy`. There is no pre-existing scope to identify or delete when creating a flag. ```go // Before (v2.x) _, _, err := client.ProjectFeatureFlags.CreateProjectFeatureFlag(1, &CreateProjectFeatureFlagOptions{ Name: Ptr("awesome_feature"), Strategies: &[]*FeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*ProjectFeatureFlagScope{ { EnvironmentScope: "*", }, }, }, }, }) // After (v3.0) _, _, err := client.ProjectFeatureFlags.CreateProjectFeatureFlag(1, &CreateProjectFeatureFlagOptions{ Name: Ptr("awesome_feature"), Strategies: &[]*CreateFeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*CreateProjectFeatureFlagScopeOptions{ { EnvironmentScope: Ptr("*"), }, }, }, }, }) ``` Update calls keep the full set of fields, and only need the type renamed: ```go // Before (v2.x) _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_feature", &UpdateProjectFeatureFlagOptions{ Strategies: &[]*FeatureFlagStrategyOptions{ { ID: Ptr(int64(38)), Scopes: &[]*ProjectFeatureFlagScope{ { ID: int64(1), Destroy: Ptr(true), }, }, }, }, }) // After (v3.0) _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_feature", &UpdateProjectFeatureFlagOptions{ Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(38)), Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { ID: Ptr(int64(1)), Destroy: Ptr(true), }, }, }, }, }) ``` ## Merge request webhook reviewers now use `EventReviewer` Merge request webhook events model reviewers with a dedicated `EventReviewer` Loading project_feature_flags.go +19 −14 Original line number Diff line number Diff line Loading @@ -65,11 +65,6 @@ type ProjectFeatureFlag struct { type ProjectFeatureFlagScope struct { ID int64 `json:"id,omitempty"` EnvironmentScope string `json:"environment_scope"` // Destroy removes the scope identified by ID when set to true. Used // during UpdateProjectFeatureFlag to delete a scope that is no longer // wanted. Destroy *bool `json:"_destroy,omitempty"` } // ProjectFeatureFlagStrategy defines the strategy used for a feature flag Loading Loading @@ -147,21 +142,18 @@ type CreateProjectFeatureFlagOptions struct { type CreateFeatureFlagStrategyOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Parameters *ProjectFeatureFlagStrategyParameter `url:"parameters,omitempty" json:"parameters,omitempty"` Scopes *[]*ProjectFeatureFlagScope `url:"scopes,omitempty" json:"scopes,omitempty"` Scopes *[]*CreateProjectFeatureFlagScopeOptions `url:"scopes,omitempty" json:"scopes,omitempty"` // UserListID sets the feature flag user list bound to the strategy. Only // used when Name is "gitlabUserList". UserListID *int64 `url:"user_list_id,omitempty" json:"user_list_id,omitempty"` } // ProjectFeatureFlagScopeOptions represents the available feature flag scope // options. // CreateProjectFeatureFlagScopeOptions defines the scopes of a feature flag // // GitLab API docs: // https://docs.gitlab.com/api/feature_flags/#create-a-feature-flag type ProjectFeatureFlagScopeOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` EnvironmentScope *string `url:"id,omitempty" json:"environment_scope,omitempty"` // GitLab API docs: https://docs.gitlab.com/api/feature_flags/ type CreateProjectFeatureFlagScopeOptions struct { EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` } func (s *ProjectFeatureFlagService) CreateProjectFeatureFlag(pid any, opt *CreateProjectFeatureFlagOptions, options ...RequestOptionFunc) (*ProjectFeatureFlag, *Response, error) { Loading Loading @@ -194,7 +186,7 @@ type UpdateFeatureFlagStrategyOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"` Parameters *ProjectFeatureFlagStrategyParameter `url:"parameters,omitempty" json:"parameters,omitempty"` Scopes *[]*ProjectFeatureFlagScope `url:"scopes,omitempty" json:"scopes,omitempty"` Scopes *[]*UpdateProjectFeatureFlagScopeOptions `url:"scopes,omitempty" json:"scopes,omitempty"` // UserListID sets the feature flag user list bound to the strategy. Only // used when Name is "gitlabUserList". Loading @@ -205,6 +197,19 @@ type UpdateFeatureFlagStrategyOptions struct { Destroy *bool `url:"_destroy,omitempty" json:"_destroy,omitempty"` } // UpdateProjectFeatureFlagScopeOptions defines the scopes of a feature flag // // GitLab API docs: https://docs.gitlab.com/api/feature_flags/ type UpdateProjectFeatureFlagScopeOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` // Destroy removes the scope identified by ID when set to true. Used // during UpdateProjectFeatureFlag to delete a scope that is no longer // wanted. Destroy *bool `url:"_destroy,omitempty" json:"_destroy,omitempty"` } func (s *ProjectFeatureFlagService) UpdateProjectFeatureFlag(pid any, name string, opt *UpdateProjectFeatureFlagOptions, options ...RequestOptionFunc) (*ProjectFeatureFlag, *Response, error) { return do[*ProjectFeatureFlag](s.client, withMethod(http.MethodPut), Loading project_feature_flags_test.go +6 −7 Original line number Diff line number Diff line Loading @@ -200,9 +200,9 @@ func TestCreateProjectFeatureFlag_Strategies(t *testing.T) { Strategies: &[]*CreateFeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*CreateProjectFeatureFlagScopeOptions{ { EnvironmentScope: "production", EnvironmentScope: Ptr("production"), }, }, }, Loading Loading @@ -369,7 +369,6 @@ func TestUpdateProjectFeatureFlag_ScopeDestroy(t *testing.T) { "scopes": []any{ map[string]any{ "id": float64(37), "environment_scope": "", "_destroy": true, }, }, Loading @@ -383,9 +382,9 @@ func TestUpdateProjectFeatureFlag_ScopeDestroy(t *testing.T) { Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(36)), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { ID: 37, ID: Ptr(int64(37)), Destroy: Ptr(true), }, }, Loading Loading @@ -441,9 +440,9 @@ func TestUpdateProjectFeatureFlag_ScopeCreate(t *testing.T) { Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(36)), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { EnvironmentScope: "staging", EnvironmentScope: Ptr("staging"), }, }, }, Loading Loading
docs/release-3.0-migration.md +82 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,88 @@ _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_fea }) ``` ## Replaced "ProjectFeatureFlagScope" with create and update options variants `FeatureFlagStrategyOptions`, now replaced by `CreateProjectFeatureFlagOptions` and `UpdateProjectFeatureFlagOptions` used `ProjectFeatureFlagScope` for its `Scopes` field, which exposed fields on the create endpoint that only the update endpoint accepts. The struct is now split so each endpoint only offers the attributes its API documentation lists. **Changes:** - Added: `CreateProjectFeatureFlagScopeOptions`, used by `CreateFeatureFlagStrategyOptions` - Added: `UpdateProjectFeatureFlagScopeOptions`, used by `UpdateFeatureFlagStrategyOptions` `CreateProjectFeatureFlagScopeOptions` omits the `ID` and `Destroy` fields, as the create endpoint documents neither `scopes:id` nor `scopes:_destroy`. There is no pre-existing scope to identify or delete when creating a flag. ```go // Before (v2.x) _, _, err := client.ProjectFeatureFlags.CreateProjectFeatureFlag(1, &CreateProjectFeatureFlagOptions{ Name: Ptr("awesome_feature"), Strategies: &[]*FeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*ProjectFeatureFlagScope{ { EnvironmentScope: "*", }, }, }, }, }) // After (v3.0) _, _, err := client.ProjectFeatureFlags.CreateProjectFeatureFlag(1, &CreateProjectFeatureFlagOptions{ Name: Ptr("awesome_feature"), Strategies: &[]*CreateFeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*CreateProjectFeatureFlagScopeOptions{ { EnvironmentScope: Ptr("*"), }, }, }, }, }) ``` Update calls keep the full set of fields, and only need the type renamed: ```go // Before (v2.x) _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_feature", &UpdateProjectFeatureFlagOptions{ Strategies: &[]*FeatureFlagStrategyOptions{ { ID: Ptr(int64(38)), Scopes: &[]*ProjectFeatureFlagScope{ { ID: int64(1), Destroy: Ptr(true), }, }, }, }, }) // After (v3.0) _, _, err := client.ProjectFeatureFlags.UpdateProjectFeatureFlag(1, "awesome_feature", &UpdateProjectFeatureFlagOptions{ Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(38)), Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { ID: Ptr(int64(1)), Destroy: Ptr(true), }, }, }, }, }) ``` ## Merge request webhook reviewers now use `EventReviewer` Merge request webhook events model reviewers with a dedicated `EventReviewer` Loading
project_feature_flags.go +19 −14 Original line number Diff line number Diff line Loading @@ -65,11 +65,6 @@ type ProjectFeatureFlag struct { type ProjectFeatureFlagScope struct { ID int64 `json:"id,omitempty"` EnvironmentScope string `json:"environment_scope"` // Destroy removes the scope identified by ID when set to true. Used // during UpdateProjectFeatureFlag to delete a scope that is no longer // wanted. Destroy *bool `json:"_destroy,omitempty"` } // ProjectFeatureFlagStrategy defines the strategy used for a feature flag Loading Loading @@ -147,21 +142,18 @@ type CreateProjectFeatureFlagOptions struct { type CreateFeatureFlagStrategyOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Parameters *ProjectFeatureFlagStrategyParameter `url:"parameters,omitempty" json:"parameters,omitempty"` Scopes *[]*ProjectFeatureFlagScope `url:"scopes,omitempty" json:"scopes,omitempty"` Scopes *[]*CreateProjectFeatureFlagScopeOptions `url:"scopes,omitempty" json:"scopes,omitempty"` // UserListID sets the feature flag user list bound to the strategy. Only // used when Name is "gitlabUserList". UserListID *int64 `url:"user_list_id,omitempty" json:"user_list_id,omitempty"` } // ProjectFeatureFlagScopeOptions represents the available feature flag scope // options. // CreateProjectFeatureFlagScopeOptions defines the scopes of a feature flag // // GitLab API docs: // https://docs.gitlab.com/api/feature_flags/#create-a-feature-flag type ProjectFeatureFlagScopeOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` EnvironmentScope *string `url:"id,omitempty" json:"environment_scope,omitempty"` // GitLab API docs: https://docs.gitlab.com/api/feature_flags/ type CreateProjectFeatureFlagScopeOptions struct { EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` } func (s *ProjectFeatureFlagService) CreateProjectFeatureFlag(pid any, opt *CreateProjectFeatureFlagOptions, options ...RequestOptionFunc) (*ProjectFeatureFlag, *Response, error) { Loading Loading @@ -194,7 +186,7 @@ type UpdateFeatureFlagStrategyOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"` Parameters *ProjectFeatureFlagStrategyParameter `url:"parameters,omitempty" json:"parameters,omitempty"` Scopes *[]*ProjectFeatureFlagScope `url:"scopes,omitempty" json:"scopes,omitempty"` Scopes *[]*UpdateProjectFeatureFlagScopeOptions `url:"scopes,omitempty" json:"scopes,omitempty"` // UserListID sets the feature flag user list bound to the strategy. Only // used when Name is "gitlabUserList". Loading @@ -205,6 +197,19 @@ type UpdateFeatureFlagStrategyOptions struct { Destroy *bool `url:"_destroy,omitempty" json:"_destroy,omitempty"` } // UpdateProjectFeatureFlagScopeOptions defines the scopes of a feature flag // // GitLab API docs: https://docs.gitlab.com/api/feature_flags/ type UpdateProjectFeatureFlagScopeOptions struct { ID *int64 `url:"id,omitempty" json:"id,omitempty"` EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` // Destroy removes the scope identified by ID when set to true. Used // during UpdateProjectFeatureFlag to delete a scope that is no longer // wanted. Destroy *bool `url:"_destroy,omitempty" json:"_destroy,omitempty"` } func (s *ProjectFeatureFlagService) UpdateProjectFeatureFlag(pid any, name string, opt *UpdateProjectFeatureFlagOptions, options ...RequestOptionFunc) (*ProjectFeatureFlag, *Response, error) { return do[*ProjectFeatureFlag](s.client, withMethod(http.MethodPut), Loading
project_feature_flags_test.go +6 −7 Original line number Diff line number Diff line Loading @@ -200,9 +200,9 @@ func TestCreateProjectFeatureFlag_Strategies(t *testing.T) { Strategies: &[]*CreateFeatureFlagStrategyOptions{ { Name: Ptr("default"), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*CreateProjectFeatureFlagScopeOptions{ { EnvironmentScope: "production", EnvironmentScope: Ptr("production"), }, }, }, Loading Loading @@ -369,7 +369,6 @@ func TestUpdateProjectFeatureFlag_ScopeDestroy(t *testing.T) { "scopes": []any{ map[string]any{ "id": float64(37), "environment_scope": "", "_destroy": true, }, }, Loading @@ -383,9 +382,9 @@ func TestUpdateProjectFeatureFlag_ScopeDestroy(t *testing.T) { Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(36)), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { ID: 37, ID: Ptr(int64(37)), Destroy: Ptr(true), }, }, Loading Loading @@ -441,9 +440,9 @@ func TestUpdateProjectFeatureFlag_ScopeCreate(t *testing.T) { Strategies: &[]*UpdateFeatureFlagStrategyOptions{ { ID: Ptr(int64(36)), Scopes: &[]*ProjectFeatureFlagScope{ Scopes: &[]*UpdateProjectFeatureFlagScopeOptions{ { EnvironmentScope: "staging", EnvironmentScope: Ptr("staging"), }, }, }, Loading