-
Notifications
You must be signed in to change notification settings - Fork 31
/
technology.go
127 lines (120 loc) · 4.09 KB
/
technology.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
126
127
/**
* @license
* Copyright 2020 Dynatrace LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package runtimevulnerabilitydetection
import (
"github.com/dynatrace-oss/terraform-provider-dynatrace/dynatrace/opt"
"github.com/dynatrace-oss/terraform-provider-dynatrace/terraform/hcl"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
type Technology struct {
EnableDotNet bool `json:"enableDotNet"` // NET
EnableDotNetRuntime *bool `json:"enableDotNetRuntime,omitempty"` // NET runtimes
EnableGo bool `json:"enableGo"` // Go
EnableJava bool `json:"enableJava"` // Java
EnableJavaRuntime *bool `json:"enableJavaRuntime,omitempty"` // Java runtimes
EnableKubernetes bool `json:"enableKubernetes"` // Kubernetes
EnableNodeJs bool `json:"enableNodeJs"` // Node.js
EnableNodeJsRuntime *bool `json:"enableNodeJsRuntime,omitempty"` // Node.js runtimes
EnablePhp bool `json:"enablePhp"` // PHP
}
func (me *Technology) Schema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"enable_dot_net": {
Type: schema.TypeBool,
Description: "NET",
Required: true,
},
"enable_dot_net_runtime": {
Type: schema.TypeBool,
Description: "NET runtimes",
Optional: true, // precondition
},
"enable_go": {
Type: schema.TypeBool,
Description: "Go",
Required: true,
},
"enable_java": {
Type: schema.TypeBool,
Description: "Java",
Required: true,
},
"enable_java_runtime": {
Type: schema.TypeBool,
Description: "Java runtimes",
Optional: true, // precondition
},
"enable_kubernetes": {
Type: schema.TypeBool,
Description: "Kubernetes",
Required: true,
},
"enable_node_js": {
Type: schema.TypeBool,
Description: "Node.js",
Required: true,
},
"enable_node_js_runtime": {
Type: schema.TypeBool,
Description: "Node.js runtimes",
Optional: true, // precondition
},
"enable_php": {
Type: schema.TypeBool,
Description: "PHP",
Required: true,
},
}
}
func (me *Technology) MarshalHCL(properties hcl.Properties) error {
return properties.EncodeAll(map[string]any{
"enable_dot_net": me.EnableDotNet,
"enable_dot_net_runtime": me.EnableDotNetRuntime,
"enable_go": me.EnableGo,
"enable_java": me.EnableJava,
"enable_java_runtime": me.EnableJavaRuntime,
"enable_kubernetes": me.EnableKubernetes,
"enable_node_js": me.EnableNodeJs,
"enable_node_js_runtime": me.EnableNodeJsRuntime,
"enable_php": me.EnablePhp,
})
}
func (me *Technology) HandlePreconditions() error {
if (me.EnableDotNetRuntime == nil) && (me.EnableDotNet) {
me.EnableDotNetRuntime = opt.NewBool(false)
}
if (me.EnableJavaRuntime == nil) && (me.EnableJava) {
me.EnableJavaRuntime = opt.NewBool(false)
}
if (me.EnableNodeJsRuntime == nil) && (me.EnableNodeJs) {
me.EnableNodeJsRuntime = opt.NewBool(false)
}
return nil
}
func (me *Technology) UnmarshalHCL(decoder hcl.Decoder) error {
return decoder.DecodeAll(map[string]any{
"enable_dot_net": &me.EnableDotNet,
"enable_dot_net_runtime": &me.EnableDotNetRuntime,
"enable_go": &me.EnableGo,
"enable_java": &me.EnableJava,
"enable_java_runtime": &me.EnableJavaRuntime,
"enable_kubernetes": &me.EnableKubernetes,
"enable_node_js": &me.EnableNodeJs,
"enable_node_js_runtime": &me.EnableNodeJsRuntime,
"enable_php": &me.EnablePhp,
})
}