|
| 1 | +package aquasec |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/aquasecurity/terraform-provider-aquasec/client" |
| 5 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
| 6 | +) |
| 7 | + |
| 8 | +func dataApplicationScopeSaas() *schema.Resource { |
| 9 | + return &schema.Resource{ |
| 10 | + Read: readApplicationScopeRead, |
| 11 | + Schema: map[string]*schema.Schema{ |
| 12 | + "name": { |
| 13 | + Type: schema.TypeString, |
| 14 | + Description: "Name of an application scope.", |
| 15 | + Required: true, |
| 16 | + }, |
| 17 | + "description": { |
| 18 | + Type: schema.TypeString, |
| 19 | + Description: "Description of the application scope.", |
| 20 | + Computed: true, |
| 21 | + }, |
| 22 | + "author": { |
| 23 | + Type: schema.TypeString, |
| 24 | + Description: "Username of the account that created the service.", |
| 25 | + Computed: true, |
| 26 | + }, |
| 27 | + "owner_email": { |
| 28 | + Type: schema.TypeString, |
| 29 | + Description: "Name of an application scope.", |
| 30 | + Computed: true, |
| 31 | + }, |
| 32 | + "categories": { |
| 33 | + Type: schema.TypeSet, |
| 34 | + Optional: true, |
| 35 | + Description: "Artifacts (of applications) / Workloads (containers) / Infrastructure (elements).", |
| 36 | + Elem: &schema.Resource{ |
| 37 | + Schema: map[string]*schema.Schema{ |
| 38 | + "artifacts": { |
| 39 | + Type: schema.TypeSet, |
| 40 | + Optional: true, |
| 41 | + Elem: &schema.Resource{ |
| 42 | + Schema: map[string]*schema.Schema{ |
| 43 | + "image": { |
| 44 | + Type: schema.TypeSet, |
| 45 | + Optional: true, |
| 46 | + Elem: &schema.Resource{ |
| 47 | + Schema: map[string]*schema.Schema{ |
| 48 | + "expression": { |
| 49 | + Type: schema.TypeString, |
| 50 | + Optional: true, |
| 51 | + Computed: true, |
| 52 | + }, |
| 53 | + "variables": { |
| 54 | + Type: schema.TypeList, |
| 55 | + Optional: true, |
| 56 | + Elem: &schema.Resource{ |
| 57 | + Schema: map[string]*schema.Schema{ |
| 58 | + "attribute": { |
| 59 | + Type: schema.TypeString, |
| 60 | + Optional: true, |
| 61 | + }, |
| 62 | + "value": { |
| 63 | + Type: schema.TypeString, |
| 64 | + Optional: true, |
| 65 | + }, |
| 66 | + "name": { |
| 67 | + Type: schema.TypeString, |
| 68 | + Optional: true, |
| 69 | + }, |
| 70 | + }, |
| 71 | + }, |
| 72 | + }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + }, |
| 76 | + "function": { |
| 77 | + Type: schema.TypeSet, |
| 78 | + Optional: true, |
| 79 | + Elem: &schema.Resource{ |
| 80 | + Schema: map[string]*schema.Schema{ |
| 81 | + "expression": { |
| 82 | + Type: schema.TypeString, |
| 83 | + Optional: true, |
| 84 | + Computed: true, |
| 85 | + }, |
| 86 | + "variables": { |
| 87 | + Type: schema.TypeList, |
| 88 | + Optional: true, |
| 89 | + Elem: &schema.Resource{ |
| 90 | + Schema: map[string]*schema.Schema{ |
| 91 | + "attribute": { |
| 92 | + Type: schema.TypeString, |
| 93 | + Optional: true, |
| 94 | + Computed: true, |
| 95 | + }, |
| 96 | + "value": { |
| 97 | + Type: schema.TypeString, |
| 98 | + Optional: true, |
| 99 | + }, |
| 100 | + "name": { |
| 101 | + Type: schema.TypeString, |
| 102 | + Optional: true, |
| 103 | + }, |
| 104 | + }, |
| 105 | + }, |
| 106 | + }, |
| 107 | + }, |
| 108 | + }, |
| 109 | + }, |
| 110 | + "cf": { |
| 111 | + Type: schema.TypeSet, |
| 112 | + Optional: true, |
| 113 | + Elem: &schema.Resource{ |
| 114 | + Schema: map[string]*schema.Schema{ |
| 115 | + "expression": { |
| 116 | + Type: schema.TypeString, |
| 117 | + Optional: true, |
| 118 | + Computed: true, |
| 119 | + }, |
| 120 | + "variables": { |
| 121 | + Type: schema.TypeList, |
| 122 | + Optional: true, |
| 123 | + Elem: &schema.Resource{ |
| 124 | + Schema: map[string]*schema.Schema{ |
| 125 | + "attribute": { |
| 126 | + Type: schema.TypeString, |
| 127 | + Optional: true, |
| 128 | + Computed: true, |
| 129 | + }, |
| 130 | + "value": { |
| 131 | + Type: schema.TypeString, |
| 132 | + Optional: true, |
| 133 | + }, |
| 134 | + "name": { |
| 135 | + Type: schema.TypeString, |
| 136 | + Optional: true, |
| 137 | + }, |
| 138 | + }, |
| 139 | + }, |
| 140 | + }, |
| 141 | + }, |
| 142 | + }, |
| 143 | + }, |
| 144 | + }, |
| 145 | + }, |
| 146 | + }, |
| 147 | + "entity_scope": { |
| 148 | + Type: schema.TypeSet, |
| 149 | + Optional: true, |
| 150 | + Elem: &schema.Resource{ |
| 151 | + Schema: map[string]*schema.Schema{ |
| 152 | + "expression": { |
| 153 | + Type: schema.TypeString, |
| 154 | + Optional: true, |
| 155 | + Computed: true, |
| 156 | + }, |
| 157 | + "variables": { |
| 158 | + Type: schema.TypeList, |
| 159 | + Optional: true, |
| 160 | + Elem: &schema.Resource{ |
| 161 | + Schema: map[string]*schema.Schema{ |
| 162 | + "attribute": { |
| 163 | + Type: schema.TypeString, |
| 164 | + Optional: true, |
| 165 | + Computed: true, |
| 166 | + }, |
| 167 | + "value": { |
| 168 | + Type: schema.TypeString, |
| 169 | + Optional: true, |
| 170 | + Computed: true, |
| 171 | + }, |
| 172 | + "name": { |
| 173 | + Type: schema.TypeString, |
| 174 | + Optional: true, |
| 175 | + Computed: true, |
| 176 | + }, |
| 177 | + }, |
| 178 | + }, |
| 179 | + }, |
| 180 | + }, |
| 181 | + }, |
| 182 | + }, |
| 183 | + "workloads": { |
| 184 | + Type: schema.TypeSet, |
| 185 | + Optional: true, |
| 186 | + Elem: &schema.Resource{ |
| 187 | + Schema: map[string]*schema.Schema{ |
| 188 | + "cf": { |
| 189 | + Type: schema.TypeSet, |
| 190 | + Optional: true, |
| 191 | + Elem: &schema.Resource{ |
| 192 | + Schema: map[string]*schema.Schema{ |
| 193 | + "expression": { |
| 194 | + Type: schema.TypeString, |
| 195 | + Optional: true, |
| 196 | + Computed: true, |
| 197 | + }, |
| 198 | + "variables": { |
| 199 | + Type: schema.TypeList, |
| 200 | + Optional: true, |
| 201 | + Elem: &schema.Resource{ |
| 202 | + Schema: map[string]*schema.Schema{ |
| 203 | + "attribute": { |
| 204 | + Type: schema.TypeString, |
| 205 | + Optional: true, |
| 206 | + Computed: true, |
| 207 | + }, |
| 208 | + "value": { |
| 209 | + Type: schema.TypeString, |
| 210 | + Optional: true, |
| 211 | + }, |
| 212 | + "name": { |
| 213 | + Type: schema.TypeString, |
| 214 | + Optional: true, |
| 215 | + }, |
| 216 | + }, |
| 217 | + }, |
| 218 | + }, |
| 219 | + }, |
| 220 | + }, |
| 221 | + }, |
| 222 | + "kubernetes": { |
| 223 | + Type: schema.TypeSet, |
| 224 | + Optional: true, |
| 225 | + Elem: &schema.Resource{ |
| 226 | + Schema: map[string]*schema.Schema{ |
| 227 | + "expression": { |
| 228 | + Type: schema.TypeString, |
| 229 | + Optional: true, |
| 230 | + Computed: true, |
| 231 | + }, |
| 232 | + "variables": { |
| 233 | + Type: schema.TypeList, |
| 234 | + Optional: true, |
| 235 | + Elem: &schema.Resource{ |
| 236 | + Schema: map[string]*schema.Schema{ |
| 237 | + "attribute": { |
| 238 | + Type: schema.TypeString, |
| 239 | + Optional: true, |
| 240 | + Computed: true, |
| 241 | + }, |
| 242 | + "value": { |
| 243 | + Type: schema.TypeString, |
| 244 | + Optional: true, |
| 245 | + }, |
| 246 | + "name": { |
| 247 | + Type: schema.TypeString, |
| 248 | + Optional: true, |
| 249 | + }, |
| 250 | + }, |
| 251 | + }, |
| 252 | + }, |
| 253 | + }, |
| 254 | + }, |
| 255 | + }, |
| 256 | + "os": { |
| 257 | + Type: schema.TypeSet, |
| 258 | + Optional: true, |
| 259 | + Elem: &schema.Resource{ |
| 260 | + Schema: map[string]*schema.Schema{ |
| 261 | + "expression": { |
| 262 | + Type: schema.TypeString, |
| 263 | + Optional: true, |
| 264 | + Computed: true, |
| 265 | + }, |
| 266 | + "variables": { |
| 267 | + Type: schema.TypeList, |
| 268 | + Optional: true, |
| 269 | + Elem: &schema.Resource{ |
| 270 | + Schema: map[string]*schema.Schema{ |
| 271 | + "attribute": { |
| 272 | + Type: schema.TypeString, |
| 273 | + Optional: true, |
| 274 | + Computed: true, |
| 275 | + }, |
| 276 | + "value": { |
| 277 | + Type: schema.TypeString, |
| 278 | + Optional: true, |
| 279 | + }, |
| 280 | + "name": { |
| 281 | + Type: schema.TypeString, |
| 282 | + Optional: true, |
| 283 | + }, |
| 284 | + }, |
| 285 | + }, |
| 286 | + }, |
| 287 | + }, |
| 288 | + }, |
| 289 | + }, |
| 290 | + }, |
| 291 | + }, |
| 292 | + }, |
| 293 | + "infrastructure": { |
| 294 | + Type: schema.TypeSet, |
| 295 | + Optional: true, |
| 296 | + Elem: &schema.Resource{ |
| 297 | + Schema: map[string]*schema.Schema{ |
| 298 | + "kubernetes": { |
| 299 | + Type: schema.TypeSet, |
| 300 | + Optional: true, |
| 301 | + Elem: &schema.Resource{ |
| 302 | + Schema: map[string]*schema.Schema{ |
| 303 | + "expression": { |
| 304 | + Type: schema.TypeString, |
| 305 | + Optional: true, |
| 306 | + Computed: true, |
| 307 | + }, |
| 308 | + "variables": { |
| 309 | + Type: schema.TypeList, |
| 310 | + Optional: true, |
| 311 | + Elem: &schema.Resource{ |
| 312 | + Schema: map[string]*schema.Schema{ |
| 313 | + "attribute": { |
| 314 | + Type: schema.TypeString, |
| 315 | + Optional: true, |
| 316 | + Computed: true, |
| 317 | + }, |
| 318 | + "value": { |
| 319 | + Type: schema.TypeString, |
| 320 | + Optional: true, |
| 321 | + }, |
| 322 | + "name": { |
| 323 | + Type: schema.TypeString, |
| 324 | + Optional: true, |
| 325 | + }, |
| 326 | + }, |
| 327 | + }, |
| 328 | + }, |
| 329 | + }, |
| 330 | + }, |
| 331 | + }, |
| 332 | + "os": { |
| 333 | + Type: schema.TypeSet, |
| 334 | + Optional: true, |
| 335 | + Elem: &schema.Resource{ |
| 336 | + Schema: map[string]*schema.Schema{ |
| 337 | + "expression": { |
| 338 | + Type: schema.TypeString, |
| 339 | + Optional: true, |
| 340 | + Computed: true, |
| 341 | + }, |
| 342 | + "variables": { |
| 343 | + Type: schema.TypeList, |
| 344 | + Optional: true, |
| 345 | + Elem: &schema.Resource{ |
| 346 | + Schema: map[string]*schema.Schema{ |
| 347 | + "attribute": { |
| 348 | + Type: schema.TypeString, |
| 349 | + Optional: true, |
| 350 | + Computed: true, |
| 351 | + }, |
| 352 | + "value": { |
| 353 | + Type: schema.TypeString, |
| 354 | + Optional: true, |
| 355 | + }, |
| 356 | + "name": { |
| 357 | + Type: schema.TypeString, |
| 358 | + Optional: true, |
| 359 | + }, |
| 360 | + }, |
| 361 | + }, |
| 362 | + }, |
| 363 | + }, |
| 364 | + }, |
| 365 | + }, |
| 366 | + }, |
| 367 | + }, |
| 368 | + }, |
| 369 | + }, |
| 370 | + }, |
| 371 | + }, |
| 372 | + }, |
| 373 | + } |
| 374 | +} |
| 375 | + |
| 376 | +func readApplicationScopeSaasRead(d *schema.ResourceData, m interface{}) error { |
| 377 | + ac := m.(*client.Client) |
| 378 | + name := d.Get("name").(string) |
| 379 | + |
| 380 | + iap, err := ac.GetApplicationScope(name) |
| 381 | + if err == nil { |
| 382 | + d.Set("name", iap.Name) |
| 383 | + d.Set("description", iap.Description) |
| 384 | + d.Set("author", iap.Author) |
| 385 | + d.Set("owner_email", iap.OwnerEmail) |
| 386 | + d.Set("categories", flattenCategories(iap.Categories)) |
| 387 | + d.SetId(name) |
| 388 | + } else { |
| 389 | + return err |
| 390 | + } |
| 391 | + return nil |
| 392 | +} |
0 commit comments