-
Notifications
You must be signed in to change notification settings - Fork 100
/
resource_artifactory_remote_composer_repository.go
47 lines (41 loc) · 1.61 KB
/
resource_artifactory_remote_composer_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
package artifactory
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
type ComposerRemoteRepo struct {
RemoteRepositoryBaseParams
RemoteRepositoryVcsParams
ComposerRegistryUrl string `json:"composerRegistryUrl"`
}
func resourceArtifactoryRemoteComposerRepository() *schema.Resource {
const packageType = "composer"
var composerRemoteSchema = mergeSchema(baseRemoteRepoSchema, vcsRemoteRepoSchema, map[string]*schema.Schema{
"composer_registry_url": {
Type: schema.TypeString,
Optional: true,
Default: "https://packagist.org",
ValidateFunc: validation.IsURLWithHTTPorHTTPS,
Description: `(Optional) Proxy remote Composer repository. Default value is "https://packagist.org".`,
},
}, repoLayoutRefSchema("remote", packageType))
var unpackComposerRemoteRepo = func(s *schema.ResourceData) (interface{}, string, error) {
d := &ResourceData{s}
repo := ComposerRemoteRepo{
RemoteRepositoryBaseParams: unpackBaseRemoteRepo(s, packageType),
RemoteRepositoryVcsParams: unpackVcsRemoteRepo(s),
ComposerRegistryUrl: d.getString("composer_registry_url", false),
}
return repo, repo.Id(), nil
}
return mkResourceSchema(composerRemoteSchema, defaultPacker, unpackComposerRemoteRepo, func() interface{} {
repoLayout, _ := getDefaultRepoLayoutRef("remote", packageType)()
return &ComposerRemoteRepo{
RemoteRepositoryBaseParams: RemoteRepositoryBaseParams{
Rclass: "remote",
PackageType: packageType,
RemoteRepoLayoutRef: repoLayout.(string),
},
}
})
}