GithubHelp home page GithubHelp logo

goharbor / terraform-provider-harbor Goto Github PK

View Code? Open in Web Editor NEW
115.0 12.0 90.0 9.93 MB

A Terraform provider for Harbor. To configure and manage all aspects of your Harbor Container Registry with Terraform Infrastructure as Code.

Home Page: https://registry.terraform.io/providers/goharbor/harbor

License: MIT License

Go 99.77% Makefile 0.23%
harbor terraform terraform-provider container-registry iac iac-terraform

terraform-provider-harbor's People

Contributors

akhal3d96 avatar andrei-predoiu avatar cesarempathy avatar dependabot-circleci[bot] avatar dependabot[bot] avatar dh-ironsec avatar dmitry-g avatar dweebo avatar flbla avatar gaardsholt avatar gaglimax avatar kschu91 avatar macno avatar martinohmann avatar mnaser avatar mxmorin avatar naitmare01 avatar niklasbeinghaus avatar nkbud avatar orkarstoft avatar orlinvasilev avatar pesarkhobeee avatar punycode avatar roberdvs avatar slushysnowman avatar sshota0809 avatar stainless888 avatar sydorovdmytro avatar vad1mo avatar wrighbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-harbor's Issues

Cannot create robot accounts for private projects

We have existing project that we want to gradually migrate to this provider. For public projects, we can create robot accounts like this

data "harbor_project" "project" {
name = var.harbor_project_name
}

resource "harbor_robot_account" "account" {
name = var.harbor_robot_account_name
description = var.harbor_robot_account_description
project_id = data.harbor_project.project.id
actions = ["pull","read"]
}

For private projects, I get following error

Error: strconv.ParseBool: parsing "": invalid syntax

Is it my hands (I am terraform noob), or actual bug? I am using harbor admin account

Password LDAP seems not working

Hello,

When I note ldap_search_password and I check connectivity, I get this log in Harbor :
2021-03-05T12:35:44Z [ERROR] [/lib/http/error.go:54]: {"errors":[{"code":"INTERNAL_SERVER_ERROR","message":"LDAP connect fail, error: LDAP Result Code 206 "Empty password not allowed by the client": ldap: empty password not allowed by the client"}]}

  • Version 1.2.2

auto launch replication after create or update a replication

When I create event_based replication, Harbor doesn't launch a replication if there is no event.
Could be great to have in the replication resource definition a "launch replication" property which launch a replication after a create or an update of the replication object.

Unable to add internal user to a project

Hi.
We have some problems with internal users, provider crashes when we try to add a new user to a project.
tf code which provide error

resource "harbor_project_member" "project_member" {
  project_id    = harbor_project.project["core"].id
  name          = "core"
  role          = "developer"
  type          = "internal"
}

