-
Notifications
You must be signed in to change notification settings - Fork 17
/
Aspects.go
100 lines (88 loc) · 2.19 KB
/
Aspects.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
package awscdk
import (
_init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii"
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
"github.com/aws/constructs-go/constructs/v10"
)
// Aspects can be applied to CDK tree scopes and can operate on the tree before synthesis.
//
// Example:
// import "github.com/aws/aws-cdk-go/awscdk"
// import "github.com/aws/constructs-go/constructs"
//
// type myAspect struct {
// }
//
// func (this *myAspect) visit(node iConstruct) {
// if *node instanceof cdk.CfnResource && *node.CfnResourceType == "Foo::Bar" {
// this.error(*node, jsii.String("we do not want a Foo::Bar resource"))
// }
// }
//
// func (this *myAspect) error(node iConstruct, message *string) {
// cdk.Annotations_Of(*node).AddError(*message)
// }
//
// type myStack struct {
// stack
// }
//
// func newMyStack(scope construct, id *string) *myStack {
// this := &myStack{}
// cdk.NewStack_Override(this, scope, id)
//
// stack := cdk.NewStack()
// cdk.NewCfnResource(stack, jsii.String("Foo"), &CfnResourceProps{
// Type: jsii.String("Foo::Bar"),
// Properties: map[string]interface{}{
// "Fred": jsii.String("Thud"),
// },
// })
// cdk.Aspects_Of(stack).Add(NewMyAspect())
// return this
// }
//
type Aspects interface {
// The list of aspects which were directly applied on this scope.
All() *[]IAspect
// Adds an aspect to apply this scope before synthesis.
Add(aspect IAspect)
}
// The jsii proxy struct for Aspects
type jsiiProxy_Aspects struct {
_ byte // padding
}
func (j *jsiiProxy_Aspects) All() *[]IAspect {
var returns *[]IAspect
_jsii_.Get(
j,
"all",
&returns,
)
return returns
}
// Returns the `Aspects` object associated with a construct scope.
func Aspects_Of(scope constructs.IConstruct) Aspects {
_init_.Initialize()
if err := validateAspects_OfParameters(scope); err != nil {
panic(err)
}
var returns Aspects
_jsii_.StaticInvoke(
"aws-cdk-lib.Aspects",
"of",
[]interface{}{scope},
&returns,
)
return returns
}
func (a *jsiiProxy_Aspects) Add(aspect IAspect) {
if err := a.validateAddParameters(aspect); err != nil {
panic(err)
}
_jsii_.InvokeVoid(
a,
"add",
[]interface{}{aspect},
)
}