jfrog / terraform-provider-artifactory

Terraform provider to manage JFrog Artifactory
https://jfrog.com/artifactory
Apache License 2.0
275 stars 106 forks source link

curated = true not working for nuget and npm remote repositories with azureDevOps as Source #1118

Open FischlerA opened 1 day ago

FischlerA commented 1 day ago

Describe the bug When creating artifactory_remote_npm_repository or artifactory_remote_nuget_repository the option "curated" cannot be set to true when using azureDevops as source for the remote repo.

This terraform code

resource "artifactory_remote_nuget_repository" "nuget-azuredevops" {
  key                        = "nuget-azuredevops"
  url                        = <url to private azure devops artifact feed>
  xray_index                 = true
  force_nuget_authentication = true
  curated                    = true
  username = "fake"
  password = "password"
}

produces this error

╷
│ Error: {
│   "errors" : [ {
│     "status" : 400,
│     "message" : "The Curation config changes on remote repo: nuget-azuredevops are invalid"
│   } ]
│ }
│ 
│   with artifactory_remote_nuget_repository.nuget-azuredevops,
│   on artifact-repos.tf line 32, in resource "artifactory_remote_nuget_repository" "nuget-azuredevops":
│   32: resource "artifactory_remote_nuget_repository" "nuget-azuredevops" {
│ 
╵

Artifactory Version: 7.99.2 Artifactory Revision: 79902900 Terraform Version 1.2.3 Artifactory Provider v12.3.3

Requirements for and issue

Expected behavior It should be possible to enable curation for all remote repositories as per terraform documentation https://registry.terraform.io/providers/jfrog/artifactory/latest/docs/resources/remote_nuget_repository

FischlerA commented 1 day ago

Enabling curation works when not using AzureDevOps as source:

resource "artifactory_remote_nuget_repository" "nuget-remote" {
  key                        = "nuget-remote"
  description                = "Enthält alle NuGet-Pakete von NuGet.org"
  url                        = "https://www.nuget.org/"
  download_context_path      = "api/v2/package"
  curated                    = true
  xray_index                 = true
  force_nuget_authentication = true
  v3_feed_url                = "https://api.nuget.org/v3/index.json"
  symbol_server_url          = "https://symbols.nuget.org/download/symbols"
}
alexhung commented 1 day ago

@FischlerA Thanks for the report. The error message is from the REST API so I suspect there's some limitation with NuGet package type and curation that isn't clear. I'll add this to our plan to investigate.

alexhung commented 7 hours ago

@FischlerA I am unable to reproduce your issue so far.

Using your TF configuration, I am able to create the resource on our dev Artifactory instance (v7.99.2):

terraform {
  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "12.4.0"
    }
  }
}

provider "artifactory" {
  //  supply ARTIFACTORY_ACCESS_TOKEN / JFROG_ACCESS_TOKEN / ARTIFACTORY_API_KEY and ARTIFACTORY_URL / JFROG_URL as env vars
}

resource "artifactory_remote_nuget_repository" "nuget-azuredevops" {
  key                        = "nuget-azuredevops"
  url                        = "https://www.nuget.org"
  xray_index                 = true
  force_nuget_authentication = true
  curated                    = true
  username = "fake"
  password = "password"
}
alexh@alexh-mac terraform-provider-artifactory % terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # artifactory_remote_nuget_repository.nuget-azuredevops will be created
  + resource "artifactory_remote_nuget_repository" "nuget-azuredevops" {
      + allow_any_host_auth                   = false
      + archive_browsing_enabled              = false
      + assumed_offline_period_secs           = 300
      + blacked_out                           = false
      + block_mismatching_mime_types          = true
      + bypass_head_requests                  = false
      + cdn_redirect                          = false
      + client_tls_certificate                = (known after apply)
      + curated                               = true
      + disable_proxy                         = false
      + disable_url_normalization             = false
      + download_context_path                 = "api/v2/package"
      + download_direct                       = false
      + enable_cookie_management              = false
      + feed_context_path                     = "api/v2"
      + force_nuget_authentication            = true
      + hard_fail                             = false
      + id                                    = (known after apply)
      + includes_pattern                      = "**/*"
      + key                                   = "nuget-azuredevops"
      + list_remote_folder_items              = false
      + metadata_retrieval_timeout_secs       = 60
      + missed_cache_period_seconds           = 1800
      + offline                               = false
      + package_type                          = (known after apply)
      + password                              = (sensitive value)
      + priority_resolution                   = false
      + project_environments                  = (known after apply)
      + repo_layout_ref                       = "nuget-default"
      + retrieval_cache_period_seconds        = 7200
      + share_configuration                   = (known after apply)
      + socket_timeout_millis                 = 15000
      + store_artifacts_locally               = true
      + symbol_server_url                     = "https://symbols.nuget.org/download/symbols"
      + synchronize_properties                = false
      + unused_artifacts_cleanup_period_hours = 0
      + url                                   = "https://www.nuget.org"
      + username                              = "fake"
      + v3_feed_url                           = "https://api.nuget.org/v3/index.json"
      + xray_index                            = true

      + content_synchronisation (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

artifactory_remote_nuget_repository.nuget-azuredevops: Creating...
artifactory_remote_nuget_repository.nuget-azuredevops: Creation complete after 0s [id=nuget-azuredevops]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Terraform version: 1.9.1 Terraform Provider version: 12.4.0