Plan is generated without any problem but when we try to apply it we got crash and following error https://gist.github.com/pcheliniy/b68acdecc697cfc88e40dd06a6ca2818
provider version: 0.1.1
api_version: 2
harbor doesn't have clair and trivy components (I'm not sure but I guess it can be connected to the problem)
vulnerability scanning for project also disabled (we tried to enable it but it didn't help)

Robot Account Prefix is hardcoded to "robot$"

Describe the bug

The robot prefix is hardcoded to robot$.

https://github.com/BESTSELLER/terraform-provider-harbor/blob/54c1a0fe9cb30c554ffcb20dee09a33af67976ee/provider/resource_robot_account.go#L117

Since Harbor 2.2.0 (current only a release candidate), it's possible to adjust this value in the harbor instance configuration. Thus, the hardcoded value in the provider leads to an issue when another prefix is chosen. Syncing the state leads to the recreation of robot accounts each time terraform apply is executed.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Habor Web interface as an admin (Harbor version >= 2.2.0)
  2. Click on Administration -> Configuration -> System Settings
  3. Set "Robot Name Prefix" to something which is not robot$
  4. Save the changes
  5. Apply a terraform configuration with a robot account.

Here, the prefix robot_ was chosen:

  # module.harbor_prod.harbor_robot_account.npp-robot must be replaced
-/+ resource "harbor_robot_account" "npp-robot" {
      ~ id          = "/projects/3/robots/102" -> (known after apply)
      ~ name        = "robot_npp+npp" -> "npp" # forces replacement
      ~ project_id  = "/projects/0" -> "/projects/3" # forces replacement
      ~ robot_id    = "102" -> (known after apply)
      + token       = (sensitive value)
        # (2 unchanged attributes hidden)
    }

Expected behavior
Any prefix should work and not lead to replacing the robot account in terraform.

Thanks for your work on this project!

Support Limited Guest Role

Is your feature request related to a problem? Please describe.
Currently, I can't specify Limited guest in the string type role of project_member_group and project_member_user

Error: "role" must be either projectadmin, developer, guest or master, got: limitedguest

Describe the solution you'd like
Support limited guest on role

Describe alternatives you've considered
There is no terraform alternative, but manually set this up on portal

Additional context

Authentication is not working for harbor instance which is behind an OIDC provider

Hello,
We have a Harbor instance running behind an OIDC provider/SSO. When I am trying to import or provision any object, I am constantly getting 401 UNAUTHORIZED even though username/password is correct.

Code

terraform {
  required_providers {
    harbor = {
      source = "BESTSELLER/harbor"
      version = "2.0.5"
    }
  }
}

provider "harbor" {
  url      = "URL"
  username = "USERNAME"
  password = "PASSWORD"
}

resource "harbor_project" "mbd-otr-de" {}

Output

Error: [ERROR] unexpected status code got: 401 expected: 200
 {"errors":[{"code":"UNAUTHORIZED","message":"UnAuthorized"}]}

the project contains repositories, can not be deleted

Describe the bug
While destroying the project resource using terraform destroy which is replicated once as per cron schedule, I am unable to destroy the project resource.

To Reproduce

  1. create a project.
resource "harbor_project" "main" {
  name                   = "jenkins"
  public                 = true
  vulnerability_scanning = true
}
  1. create registry and replication for the same project.
resource "harbor_registry" "pull" {
  provider_name = "docker-hub"
  name          = "DockerHub"
  endpoint_url  = "https://hub.docker.com"
}

resource "harbor_replication" "replication_pull" {
  name     = "Jenkins"
  action   = "pull"
  schedule = "0 0 2 * * *"
  filters {
    name     = "jenkins/jenkins"
    tag      = "2.*.{0,1,2,3,4,5,6,7,8,9}-lts-jdk11"
    resource = "image"
  }
  registry_id = harbor_registry.pull.registry_id
  1. run replicate from GUI and then run terraform destroy

Expected behavior
terraform should be able to destroy the project resource.

Screenshots
Screen Shot 2021-04-30 at 11 32 53 PM

Unable to create a retention policy - `METHOD_NOT_ALLOWED`

Describe the bug
When trying to create a retention policy, I'm getting the following error:

{"errors":[{"code":"METHOD_NOT_ALLOWED","message":"method PUT is not allowed, but [POST] are"}]}

To Reproduce
Steps to reproduce the behavior:

resource "harbor_project" "test" {
    name                    = "test"
    public                  = true
    vulnerability_scanning  = false
    enable_content_trust    = false
}


resource "harbor_retention_policy" "test" {
     scope = harbor_project.test.id
     schedule = "daily"
     rule {
         n_days_since_last_push = 30
         repo_matching = "**"
         tag_matching = "**"
     }
}

Expected behavior
Policy gets created.

Additional context

terraform version
Terraform v0.14.7
+ provider registry.terraform.io/bestseller/harbor v3.1.0
Harbor Version v2.2.0-ec0ba116

Add project tag immutability options

Is your feature request related to a problem? Please describe.
Being able to configure tag immutability rules for projects through Terraform would be very useful.

Describe the solution you'd like
An option to define tag immutability rules for a Harbor project.

Describe alternatives you've considered
Using the API / UI.

Get Project data object error

Hello,

I try to get data object information for library project by this way:

data "harbor_project" "main" {
    name    = "library" 
}

output "project_id" {
    value = data.harbor_project.main.id
}

but I got this error:

Error: strconv.ParseBool: parsing "": invalid syntax

  on template.tf line 49, in data "harbor_project" "main":
  49: data "harbor_project" "main" {
  • version : 2.0.5

tag_excluding not managed

Describe the bug
When setting retention rules to tag_excluding, rule is created but without decoration.

Expected behavior
Add tag_excluding management

Additional context
In client/retention.go, tag_matching is tested but not tag_excluding

Harbor Garbage Collection configuration

Is your feature request related to a problem? Please describe.
It's not possible to configure with this TF provider, garbage collect on Harbor

Describe the solution you'd like
Be able to configure this with Terraform :
image

Robot accounts not compatible with Harbor v2.2.0

Harbor v2.2.0 adds project name to name of the robot account causing replacement on next apply

  # harbor_robot_account.account must be replaced
-/+ resource "harbor_robot_account" "account" {
      ~ id          = "/projects/24/robots/2951" -> (known after apply)
      ~ name        = "vera+read" -> "read" # forces replacement
      ~ project_id  = "/projects/0" -> "/projects/24" # forces replacement
      ~ robot_id    = "2951" -> (known after apply)
      + token       = (sensitive value)
        # (2 unchanged attributes hidden)
    }

Change in robot controller

	name := r.Name
	// for the project level robot, set the name pattern as projectname+robotname, and + is a illegal character.
	if r.Level == LEVELPROJECT {
		name = fmt.Sprintf("%s+%s", r.ProjectName, r.Name)
	}

Add support for System Level Robot Accounts

Is your feature request related to a problem? Please describe.
Harbor 2.2.0 (current only a release candidate) added the feature of System Level Robot Accounts. It would be beneficial when those accounts could be managed with this provider, too.

Describe the solution you'd like
Adjusting the currently implemented harbor_robot_account resource to allow configuring system level robot accounts as well, or adding a new resource type for system level robots.

Describe alternatives you've considered
Managing system level robot accounts manually and outside of terraform.

Thanks for your work on this project!

access_key should be access_secret in documentation

Describe the bug

  • In the documentation of the registry.md when providing the argument access_key is giving issues, I went to code and analyzed the go template and saw that the argument should be access_secret instead of access_key.

https://github.com/BESTSELLER/terraform-provider-harbor/blob/c949b465c46aa82b331541cab9fe44fcf5b02545/provider/resource_registry.go#L36

https://github.com/BESTSELLER/terraform-provider-harbor/blob/master/docs/resources/registry.md which has a line

  • access_key - (Optional) The password / access keys / token for the external container register

Missing resources must be recreated

Describe the bug
When a resource is not found (manually deleted for example), terraform apply failed.
According to terraform doc :
When you create something in Terraform but delete it manually, Terraform should gracefully handle it. If the API returns an error when the resource doesn't exist, the read function should check to see if the resource is available first. If the resource isn't available, the function should set the ID to an empty string so Terraform "destroys" the resource in state. The following code snippet is an example of how this can be implemented; you do not need to add this to your configuration for this tutorial.

Expected behavior
Resource must be recreated is not found

Creating 'internal' users

Hi.
Thanks a lot for your provider.
Do you have any plans to write a resource for creating internal users?

Terraform run fails with "quota {id} not found"

Describe the bug

When updating from a previous version of this provider to v2.0.10, terraform apply could fail, if quota_per_project_enable is set to false in Harbor.

To Reproduce

  1. Have a Harbor 2.0 installation set-up with v0.6.2 of terraform-provider-harbor
  2. have quota_per_project_enable set to false in Harbor
  3. Create a few projects in harbor using the provider
  4. Update Harbor to 2.2 and use v2.0.10 of terraform-provider-harbor
  5. Run the terraform stack again
  6. The following error occurs
    Error: [ERROR] unexpected status code got: 404 expected: 200
     \{"errors":[ {"code":"NOT_FOUND","message":"quota 5 not found"}
    ]}
    

Expected behavior

Terraform runs as before โ€“ and applies any necessary changes without errors.

Additional context

The underlying problem is that since 9fbab5e it is asumed, that a resource /quotas/5 exists. This is not the case if quota_per_project_enable is false.

There is also no way to add a quota resource for an existing project in harbor (there is no POST endpoint)
Auswahl_001

It seems the issue can not be fixed without removing and recreating all existing projects. This would involve either dropping or migrating all container images in this project.

Possible Solution

The easy solution is to allow the PUT /quotas/{id} request to fail silently when storage_quota is set to -1 anyway. Maybe add an error description if it is set to a value, but quota_per_project_enable is not enabled.

The better solution could be to detect if quota_per_project_enable is enabled in harbor and act accordingly.

Resource harbor_group unsupported

It would be good if we can create resource harbor_group. We are managing Harbor users via LDAP groups, so we cannot use this provider for this purposes.

Resource harbor_replication don't fill name in Source resource filter

I have specified resource for replication policy below, when I apply it, the replication policy is created in web UI, but the name in section Source resource filter is empty even it is specified in resource. It should be test/**.

resource "harbor_replication" "test" {
  name        = "test"
  action      = "push"
  registry_id = harbor_registry.test-harbor.registry_id
  override    = true
  enabled     = true
  filters {
    name      = "test/**"
    resource = "artifact"
  }
}

Harbor version: v2.1.1-5f52168e

Terraform version: v0.14.3

Project quota not updated

Describe the bug
Hi, when I create Harbor project for the first time with terraform, I am assigning to the project project quota of 5 GB. Everything is working fine, but then when I want to change the value of project quota to different value, terraform tells me that one resource is updated, but when I go to Harbor UI, project quota is not updated.

I can change the project quota manually in Harbor UI, but not with terraform and this provider.

Harbor

  • Version: v2.1.3-b6de84c5
  • Ubuntu 18.04.5 LTS

Terraform

$ terraform version
Terraform v0.14.3
+ provider registry.terraform.io/bestseller/harbor v1.2.0

Your version of Terraform is out of date! The latest version
is 0.14.4. You can update by downloading from https://www.terraform.io/downloads.htm

Error when trying to configure of LDAP via resource harbor_config_auth

I did fresh installation of Harbor v2.1.3. I have used this provider to configure LDAP with local admin account from Harbor.

My configuration of LDAP is following

resource "harbor_config_auth" "ldap" {
  auth_mode             = "ldap_auth"
  ldap_url              = "ldaps://example.local:3269"
  ldap_search_dn        = "CN=service_account,OU=srv,DC=example,DC=local"
  ldap_search_password  = var.ldap_search_password
  ldap_base_dn          = "DC=example,DC=local"
  ldap_uid              = "sAMAccountName"
  ldap_scope            = 2
  ldap_group_base_dn    = "OU=Harbor,OU=Apps,DC=example,DC=local"
  ldap_group_admin_dn   = "CN=App_Harbor_Admins,OU=Harbor,OU=Apps,DC=example,DC=local"
  ldap_group_membership = "memberof"
  ldap_group_gid        = "cn"
  ldap_group_scope      = 2
  ldap_verify_cert      = false
}

When I apply the resource, I receive this error message

Error: [ERROR] unexpected status code got: 400 expected: 200 
 {"errors":[{"code":"BAD_REQUEST","message":"configure item is not defined in metadata, item name: ldap_group_id"}]}

I tried to add metadata ldap_group_id = "" (empty string because I don't know what are valid values) to resource harbor_config_auth, but then I receive this error message

Error: Unsupported argument

  on administration_configuration.tf line 13, in resource "harbor_config_auth" "ldap":
  13:   ldap_group_id        = ""

An argument named "ldap_group_id" is not expected here. Did you mean
"ldap_group_uid"?

Am I doing something wrong? I tried to follow the documentation, but currently I am not possible to configure LDAP via this provider.

Allow multiple actions for robot user

Current situation
A robot user can be created but only with a single action

resource "haror_project" "main" {
    name = "main"
}

resource "harbor_robot_account" "account" {
  name        = "${harbor_project.main.name}"
  description = "Robot account used to push images to harbor"
  project_id  = harbor_project.main.id
  action      = "push"
}

In harbor a robot account can be created with more than one action.

  • push (docker)
  • read (helm)
  • create (helm)

Desired situation
Please enable creation of a robot account allowing multiple acctions. For example like this.

resource "haror_project" "main" {
    name = "main"
}

resource "harbor_robot_account" "account" {
  name        = "${harbor_project.main.name}"
  description = "Robot account used to push images to harbor"
  project_id  = harbor_project.main.id
  action      = ["push","create","read"]
}

To be changed
As far as i understood the RobotBodyAccess in RobotBody must be adjusted to send a json with multiple actions instead of a single action like this.

{
  "name": "testrobot",
  "expires_at": -1,
  "description": "t",
  "access": [
    {
      "resource": "/project/3/repository",
      "action": "push"
    },
    {
      "resource": "/project/3/helm-chart",
      "action": "read"
    },
    {
      "resource": "/project/3/helm-chart-version",
      "action": "create"
    }
  ]
}

[update documentation] custom cron expressions for harbor_interrogation_services

Current state
The Interrogation Services can be configured to use preconfigured schedules like described here

It can also use custom cron expressions like in the UI and API but it is not mentioned in the documentation.
image

Request
It would be very good to know this feature is implemented in case you need a more specific cron expression or at a different time during the day.

Unsupported role "Maintainer"

According this documentation for version of Harbor 2.1.0, supported type roles for project are:

  • Limited Guest,
  • Guest,
  • Developer,
  • Maintainer,
  • ProjectAdmin.

When I am trying to create user with maintainer role for project, it throws me error:
Error: "role" must be either projectadmin, developer, guest, limitedguest or master, got: maintainer.

So I assume that the master role was removed and was replaced by maintainer.

Replication description is not propagated

Describe the bug

When creating a harbor_replication with the description argument set, the resulting replication in Harbor has an empty description.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new harbor_replication resource with description set to a non-empty string
  2. terraform apply
  3. View replication in Harbor

Expected behavior

The description argument should be propagated to Harbor.

ldap mismatch fields

Describe the bug
2 fields have wrong management

  • ldap_group_membership is mapped to ldap_group_attribute_name and must be ldap_group_membership_attribute
  • ldat_group_gid is mapped to ldap_group_gid which does not exists in harbor

Expected behavior

  • ldap_group_membership must be ldap_group_membership_attribute
  • ldat_group_gid must be ldap_group_attribute_name

Quay registry creation

Describe the bug

Hey first of all: great project!

This bug/feature request is for quay.io support. Note that the enum exists at https://github.com/BESTSELLER/terraform-provider-harbor/blob/41d356fdea6521bf16c594a7246975567baed0ff/client/registry.go#L40 but it is still impossible to create quay registries in Terraform even though it's possible from the UI.

To Reproduce
Define a resource for a quay registry.

resource "harbor_registry" "quay" {
  provider_name = "quay"
  name          = "quay"
  endpoint_url  = "https://quay.io"
}

This will cause:

Error: [ERROR] unexpected status code got: 400 expected: 201 
 {"errors":[{"code":"BAD_REQUEST","message":"the registry is unhealthy"}]}

Note that even if access is setup reasonably (access_id: "json_file" and a valid cli_password/username as per here it will still fail. It will also fail if access_id: "".

Expected behavior
A valid registry

Additional context
Harbor auto-fills the "access_id" in the web UI as "json_file" and throws the same error until the auto-filled value is removed or a valid "access_secret" is passed. In Terraform, I attempted to overwrite this default value with an empty string but that does not work unfortunately.

Filters in the replication are not populating in harbor UI

Describe the bug
I used below code to create registry and replication according to documentation and the filters are populating during the tfplan step but when I see in the UI for the same replication the filters are not present.

To Reproduce
Steps to reproduce the behavior:

provider "harbor" {
  url      = "xxxxx"
  username = "admin"
  password = "xxxx"
}

# registry configuration pull
resource "harbor_registry" "pull" {
  
  provider_name = "docker-hub"
  name          = "Docker Hub"
  endpoint_url  = "https://hub.docker.com"
}

# replication pull based
resource "harbor_replication" "replication_pull" {
  name     = "Jenkins"
  action   = "pull"
  schedule = "0 0 2 * * *"
  filters {
    name     = "jenkins/jenkins"
    tag      = "2.*.{0,1,2,3,4,5,6,7,8,9}-lts-jdk11"
    resource = "image"
  }
  registry_id = harbor_registry.pull.registry_id
}

Use the above configuration with terraform apply

Screenshots
Screen Shot 2021-01-29 at 4 04 57 PM

Expected behavior
Filters should reflect in harbor replication.

Desktop (please complete the following information):

  • OS: Linux

Smartphone (please complete the following information):
NA

Additional context
NA

retention policy are not deleted in harbor but are in the tfstate

Describe the bug
retention policy are not deleted in harbor but are in the tfstate

  # module.harbor_replication[0].harbor_retention_policy.main[0] will be destroyed
  - resource "harbor_retention_policy" "main" {
      - id       = "/retentions/103" -> null
      - schedule = "daily" -> null
      - scope    = "/projects/531" -> null

      - rule {
          - always_retain          = false -> null
          - disabled               = false -> null
          - most_recently_pulled   = 0 -> null
          - most_recently_pushed   = 0 -> null
          - n_days_since_last_pull = 1 -> null
          - n_days_since_last_push = 0 -> null
          - repo_matching          = "**" -> null
          - tag_matching           = "**" -> null
          - untagged_artifacts     = true -> null
        }
    }

Plan: 0 to add, 0 to change, 1 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

module.harbor_replication[0].harbor_retention_policy.main[0]: Destroying... [id=/retentions/103]
module.harbor_replication[0].harbor_retention_policy.main[0]: Destruction complete after 0s

The retention policy is still there :
image

And if I re-create it with TF it failed :

  # module.harbor_replication[0].harbor_retention_policy.main[0] will be created
  + resource "harbor_retention_policy" "main" {
      + id       = (known after apply)
      + schedule = "daily"
      + scope    = "/projects/531"

      + rule {
          + always_retain          = false
          + disabled               = false
          + n_days_since_last_pull = 1
          + repo_matching          = "**"
          + tag_matching           = "**"
          + untagged_artifacts     = true
        }
    }

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

module.harbor_replication[0].harbor_retention_policy.main[0]: Creating...

Error: [ERROR] unexpected status code got: 400 expected: 201 
 {"errors":[{"code":"BAD_REQUEST","message":"project 531 already has retention policy 103"}]}

Add Changelog

Is your feature request related to a problem? Please describe.
Hard to tell without going through commits as what has changed between releases

Describe the solution you'd like
A CHANGELOG.md managed that follows KeepAChangeLog.com. Ideally this would be attached to each release's details.

Describe alternatives you've considered
Going through commits

Additional context
See most open source projects for examples.

issue while creating email configuration

Hi,
Thanks for this project!
I had the following issue when trying to configure email.

Describe the bug
I tried to use: harbor_config_email, but I got this error and a stacktrace :
panic: interface conversion: interface {} is string, not int

To Reproduce

  1. add a harbor_config_email resources with :
email_host
email_port
email_username
email_password
email_from
email_ssl
  1. terraform apply

Expected behavior
Email configuration is applied on harbor

Desktop (please complete the following information):

  • OS: windows10
  • Terraform v0.13.5
  • provider registry.terraform.io/bestseller/harbor v0.5.1

strconv.ParseBool: parsing "": invalid syntax on Project Import

Describe the bug
When importing a project that does not have scanning enabled, an error will occur when trying to import the project. The error goes away after manually configuring the project to enable scanning.

To Reproduce
Steps to reproduce the behavior:

  1. Manually create project in Harbor that does not have project scanning enabled
  2. Try to import the project utilizing the provider
  3. See error. strconv.ParseBool: parsing "": invalid syntax

Expected behavior
Project is successfully imported

Harbor Version: v2.1.1-5f52168e
Provider version: v2.0.10

Cannot import registry

According this documentation I should be able to import existing registry which already exists in Harbor.

I try this command to import the registry
terraform import harbor_registry.docker_hub /registries/1

It throws me
Error: resource harbor_registry doesn't support import

project if not exist => 404

Describe the bug
when I do terraform plan or apply I always get this if the project doesn't exist

Error: [ERROR] unexpected status code got: 404 expected: 200
 {"errors":[{"code":"NOT_FOUND","message":"project test not found"}]}

harbor_garbage_collection not working "Error: unexpected end of JSON input"

When trying to test the harbor_garbage_collection resource on a local harbor server, it ends with the following error :

$ cat <<EOF >> root.tf
terraform {
  required_version = ">= 0.12"
  required_providers {
    harbor = {
      source  = "BESTSELLER/harbor"
      version = "~> 3.1.1"
    }
  }
}

provider "harbor" {
  url      = "http://localhost:30000"
  username = "admin"
  password = "admin"
}

resource "harbor_garbage_collection" "main" {
  schedule        = "daily"
  delete_untagged = true
}
EOF


$ terraform apply --auto-approve      
harbor_garbage_collection.main: Creating...

Error: unexpected end of JSON input

  on root.tf line 17, in resource "harbor_garbage_collection" "main":
  17: resource "harbor_garbage_collection" "main" {

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.5
  • Terraform : v0.14.10

Additional context

Debug logs

TF_LOG=DEBUG terraform apply --auto-approve
2021/04/13 11:41:05 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.

2021/04/13 11:41:05 [INFO] Terraform version: 0.14.10
2021/04/13 11:41:05 [INFO] Go runtime version: go1.15.6
2021/04/13 11:41:05 [INFO] CLI args: []string{"/home/guillaume/.tfenv/versions/0.14.10/terraform", "apply", "--auto-approve"}
2021/04/13 11:41:05 [DEBUG] Attempting to open CLI config file: /home/guillaume/.terraformrc
2021/04/13 11:41:05 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021/04/13 11:41:05 [DEBUG] checking for credentials in "/home/guillaume/.terraform.d/plugins"
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/04/13 11:41:05 [DEBUG] will search for provider plugins in /home/guillaume/.terraform.d/plugins
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory /home/guillaume/.local/share/terraform/plugins
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory /usr/share/ubuntu/terraform/plugins
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2021/04/13 11:41:05 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins
2021/04/13 11:41:05 [INFO] CLI command args: []string{"apply", "--auto-approve"}
2021/04/13 11:41:05 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
Use TF_LOG=TRACE to see Terraform's internal logs.

2021/04/13 11:41:05 [DEBUG] New state was assigned lineage "45951b85-b2a2-92cf-ea83-b72d59f15180"
2021/04/13 11:41:05 [DEBUG] checking for provisioner in "."
2021/04/13 11:41:05 [DEBUG] checking for provisioner in "/home/guillaume/.tfenv/versions/0.14.10"
2021/04/13 11:41:05 [DEBUG] checking for provisioner in "/home/guillaume/.terraform.d/plugins"
2021/04/13 11:41:05 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory
2021/04/13 11:41:05 [INFO] backend/local: starting Apply operation
2021-04-13T11:41:05.594+0200 [INFO] plugin: configuring client automatic mTLS
2021-04-13T11:41:05.635+0200 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 args=[.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1]
2021-04-13T11:41:05.636+0200 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374015
2021-04-13T11:41:05.636+0200 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1
2021-04-13T11:41:05.659+0200 [INFO] plugin.terraform-provider-harbor_v3.1.1: configuring server automatic mTLS: timestamp=2021-04-13T11:41:05.659+0200
2021-04-13T11:41:05.753+0200 [DEBUG] plugin: using plugin: version=5
2021-04-13T11:41:05.753+0200 [DEBUG] plugin.terraform-provider-harbor_v3.1.1: plugin address: address=/tmp/plugin427380951 network=unix timestamp=2021-04-13T11:41:05.753+0200
2021-04-13T11:41:05.861+0200 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-04-13T11:41:05.862+0200 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374015
2021-04-13T11:41:05.862+0200 [DEBUG] plugin: plugin exited
2021/04/13 11:41:05 [INFO] terraform: building graph: GraphTypeValidate
2021/04/13 11:41:05 [DEBUG] ProviderTransformer: "harbor_garbage_collection.main" (*terraform.NodeValidatableResource) needs provider["registry.terraform.io/bestseller/harbor"]
2021/04/13 11:41:05 [DEBUG] ReferenceTransformer: "harbor_garbage_collection.main" references: []
2021/04/13 11:41:05 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/bestseller/harbor"]" references: []
2021/04/13 11:41:05 [DEBUG] Starting graph walk: walkValidate
2021-04-13T11:41:05.864+0200 [INFO] plugin: configuring client automatic mTLS
2021-04-13T11:41:05.919+0200 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 args=[.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1]
2021-04-13T11:41:05.921+0200 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374024
2021-04-13T11:41:05.921+0200 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1
2021-04-13T11:41:05.932+0200 [INFO] plugin.terraform-provider-harbor_v3.1.1: configuring server automatic mTLS: timestamp=2021-04-13T11:41:05.931+0200
2021-04-13T11:41:05.997+0200 [DEBUG] plugin.terraform-provider-harbor_v3.1.1: plugin address: address=/tmp/plugin361514411 network=unix timestamp=2021-04-13T11:41:05.997+0200
2021-04-13T11:41:05.998+0200 [DEBUG] plugin: using plugin: version=5
2021-04-13T11:41:06.121+0200 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-04-13T11:41:06.125+0200 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374024
2021-04-13T11:41:06.125+0200 [DEBUG] plugin: plugin exited
2021/04/13 11:41:06 [INFO] backend/local: apply calling Plan
2021/04/13 11:41:06 [INFO] terraform: building graph: GraphTypePlan
2021/04/13 11:41:06 [DEBUG] ProviderTransformer: "harbor_garbage_collection.main (expand)" (*terraform.nodeExpandPlannableResource) needs provider["registry.terraform.io/bestseller/harbor"]
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "harbor_garbage_collection.main (expand)" references: []
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/bestseller/harbor"]" references: []
2021/04/13 11:41:06 [DEBUG] Starting graph walk: walkPlan
2021-04-13T11:41:06.127+0200 [INFO] plugin: configuring client automatic mTLS
2021-04-13T11:41:06.178+0200 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 args=[.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1]
2021-04-13T11:41:06.179+0200 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374033
2021-04-13T11:41:06.179+0200 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1
2021-04-13T11:41:06.192+0200 [INFO] plugin.terraform-provider-harbor_v3.1.1: configuring server automatic mTLS: timestamp=2021-04-13T11:41:06.191+0200
2021-04-13T11:41:06.272+0200 [DEBUG] plugin: using plugin: version=5
2021-04-13T11:41:06.272+0200 [DEBUG] plugin.terraform-provider-harbor_v3.1.1: plugin address: address=/tmp/plugin896682156 network=unix timestamp=2021-04-13T11:41:06.272+0200
2021/04/13 11:41:06 [DEBUG] Resource instance state not found for node "harbor_garbage_collection.main", instance harbor_garbage_collection.main
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "harbor_garbage_collection.main" references: []
2021/04/13 11:41:06 [DEBUG] refresh: harbor_garbage_collection.main: no state, so not refreshing
2021-04-13T11:41:06.414+0200 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-04-13T11:41:06.416+0200 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374033
2021-04-13T11:41:06.416+0200 [DEBUG] plugin: plugin exited
2021/04/13 11:41:06 [INFO] backend/local: apply calling Apply
2021/04/13 11:41:06 [INFO] terraform: building graph: GraphTypeApply
2021/04/13 11:41:06 [DEBUG] Resource state not found for node "harbor_garbage_collection.main", instance harbor_garbage_collection.main
2021/04/13 11:41:06 [DEBUG] ProviderTransformer: "harbor_garbage_collection.main (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/bestseller/harbor"]
2021/04/13 11:41:06 [DEBUG] ProviderTransformer: "harbor_garbage_collection.main" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/bestseller/harbor"]
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "harbor_garbage_collection.main (expand)" references: []
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "harbor_garbage_collection.main" references: []
2021/04/13 11:41:06 [DEBUG] ReferenceTransformer: "provider["registry.terraform.io/bestseller/harbor"]" references: []
2021/04/13 11:41:06 [DEBUG] Starting graph walk: walkApply
2021-04-13T11:41:06.418+0200 [INFO] plugin: configuring client automatic mTLS
2021-04-13T11:41:06.474+0200 [DEBUG] plugin: starting plugin: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 args=[.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1]
2021-04-13T11:41:06.475+0200 [DEBUG] plugin: plugin started: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374042
2021-04-13T11:41:06.475+0200 [DEBUG] plugin: waiting for RPC address: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1
2021-04-13T11:41:06.485+0200 [INFO] plugin.terraform-provider-harbor_v3.1.1: configuring server automatic mTLS: timestamp=2021-04-13T11:41:06.485+0200
2021-04-13T11:41:06.561+0200 [DEBUG] plugin: using plugin: version=5
2021-04-13T11:41:06.561+0200 [DEBUG] plugin.terraform-provider-harbor_v3.1.1: plugin address: address=/tmp/plugin533833352 network=unix timestamp=2021-04-13T11:41:06.561+0200
harbor_garbage_collection.main: Creating...
2021/04/13 11:41:06 [DEBUG] EvalApply: ProviderMeta config value set
2021/04/13 11:41:06 [DEBUG] harbor_garbage_collection.main: applying the planned Create change
2021/04/13 11:41:06 [DEBUG] harbor_garbage_collection.main: apply errored, but we're indicating that via the Error pointer rather than returning it: unexpected end of JSON input

Error: unexpected end of JSON input

2021-04-13T11:41:06.685+0200 [WARN] plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
on root.tf line 17, in resource "harbor_garbage_collection" "main":
17: resource "harbor_garbage_collection" "main" {

2021-04-13T11:41:06.692+0200 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/bestseller/harbor/3.1.1/linux_amd64/terraform-provider-harbor_v3.1.1 pid=374042
2021-04-13T11:41:06.692+0200 [DEBUG] plugin: plugin exited

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.