-
Notifications
You must be signed in to change notification settings - Fork 102
/
resource_artifactory_remote_pypi_repository.go
52 lines (46 loc) · 2.07 KB
/
resource_artifactory_remote_pypi_repository.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package artifactory
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceArtifactoryRemotePypiRepository() *schema.Resource {
const packageType = "pypi"
var pypiRemoteSchema = mergeSchema(baseRemoteRepoSchema, map[string]*schema.Schema{
"pypi_registry_url": {
Type: schema.TypeString,
Optional: true,
Default: "https://pypi.org",
ValidateDiagFunc: validation.ToDiagFunc(validation.IsURLWithHTTPorHTTPS),
Description: `(Optional) To configure the remote repo to proxy public external PyPI repository, or a PyPI repository hosted on another Artifactory server. See JFrog Pypi documentation for the usage details. Default value is 'https://pypi.org'.`,
},
"pypi_repository_suffix": {
Type: schema.TypeString,
Optional: true,
Default: "simple",
ValidateDiagFunc: validation.ToDiagFunc(validation.StringIsNotEmpty),
Description: `(Optional) Usually should be left as a default for 'simple', unless the remote is a PyPI server that has custom registry suffix, like +simple in DevPI. Default value is 'simple'.`,
},
}, repoLayoutRefSchema("remote", packageType))
type PypiRemoteRepo struct {
RemoteRepositoryBaseParams
PypiRegistryUrl string `json:"pyPIRegistryUrl"`
PypiRepositorySuffix string `json:"pyPIRepositorySuffix"`
}
var unpackPypiRemoteRepo = func(s *schema.ResourceData) (interface{}, string, error) {
d := &ResourceData{s}
repo := PypiRemoteRepo{
RemoteRepositoryBaseParams: unpackBaseRemoteRepo(s, packageType),
PypiRegistryUrl: d.getString("pypi_registry_url", false),
PypiRepositorySuffix: d.getString("pypi_repository_suffix", false),
}
return repo, repo.Id(), nil
}
return mkResourceSchema(pypiRemoteSchema, defaultPacker(pypiRemoteSchema), unpackPypiRemoteRepo, func() interface{} {
return &PypiRemoteRepo{
RemoteRepositoryBaseParams: RemoteRepositoryBaseParams{
Rclass: "remote",
PackageType: packageType,
},
}
})
}