resource_remote: add artifactapi_remote_cargo #21

Merged
benvin merged 2 commits from benvin/remote-cargo into main 2026-10-09 21:48:45 +11:00
6 changed files with 31 additions and 2 deletions
+1
View File
@@ -63,6 +63,7 @@ Available resource types:
- `artifactapi_remote_puppet` - `artifactapi_remote_puppet`
- `artifactapi_remote_terraform` - `artifactapi_remote_terraform`
- `artifactapi_remote_goproxy` - `artifactapi_remote_goproxy`
- `artifactapi_remote_cargo`
- `artifactapi_remote_github_rpm` - `artifactapi_remote_github_rpm`
- `artifactapi_remote_github_deb` - `artifactapi_remote_github_deb`
- `artifactapi_remote_github_alpine` - `artifactapi_remote_github_alpine`
@@ -0,0 +1,23 @@
terraform {
required_providers {
artifactapi = {
source = "git.unkin.net/unkin/artifactapi"
version = "0.0.1"
}
}
}
provider "artifactapi" {
endpoint = "https://artifactapi.example.com"
}
# Cargo remote proxies a crates.io sparse registry.
# The provider knows index files are mutable; .crate downloads are immutable.
resource "artifactapi_remote_cargo" "crates_io" {
name = "crates-io"
base_url = "https://index.crates.io"
description = "crates.io sparse registry"
immutable_ttl = 0
mutable_ttl = 300
}
+1
View File
@@ -68,6 +68,7 @@ func (p *ArtifactAPIProvider) Resources(_ context.Context) []func() resource.Res
newRemoteResource("puppet"), newRemoteResource("puppet"),
newRemoteResource("terraform"), newRemoteResource("terraform"),
newRemoteResource("goproxy"), newRemoteResource("goproxy"),
newRemoteResource("cargo"),
newRemoteResource("github_rpm"), newRemoteResource("github_rpm"),
newRemoteResource("github_deb"), newRemoteResource("github_deb"),
newRemoteResource("github_alpine"), newRemoteResource("github_alpine"),
+3 -2
View File
@@ -66,8 +66,8 @@ func TestProvider_Resources(t *testing.T) {
p := &ArtifactAPIProvider{version: "1.0.0"} p := &ArtifactAPIProvider{version: "1.0.0"}
resources := p.Resources(context.Background()) resources := p.Resources(context.Background())
// 13 remote resource types + 1 virtual + local_terraform/pypi/rpm/deb/alpine/docker/generic = 21 // 15 remote resource types + 1 virtual + 7 local = 23
expectedCount := 22 expectedCount := 23
if len(resources) != expectedCount { if len(resources) != expectedCount {
t.Fatalf("expected %d resources, got %d", expectedCount, len(resources)) t.Fatalf("expected %d resources, got %d", expectedCount, len(resources))
} }
@@ -107,6 +107,7 @@ func TestProvider_Resources_ContainsExpectedTypes(t *testing.T) {
"artifactapi_remote_puppet", "artifactapi_remote_puppet",
"artifactapi_remote_terraform", "artifactapi_remote_terraform",
"artifactapi_remote_goproxy", "artifactapi_remote_goproxy",
"artifactapi_remote_cargo",
"artifactapi_remote_github_rpm", "artifactapi_remote_github_rpm",
"artifactapi_remote_github_deb", "artifactapi_remote_github_deb",
"artifactapi_remote_github_alpine", "artifactapi_remote_github_alpine",
+1
View File
@@ -82,6 +82,7 @@ func NewRemoteAlpine() resource.Resource { return &remoteResource{packageType
func NewRemotePuppet() resource.Resource { return &remoteResource{packageType: "puppet"} } func NewRemotePuppet() resource.Resource { return &remoteResource{packageType: "puppet"} }
func NewRemoteTerraform() resource.Resource { return &remoteResource{packageType: "terraform"} } func NewRemoteTerraform() resource.Resource { return &remoteResource{packageType: "terraform"} }
func NewRemoteGoProxy() resource.Resource { return &remoteResource{packageType: "goproxy"} } func NewRemoteGoProxy() resource.Resource { return &remoteResource{packageType: "goproxy"} }
func NewRemoteCargo() resource.Resource { return &remoteResource{packageType: "cargo"} }
func NewRemoteGitHubRPM() resource.Resource { return &remoteResource{packageType: "github_rpm"} } func NewRemoteGitHubRPM() resource.Resource { return &remoteResource{packageType: "github_rpm"} }
func NewRemoteGitHubDeb() resource.Resource { return &remoteResource{packageType: "github_deb"} } func NewRemoteGitHubDeb() resource.Resource { return &remoteResource{packageType: "github_deb"} }
func NewRemoteGitHubAlpine() resource.Resource { func NewRemoteGitHubAlpine() resource.Resource {
@@ -163,6 +163,7 @@ func TestModelToAPI_PackageTypeFromResource(t *testing.T) {
{"puppet"}, {"puppet"},
{"terraform"}, {"terraform"},
{"goproxy"}, {"goproxy"},
{"cargo"},
} }
for _, tt := range tests { for _, tt := range tests {
@@ -524,6 +525,7 @@ func TestNewRemoteResource_Constructors(t *testing.T) {
{"puppet", func() resource.Resource { return NewRemotePuppet() }, "puppet"}, {"puppet", func() resource.Resource { return NewRemotePuppet() }, "puppet"},
{"terraform", func() resource.Resource { return NewRemoteTerraform() }, "terraform"}, {"terraform", func() resource.Resource { return NewRemoteTerraform() }, "terraform"},
{"goproxy", func() resource.Resource { return NewRemoteGoProxy() }, "goproxy"}, {"goproxy", func() resource.Resource { return NewRemoteGoProxy() }, "goproxy"},
{"cargo", func() resource.Resource { return NewRemoteCargo() }, "cargo"},
{"github_rpm", func() resource.Resource { return NewRemoteGitHubRPM() }, "github_rpm"}, {"github_rpm", func() resource.Resource { return NewRemoteGitHubRPM() }, "github_rpm"},
{"github_deb", func() resource.Resource { return NewRemoteGitHubDeb() }, "github_deb"}, {"github_deb", func() resource.Resource { return NewRemoteGitHubDeb() }, "github_deb"},
{"github_alpine", func() resource.Resource { return NewRemoteGitHubAlpine() }, "github_alpine"}, {"github_alpine", func() resource.Resource { return NewRemoteGitHubAlpine() }, "github_alpine"},