-
Notifications
You must be signed in to change notification settings - Fork 101
/
resource_xray_watch.go
125 lines (115 loc) · 3.43 KB
/
resource_xray_watch.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package artifactory
import (
"errors"
"github.com/go-resty/resty/v2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func resourceXrayWatch() *schema.Resource {
return &schema.Resource{
Create: resourceXrayWatchCreate,
Read: resourceXrayWatchRead,
Delete: resourceXrayWatchDelete,
DeprecationMessage: "Xray resources will be removed from this provider on or after March 31, 2022. " +
"Please use the separate Terraform Provider Xray: https://github.com/jfrog/terraform-provider-xray. " +
"Terraform Provider Registry link: https://registry.terraform.io/providers/jfrog/xray",
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
},
"active": {
Type: schema.TypeBool,
Optional: true,
},
"resources": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
},
"name": {
Type: schema.TypeString,
Required: true,
},
"bin_mgr_id": {
Type: schema.TypeString,
Optional: true,
},
"repo_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"local",
"remote",
}, false),
},
"filters": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Required: true,
},
// TODO this can be either a string or possibly a json blob
// eg "value":{"ExcludePatterns":[],"IncludePatterns":["*"]}
"value": {
Type: schema.TypeString,
Required: true,
},
},
},
},
},
},
},
"assigned_policies": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"type": {
Type: schema.TypeString,
Required: true,
},
},
},
},
"watch_recipients": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
}
func resourceXrayWatchCreate(d *schema.ResourceData, m interface{}) error {
return errors.New("Use Xray provider (https://github.com/jfrog/terraform-provider-xray) resource instead. Also see https://www.terraform.io/plugin/sdkv2/best-practices/deprecations#provider-data-source-or-resource-removal for resource removal process.")
}
func resourceXrayWatchRead(d *schema.ResourceData, m interface{}) error {
return errors.New("Use Xray provider (https://github.com/jfrog/terraform-provider-xray) resource instead. Also see https://www.terraform.io/plugin/sdkv2/best-practices/deprecations#provider-data-source-or-resource-removal for resource removal process.")
}
func resourceXrayWatchDelete(d *schema.ResourceData, m interface{}) error {
_, err := m.(*resty.Client).R().Delete("xray/api/v2/watches/" + d.Id())
return err
}