-
Notifications
You must be signed in to change notification settings - Fork 99
/
resource_artifactory_local_cargo_repository.go
42 lines (35 loc) · 1.41 KB
/
resource_artifactory_local_cargo_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
package artifactory
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceArtifactoryLocalCargoRepository() *schema.Resource {
const packageType = "cargo"
var cargoLocalSchema = mergeSchema(baseLocalRepoSchema, map[string]*schema.Schema{
"anonymous_access": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: `(Optional) Cargo client does not send credentials when performing download and search for crates. Enable this to allow anonymous access to these resources (only), note that this will override the security anonymous access option. Default value is 'false'.`,
},
}, repoLayoutRefSchema("local", packageType), compressionFormats)
type CargoLocalRepo struct {
LocalRepositoryBaseParams
AnonymousAccess bool `json:"cargoAnonymousAccess"`
}
var unPackLocalCargoRepository = func(data *schema.ResourceData) (interface{}, string, error) {
d := &ResourceData{ResourceData: data}
repo := CargoLocalRepo{
LocalRepositoryBaseParams: unpackBaseRepo("local", data, packageType),
AnonymousAccess: d.getBool("anonymous_access", false),
}
return repo, repo.Id(), nil
}
return mkResourceSchema(cargoLocalSchema, defaultPacker, unPackLocalCargoRepository, func() interface{} {
return &CargoLocalRepo{
LocalRepositoryBaseParams: LocalRepositoryBaseParams{
PackageType: packageType,
Rclass: "local",
},
}
})
}