in internal/provider/sdk/resource_gitlab_project.go [2530:2954]
func updatePostCreateEditOptions(ctx context.Context, editProjectOptions *gitlab.EditProjectOptions, d *schema.ResourceData, client *gitlab.Client, project *gitlab.Project) diag.Diagnostics {
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("mirror_overwrites_diverged_branches"); ok {
editProjectOptions.MirrorOverwritesDivergedBranches = gitlab.Ptr(v.(bool))
importURL, err := constructImportUrl(d.Get("import_url").(string), d.Get("import_url_username").(string), d.Get("import_url_password").(string))
if err != nil {
return diag.Errorf("Unable to construct import URL for API: %s", err)
}
editProjectOptions.ImportURL = gitlab.Ptr(importURL)
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("only_mirror_protected_branches"); ok {
editProjectOptions.OnlyMirrorProtectedBranches = gitlab.Ptr(v.(bool))
importURL, err := constructImportUrl(d.Get("import_url").(string), d.Get("import_url_username").(string), d.Get("import_url_password").(string))
if err != nil {
return diag.Errorf("Unable to construct import URL for API: %s", err)
}
editProjectOptions.ImportURL = gitlab.Ptr(importURL)
}
if v, ok := d.GetOk("description"); ok {
editProjectOptions.Description = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("issues_template"); ok {
editProjectOptions.IssuesTemplate = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("merge_requests_template"); ok {
editProjectOptions.MergeRequestsTemplate = gitlab.Ptr(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("merge_pipelines_enabled"); ok {
editProjectOptions.MergePipelinesEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("merge_trains_enabled"); ok {
editProjectOptions.MergeTrainsEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("ci_default_git_depth"); ok {
editProjectOptions.CIDefaultGitDepth = gitlab.Ptr(v.(int))
}
if v, ok := d.GetOk("ci_id_token_sub_claim_components"); ok {
editProjectOptions.CIIdTokenSubClaimComponents = stringListToStringSlice(v.([]any))
}
if v, ok := d.GetOk("ci_delete_pipelines_in_seconds"); ok {
editProjectOptions.CIDeletePipelinesInSeconds = gitlab.Ptr(v.(int))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("ci_forward_deployment_enabled"); ok {
editProjectOptions.CIForwardDeploymentEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("ci_separated_caches"); ok {
editProjectOptions.CISeperateCache = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("keep_latest_artifact"); ok {
editProjectOptions.KeepLatestArtifact = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("restrict_user_defined_variables"); ok {
editProjectOptions.RestrictUserDefinedVariables = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("ci_restrict_pipeline_cancellation_role"); ok {
editProjectOptions.CIRestrictPipelineCancellationRole = gitlab.Ptr(api.AccessControlLevelValueToName(v.(string)))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("ci_pipeline_variables_minimum_override_role"); ok {
editProjectOptions.CIPipelineVariablesMinimumOverrideRole = gitlab.Ptr(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("allow_pipeline_trigger_approve_deployment"); ok {
editProjectOptions.AllowPipelineTriggerApproveDeployment = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("prevent_merge_without_jira_issue"); ok {
editProjectOptions.PreventMergeWithoutJiraIssue = gitlab.Ptr(v.(bool))
}
// If we forked the project we could apply lots of the attributes,
// thus, we have to do this now.
if project.ForkedFromProject != nil {
if v, ok := d.GetOk("default_branch"); ok {
editProjectOptions.DefaultBranch = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("merge_method"); ok {
editProjectOptions.MergeMethod = stringToMergeMethod(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("only_allow_merge_if_pipeline_succeeds"); ok {
editProjectOptions.OnlyAllowMergeIfPipelineSucceeds = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("only_allow_merge_if_all_discussions_are_resolved"); ok {
editProjectOptions.OnlyAllowMergeIfAllDiscussionsAreResolved = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("allow_merge_on_skipped_pipeline"); ok {
editProjectOptions.AllowMergeOnSkippedPipeline = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("request_access_enabled"); ok {
editProjectOptions.RequestAccessEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("issues_enabled"); ok {
editProjectOptions.IssuesEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("merge_requests_enabled"); ok {
editProjectOptions.MergeRequestsEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("pipelines_enabled"); ok {
// nolint:staticcheck // SA1019
editProjectOptions.JobsEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("approvals_before_merge"); ok {
editProjectOptions.ApprovalsBeforeMerge = gitlab.Ptr(v.(int)) //nolint:staticcheck
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("wiki_enabled"); ok {
// nolint:staticcheck // SA1019
editProjectOptions.WikiEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("snippets_enabled"); ok {
// nolint:staticcheck // SA1019
editProjectOptions.SnippetsEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("shared_runners_enabled"); ok {
editProjectOptions.SharedRunnersEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("group_runners_enabled"); ok {
editProjectOptions.GroupRunnersEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("tags"); ok {
// TODO: Remove TagList on next breaking change. TagList and Topics aren't completely synonymous.
// nolint:staticcheck // SA1019
editProjectOptions.TagList = stringSetToStringSlice(v.(*schema.Set))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("container_registry_enabled"); ok {
editProjectOptions.ContainerRegistryEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("lfs_enabled"); ok {
editProjectOptions.LFSEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("squash_option"); ok {
editProjectOptions.SquashOption = stringToSquashOptionValue(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("remove_source_branch_after_merge"); ok {
editProjectOptions.RemoveSourceBranchAfterMerge = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("printing_merge_request_link_enabled"); ok {
editProjectOptions.PrintingMergeRequestLinkEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("packages_enabled"); ok {
editProjectOptions.PackagesEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("pages_access_level"); ok {
editProjectOptions.PagesAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("ci_config_path"); ok {
editProjectOptions.CIConfigPath = gitlab.Ptr(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("ci_forward_deployment_enabled"); ok {
editProjectOptions.CIForwardDeploymentEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("resolve_outdated_diff_discussions"); ok {
editProjectOptions.ResolveOutdatedDiffDiscussions = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("analytics_access_level"); ok {
editProjectOptions.AnalyticsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("auto_cancel_pending_pipelines"); ok {
editProjectOptions.AutoCancelPendingPipelines = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("auto_devops_deploy_strategy"); ok {
editProjectOptions.AutoDevopsDeployStrategy = gitlab.Ptr(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("auto_devops_enabled"); ok {
editProjectOptions.AutoDevopsEnabled = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("autoclose_referenced_issues"); ok {
editProjectOptions.AutocloseReferencedIssues = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("build_git_strategy"); ok {
editProjectOptions.BuildGitStrategy = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("build_timeout"); ok {
editProjectOptions.BuildTimeout = gitlab.Ptr(v.(int))
}
if v, ok := d.GetOk("builds_access_level"); ok {
editProjectOptions.BuildsAccessLevel = stringToAccessControlValue(v.(string))
}
if _, ok := d.GetOk("container_expiration_policy"); ok {
editProjectOptions.ContainerExpirationPolicyAttributes = expandContainerExpirationPolicyAttributes(d)
}
if v, ok := d.GetOk("container_registry_access_level"); ok {
editProjectOptions.ContainerRegistryAccessLevel = stringToAccessControlValue(v.(string))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("emails_enabled"); ok {
editProjectOptions.EmailsEnabled = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("external_authorization_classification_label"); ok {
editProjectOptions.ExternalAuthorizationClassificationLabel = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("forking_access_level"); ok {
editProjectOptions.ForkingAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("issues_access_level"); ok {
editProjectOptions.IssuesAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("merge_requests_access_level"); ok {
editProjectOptions.MergeRequestsAccessLevel = stringToAccessControlValue(v.(string))
}
// Ignore deprecated public_builds in favor of public_jobs.
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("public_jobs"); ok {
editProjectOptions.PublicBuilds = gitlab.Ptr(v.(bool))
} else if v, ok := d.GetOkExists("public_builds"); ok {
editProjectOptions.PublicBuilds = gitlab.Ptr(v.(bool))
}
if v, ok := d.GetOk("repository_access_level"); ok {
editProjectOptions.RepositoryAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("repository_storage"); ok {
editProjectOptions.RepositoryStorage = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("requirements_access_level"); ok {
editProjectOptions.RequirementsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("security_and_compliance_access_level"); ok {
editProjectOptions.SecurityAndComplianceAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("snippets_access_level"); ok {
editProjectOptions.SnippetsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("suggestion_commit_message"); ok {
editProjectOptions.SuggestionCommitMessage = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("topics"); ok {
editProjectOptions.Topics = stringSetToStringSlice(v.(*schema.Set))
}
if v, ok := d.GetOk("wiki_access_level"); ok {
editProjectOptions.WikiAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("squash_commit_template"); ok {
editProjectOptions.SquashCommitTemplate = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("merge_commit_template"); ok {
editProjectOptions.MergeCommitTemplate = gitlab.Ptr(v.(string))
}
if v, ok := d.GetOk("import_url"); ok {
importURL, err := constructImportUrl(v.(string), d.Get("import_url_username").(string), d.Get("import_url_password").(string))
if err != nil {
return diag.Errorf("Unable to construct import URL for API: %s", err)
}
editProjectOptions.ImportURL = gitlab.Ptr(importURL)
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("mirror"); ok {
editProjectOptions.Mirror = gitlab.Ptr(v.(bool))
}
// nolint:staticcheck // SA1019 ignore deprecated GetOkExists
// lintignore: XR001 // TODO: replace with alternative for GetOkExists
if v, ok := d.GetOkExists("mirror_trigger_builds"); ok {
editProjectOptions.MirrorTriggerBuilds = gitlab.Ptr(v.(bool))
}
avatar, err := handleAvatarOnUpdate(d)
if err != nil {
return diag.FromErr(err)
}
if avatar != nil {
editProjectOptions.Avatar = &gitlab.ProjectAvatar{
Filename: avatar.Filename,
Image: avatar.Image,
}
}
if v, ok := d.GetOk("releases_access_level"); ok {
editProjectOptions.ReleasesAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("environments_access_level"); ok {
editProjectOptions.EnvironmentsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("feature_flags_access_level"); ok {
editProjectOptions.FeatureFlagsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("infrastructure_access_level"); ok {
editProjectOptions.InfrastructureAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("monitor_access_level"); ok {
editProjectOptions.MonitorAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("model_experiments_access_level"); ok {
editProjectOptions.ModelExperimentsAccessLevel = stringToAccessControlValue(v.(string))
}
if v, ok := d.GetOk("model_registry_access_level"); ok {
editProjectOptions.ModelRegistryAccessLevel = stringToAccessControlValue(v.(string))
}
}
return nil
}