-
Notifications
You must be signed in to change notification settings - Fork 101
/
resource_artifactory_virtual_generic_repository.go
46 lines (42 loc) · 1.73 KB
/
resource_artifactory_virtual_generic_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
package artifactory
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceArtifactoryVirtualGenericRepository(pkt string) *schema.Resource {
constructor := func() interface{} {
return &VirtualRepositoryBaseParams{
PackageType: pkt,
Rclass: "virtual",
}
}
unpack := func(data *schema.ResourceData) (interface{}, string, error) {
repo := unpackBaseVirtRepo(data, pkt)
return repo, repo.Id(), nil
}
return mkResourceSchema(mergeSchema(baseVirtualRepoSchema, repoLayoutRefSchema("virtual", pkt)), defaultPacker, unpack, constructor)
}
func resourceArtifactoryVirtualRepositoryWithRetrievalCachePeriodSecs(pkt string) *schema.Resource {
var repoWithRetrivalCachePeriodSecsVirtualSchema = mergeSchema(baseVirtualRepoSchema, map[string]*schema.Schema{
"retrieval_cache_period_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 7200,
Description: "This value refers to the number of seconds to cache metadata files before checking for newer versions on aggregated repositories. A value of 0 indicates no caching.",
ValidateFunc: validation.IntAtLeast(0),
},
}, repoLayoutRefSchema("virtual", pkt))
constructor := func() interface{} {
return &VirtualRepositoryBaseParamsWithRetrievalCachePeriodSecs{
VirtualRepositoryBaseParams: VirtualRepositoryBaseParams{
Rclass: "virtual",
PackageType: pkt,
},
}
}
unpack := func(data *schema.ResourceData) (interface{}, string, error) {
repo := unpackBaseVirtRepoWithRetrievalCachePeriodSecs(data, pkt)
return repo, repo.Id(), nil
}
return mkResourceSchema(repoWithRetrivalCachePeriodSecsVirtualSchema, defaultPacker, unpack, constructor)
}