-
Notifications
You must be signed in to change notification settings - Fork 3
/
flowpipe_loop_email.go
123 lines (105 loc) · 3.64 KB
/
flowpipe_loop_email.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
package modconfig
import (
"github.com/hashicorp/hcl/v2"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/schema"
"github.com/turbot/pipe-fittings/utils"
)
type LoopEmailStep struct {
LoopStep
To *[]string `json:"to,omitempty" hcl:"to,optional" cty:"to"`
From *string `json:"from,omitempty" hcl:"from,optional" cty:"from"`
SenderCredential *string `json:"sender_credential,omitempty" hcl:"sender_credential,optional" cty:"sender_credential"`
Host *string `json:"host,omitempty" hcl:"host,optional" cty:"host"`
Port *int64 `json:"port,omitempty" hcl:"port,optional" cty:"port"`
SenderName *string `json:"sender_name,omitempty" hcl:"sender_name,optional" cty:"sender_name"`
Cc *[]string `json:"cc,omitempty" hcl:"cc,optional" cty:"cc"`
Bcc *[]string `json:"bcc,omitempty" hcl:"bcc,optional" cty:"bcc"`
Body *string `json:"body,omitempty" hcl:"body,optional" cty:"body"`
ContentType *string `json:"content_type,omitempty" hcl:"content_type,optional" cty:"content_type"`
Subject *string `json:"subject,omitempty" hcl:"subject,optional" cty:"subject"`
}
func (l *LoopEmailStep) Equals(other LoopDefn) bool {
if l == nil && helpers.IsNil(other) {
return true
}
if l == nil && !helpers.IsNil(other) || !helpers.IsNil(l) && other == nil {
return false
}
otherLoopEmailStep, ok := other.(*LoopEmailStep)
if !ok {
return false
}
if !l.LoopStep.Equals(otherLoopEmailStep.LoopStep) {
return false
}
if l.To == nil && otherLoopEmailStep.To != nil || l.To != nil && otherLoopEmailStep.To == nil {
return false
}
if l.To != nil && !helpers.StringSliceEqualIgnoreOrder(*l.To, *otherLoopEmailStep.To) {
return false
}
if l.Cc == nil && otherLoopEmailStep.Cc != nil || l.Cc != nil && otherLoopEmailStep.Cc == nil {
return false
}
if l.Cc != nil && !helpers.StringSliceEqualIgnoreOrder(*l.Cc, *otherLoopEmailStep.Cc) {
return false
}
if l.Bcc == nil && otherLoopEmailStep.Bcc != nil || l.Bcc != nil && otherLoopEmailStep.Bcc == nil {
return false
}
if l.Bcc != nil && !helpers.StringSliceEqualIgnoreOrder(*l.Bcc, *otherLoopEmailStep.Bcc) {
return false
}
return utils.PtrEqual(l.From, otherLoopEmailStep.From) &&
utils.PtrEqual(l.SenderCredential, otherLoopEmailStep.SenderCredential) &&
utils.PtrEqual(l.Host, otherLoopEmailStep.Host) &&
utils.PtrEqual(l.Port, otherLoopEmailStep.Port) &&
utils.PtrEqual(l.SenderName, otherLoopEmailStep.SenderName) &&
utils.PtrEqual(l.Body, otherLoopEmailStep.Body) &&
utils.PtrEqual(l.ContentType, otherLoopEmailStep.ContentType) &&
utils.PtrEqual(l.Subject, otherLoopEmailStep.Subject)
}
func (l *LoopEmailStep) UpdateInput(input Input, evalContext *hcl.EvalContext) (Input, error) {
if l.To != nil {
input["to"] = *l.To
}
if l.From != nil {
input["from"] = *l.From
}
if l.SenderCredential != nil {
input["sender_credential"] = *l.SenderCredential
}
if l.Host != nil {
input["host"] = *l.Host
}
if l.Port != nil {
input["port"] = *l.Port
}
if l.SenderName != nil {
input["sender_name"] = *l.SenderName
}
if l.Cc != nil {
input[schema.AttributeTypeCc] = *l.Cc
}
if l.Bcc != nil {
input["bcc"] = *l.Bcc
}
if l.Body != nil {
input["body"] = *l.Body
}
if l.ContentType != nil {
input["content_type"] = *l.ContentType
}
if l.Subject != nil {
input["subject"] = *l.Subject
}
return input, nil
}
func (*LoopEmailStep) GetType() string {
return schema.BlockTypePipelineStepEmail
}
func (l *LoopEmailStep) SetAttributes(hclAttributes hcl.Attributes, evalContext *hcl.EvalContext) hcl.Diagnostics {
diags := hcl.Diagnostics{}
return diags
}