terraform-provider-harbor icon indicating copy to clipboard operation
terraform-provider-harbor copied to clipboard

harbor_replications filter not working at all.

Open haiwu opened this issue 4 months ago • 3 comments

Describe the bug harbor_replications filter not working at all.

To Reproduce Just try to use the example section listed in the document section (https://github.com/goharbor/terraform-provider-harbor/blob/main/docs/resources/replication.md), and you will see it does not work at all. There's no where to see the 'qa' label. Only the name and tag could show up. Also there's no way to specify 'includes' or 'excludes'. In the code, it has 'decoration' field, already tried and that does not work at all.

Note: I have tried every single possible harbor-terraform-provider available from this repo, including the latest one, and none works. There are some old providers I could not grab, since those are not with this new repo after the ownership changed.

resource "harbor_replication" "alpine" {
  name        = "alpine"
  action      = "pull"
  registry_id = harbor_registry.main.registry_id
  schedule = "0 0/15 * * * *"
  filters {
    name = "library/alpine"
  }
  filters {
    tag = "3.*.*"
  }
  filters {
    resource = "artifact"
  }
  filters {
    labels = ["qa"]
  }
}

Expected behavior The filter examples listed in the documentation url should all work ok, but that's not the case at all: https://github.com/goharbor/terraform-provider-harbor/blob/main/docs/resources/replication.md

Additional context

  • Provider Version: all versions found in the repo after ownership changed.
  • Terraform Version: 1.5.1, or latest one, or latest opentofu version, none worked.
  • Harbor Version: latest 2.10.0

haiwu avatar Mar 27 '24 18:03 haiwu

Hi @haiwu , with pull-based mode, label filter is only available if source is a Harbor instance

if you want to try, you can try to replicate your harbor to itself:

resource "harbor_registry" "main" {
  provider_name = "harbor"
  name          = "local"
  endpoint_url  = "http://my-release-harbor-core"
  description = "local"
  access_id = "USER"
  access_secret = "PASS"
}

resource "harbor_replication" "alpine" {
  name        = "alpine"
  action      = "pull"
  registry_id = harbor_registry.main.registry_id
  schedule    = "manual"
  filters {
    name = "library/alpine"
  }
  filters {
    labels = [ "qa" ]
  }
  filters {
    resource = "artifact"
  }
  filters {
    tag = "3.*.*"
  }
}

image

flbla avatar Apr 08 '24 08:04 flbla

@flbla : My tests were with harbor instances (both src and target are harbor instances), and it was not working for me.

Which harbor versions, harbor terraform provider version, terraform version you used ok with this one?

haiwu avatar Apr 08 '24 13:04 haiwu

hi, harbor : v2.10.1, terraform 1.8.0 and latest provider version i'm not sure it will help but can you copy the output of the plan ?

flbla avatar Apr 12 '24 09:04 flbla