Skip to content

Commit

Permalink
Merge pull request #177 from jfrog/GH-34-docker-remote-support
Browse files Browse the repository at this point in the history
GH-34 docker remote support
  • Loading branch information
chb0github authored Oct 14, 2021
2 parents eb8fd99 + b8c1fab commit b6ca7b7
Show file tree
Hide file tree
Showing 17 changed files with 1,170 additions and 448 deletions.
113 changes: 113 additions & 0 deletions docs/resources/artifactory_remote_docker_repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Artifactory Remote Repository Resource

Provides an Artifactory remote `docker` repository resource. This provides docker specific fields and is the only way to get them

### Passwords
Passwords can only be used when encryption is turned off (https://www.jfrog.com/confluence/display/RTF/Artifactory+Key+Encryption).
Since only the artifactory server can decrypt them it is impossible for terraform to diff changes correctly.

To get full management, passwords can be decrypted globally using `POST /api/system/decrypt`. If this is not possible,
the password diff can be disabled per resource with-- noting that this will require resources to be tainted for an update:
```hcl
lifecycle {
ignore_changes = ["password"]
}
```

## Example Usage

```hcl
# Create a new Artifactory remote docker repository called my-remote-docker
resource "artifactory_remote_docker_repository" "my-remote-docker" {
key = "my-remote-docker"
package_type = "docker"
external_dependencies_patterns = ["**/hub.docker.io/**","**/bintray.jfrog.io/**"]
hard_fail = true
allow_any_host_auth = true
external_dependencies_enabled = true
socket_timeout_millis = 25000
retrieval_cache_period_seconds = 70
enable_token_authentication = true
property_sets = ["artifactory"]
proxy = ""
store_artifacts_locally = true
unused_artifacts_cleanup_period_hours = 96
username = "user"
content_synchronisation {
enabled = false
}
missed_cache_period_seconds = 2500
excludes_pattern = ""
url = "https://hub.docker.io/"
share_configuration = true
unused_artifacts_cleanup_period_enabled = true
client_tls_certificate = ""
xray_index = true
block_mismatching_mime_types = true
offline = true
local_address = ""
repo_layout_ref = "docker-default"
notes = "notes"
enable_cookie_management = true
synchronize_properties = true
assumed_offline_period_secs = 96
block_pushing_schema1 = true
blacked_out = true
bypass_head_requests = true
includes_pattern = "**/*"
}
```

## Argument Reference

Arguments have a one to one mapping with the [JFrog API](https://www.jfrog.com/confluence/display/RTF/Repository+Configuration+JSON). The following arguments are supported:

* `key` - (Required) The repository identifier. Must be unique system-wide
* `package_type` - (Required) - self-explanatory
* `url` - (Required) - the remote repo URL. You kinda don't have a remote repo without it
* `allow_any_host_auth` - (Optional) Also known as 'Lenient Host Authentication', Allow credentials of this repository to be used on requests redirected to any other host.
* `assumed_offline_period_secs` - (Optional)
* `blacked_out` - (Optional) (A.K.A 'Ignore Repository' on the UI) When set, the repository or its local cache do not participate in artifact resolution.
* `block_mismatching_mime_types` - (Optional) Before caching an artifact, Artifactory first sends a HEAD request to the remote resource. In some remote resources, HEAD requests are disallowed and therefore rejected, even though downloading the artifact is allowed. When checked, Artifactory will bypass the HEAD request and cache the artifact directly using a GET request.
* `block_pushing_schema` - (Optional) When set, Artifactory will block the pulling of Docker images with manifest v2 schema 1 from the remote repository (i.e. the upstream). It will be possible to pull images with manifest v2 schema 1 that exist in the cache.
* `bypass_head_requests` - (Optional)
* `client_tls_certificate` - (Optional)
* `content_synchronisation` - (Optional)
* `description` - (Optional)
* `enable_cookie_management` - (Optional) Enables cookie management if the remote repository uses cookies to manage client state.
* `enable_token_authentication` - (Optional) Enable token (Bearer) based authentication.
* `enabled` - (Optional)
* `excludes_pattern` - (Optional)
* `external_dependencies_enabled` - (Optional) Also known as 'Foreign Layers Caching' on the UI
* `external_dependencies_patterns` - (Optional) An allow list of Ant-style path patterns that determine which remote VCS roots Artifactory will
follow to download remote modules from, when presented with 'go-import' meta tags in the remote repository response. " +
By default, this is set to '**', which means that remote modules may be downloaded from any external VCS source.
* `hard_fail` - (Optional)
* `includes_pattern` - (Optional)
* `local_address` - (Optional)
* `missed_cache_period_seconds` - (Optional)
* `notes` - (Optional)
* `offline` - (Optional) If set, Artifactory does not try to fetch remote artifacts. Only locally-cached artifacts are retrieved.
* `password` - (Optional)
* `propagate_query_params` - (Optional)
* `property_sets` - (Optional)
* `proxy` - (Optional)
* `repo_layout_ref` - (Optional)
* `retrieval_cache_period_seconds` - (Optional)
* `share_configuration` - (Optional)
* `socket_timeout_millis` - (Optional)
* `store_artifacts_locally` - (Optional) When set, the repository should store cached artifacts locally. When not set, artifacts are not stored locally, and direct repository-to-client streaming is used. This can be useful for multi-server setups over a high-speed LAN, with one Artifactory caching certain data on central storage, and streaming it directly to satellite pass-though Artifactory servers.
* `synchronize_properties` - (Optional) When set, remote artifacts are fetched along with their properties.
* `unused_artifacts_cleanup_period_enabled` - (Optional)
* `unused_artifacts_cleanup_period_hours` - (Optional)
* `username` - (Optional)
* `xray_index` - (Optional)


## Import

Remote repositories can be imported using their name, e.g.

```
$ terraform import artifactory_remote_repository.my-remote my-remote
```
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/jfrog/terraform-provider-artifactory

require (
github.com/go-resty/resty/v2 v2.6.0
github.com/go-resty/resty/v2 v2.6.1-0.20210916045937-1792d629c3c6
github.com/google/go-querystring v1.0.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0
github.com/jfrog/jfrog-client-go v0.23.1
github.com/stretchr/testify v1.7.0
Expand Down
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-resty/resty/v2 v2.4.0 h1:s6TItTLejEI+2mn98oijC5w/Rk2YU+OA6x0mnZN6r6k=
github.com/go-resty/resty/v2 v2.4.0/go.mod h1:B88+xCTEwvfD94NOuE6GS1wMlnoKNY8eEiNizfNwOwA=
github.com/go-resty/resty/v2 v2.6.0 h1:joIR5PNLM2EFqqESUjCMGXrWmXNHEU9CEiK813oKYS4=
github.com/go-resty/resty/v2 v2.6.0/go.mod h1:PwvJS6hvaPkjtjNg9ph+VrSD92bi5Zq73w/BIH7cC3Q=
github.com/go-resty/resty/v2 v2.6.1-0.20210916045937-1792d629c3c6 h1:oWZNNnHfHAE4z8uYHkuEqzueDjSgMNB+e80RCbrEyv8=
github.com/go-resty/resty/v2 v2.6.1-0.20210916045937-1792d629c3c6/go.mod h1:fUytuqHwz8P28muStrLRS1B/V95zeSbTTR/lCHDSx3g=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
Expand Down Expand Up @@ -494,11 +492,12 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 h1:lwlPPsmjDKK0J6eG6xDWd5XPehI0R024zxjDnw3esPA=
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210913180222-943fd674d43e h1:+b/22bPvDYt4NPDcy4xAGCmON713ONAWFeY3Z7I3tR8=
golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
Expand Down Expand Up @@ -554,6 +553,7 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -571,6 +571,8 @@ golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
6 changes: 3 additions & 3 deletions pkg/artifactory/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

var Version = "2.3.1"

const repositoriesEndpoint = "artifactory/api/repositories/"
// Version for some reason isn't getting updated by the linker
var Version = "2.6.9"

// Provider Artifactory provider that supports configuration via username+password or a token
// Supported resources are repos, users, groups, replications, and permissions
Expand Down Expand Up @@ -65,6 +64,7 @@ func Provider() *schema.Provider {
ResourcesMap: map[string]*schema.Resource{
"artifactory_local_repository": resourceArtifactoryLocalRepository(),
"artifactory_remote_repository": resourceArtifactoryRemoteRepository(),
"artifactory_remote_docker_repository": resourceArtifactoryRemoteDockerRepository(),
"artifactory_virtual_repository": resourceArtifactoryVirtualRepository(),
"artifactory_virtual_maven_repository": resourceArtifactoryMavenVirtualRepository(),
"artifactory_virtual_go_repository": resourceArtifactoryGoVirtualRepository(),
Expand Down
Loading

0 comments on commit b6ca7b7

Please sign in to comment.