-
Notifications
You must be signed in to change notification settings - Fork 100
/
resource_artifactory_local_debian_repository.go
57 lines (51 loc) · 2.18 KB
/
resource_artifactory_local_debian_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
53
54
55
56
57
package artifactory
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceArtifactoryLocalDebianRepository() *schema.Resource {
const packageType = "debian"
var debianLocalSchema = mergeSchema(baseLocalRepoSchema, map[string]*schema.Schema{
"primary_keypair_ref": {
Type: schema.TypeString,
Optional: true,
Description: "Used to sign index files in Debian artifacts. ",
},
"secondary_keypair_ref": {
Type: schema.TypeString,
Optional: true,
Description: "Used to sign index files in Debian artifacts. ",
},
"trivial_layout": {
Type: schema.TypeBool,
Optional: true,
Description: "When set, the repository will use the deprecated trivial layout.",
Deprecated: "You shouldn't be using this",
},
}, repoLayoutRefSchema("local", packageType), compressionFormats)
type DebianLocalRepositoryParams struct {
LocalRepositoryBaseParams
TrivialLayout bool `hcl:"trivial_layout" json:"debianTrivialLayout,omitempty"`
IndexCompressionFormats []string `hcl:"index_compression_formats" json:"optionalIndexCompressionFormats,omitempty"`
PrimaryKeyPairRef string `hcl:"primary_keypair_ref" json:"primaryKeyPairRef,omitempty"`
SecondaryKeyPairRef string `hcl:"secondary_keypair_ref" json:"secondaryKeyPairRef,omitempty"`
}
var unPackLocalDebianRepository = func(data *schema.ResourceData) (interface{}, string, error) {
d := &ResourceData{ResourceData: data}
repo := DebianLocalRepositoryParams{
LocalRepositoryBaseParams: unpackBaseRepo("local", data, packageType),
PrimaryKeyPairRef: d.getString("primary_keypair_ref", false),
SecondaryKeyPairRef: d.getString("secondary_keypair_ref", false),
TrivialLayout: d.getBool("trivial_layout", false),
IndexCompressionFormats: d.getSet("index_compression_formats"),
}
return repo, repo.Id(), nil
}
return mkResourceSchema(debianLocalSchema, defaultPacker(debianLocalSchema), unPackLocalDebianRepository, func() interface{} {
return &DebianLocalRepositoryParams{
LocalRepositoryBaseParams: LocalRepositoryBaseParams{
PackageType: packageType,
Rclass: "local",
},
}
})
}