Skip to content

Commit

Permalink
Fix email Attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
karanpopat committed Oct 18, 2023
1 parent 382b269 commit 1aec5ba
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions modconfig/flowpipe_pipeline_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -2272,40 +2272,40 @@ func (p *PipelineStepInput) GetInputs(evalContext *hcl.EvalContext) (map[string]
}

var from *string
if p.UnresolvedAttributes[schema.AttributeTypeFrom] == nil {
if p.UnresolvedAttributes[schema.AttributeTypeUsername] == nil {
from = p.Username
} else {
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeFrom], evalContext, &from)
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeUsername], evalContext, &from)
if diags.HasErrors() {
return nil, error_helpers.HclDiagsToError(p.Name, diags)
}
}

var senderCredential *string
if p.UnresolvedAttributes[schema.AttributeTypeSenderCredential] == nil {
senderCredential = p.Username
if p.UnresolvedAttributes[schema.AttributeTypePassword] == nil {
senderCredential = p.Password
} else {
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeSenderCredential], evalContext, &senderCredential)
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypePassword], evalContext, &senderCredential)
if diags.HasErrors() {
return nil, error_helpers.HclDiagsToError(p.Name, diags)
}
}

var host *string
if p.UnresolvedAttributes[schema.AttributeTypeHost] == nil {
if p.UnresolvedAttributes[schema.AttributeTypeSmtpServer] == nil {
host = p.SmtpServer
} else {
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeHost], evalContext, &host)
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeSmtpServer], evalContext, &host)
if diags.HasErrors() {
return nil, error_helpers.HclDiagsToError(p.Name, diags)
}
}

var port *int64
if p.UnresolvedAttributes[schema.AttributeTypePort] == nil {
if p.UnresolvedAttributes[schema.AttributeTypeSmtpPort] == nil {
port = p.SmtpPort
} else {
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypePort], evalContext, &port)
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeSmtpPort], evalContext, &port)
if diags.HasErrors() {
return nil, error_helpers.HclDiagsToError(p.Name, diags)
}
Expand Down Expand Up @@ -2401,6 +2401,16 @@ func (p *PipelineStepInput) GetInputs(evalContext *hcl.EvalContext) (map[string]
}
}

var responseUrl *string
if p.UnresolvedAttributes[schema.AttributeTypeResponseUrl] == nil {
responseUrl = p.ResponseUrl
} else {
diags := gohcl.DecodeExpression(p.UnresolvedAttributes[schema.AttributeTypeResponseUrl], evalContext, &responseUrl)
if diags.HasErrors() {
return nil, error_helpers.HclDiagsToError(p.Name, diags)
}
}

results := map[string]interface{}{}

if to != nil {
Expand Down Expand Up @@ -2459,6 +2469,10 @@ func (p *PipelineStepInput) GetInputs(evalContext *hcl.EvalContext) (map[string]
results[schema.AttributeTypeOptions] = options
}

if responseUrl != nil {
results[schema.AttributeTypeResponseUrl] = *responseUrl
}

return results, nil
}

Expand Down Expand Up @@ -2512,7 +2526,7 @@ func (p *PipelineStepInput) SetAttributes(hclAttributes hcl.Attributes, evalCont
if err != nil {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Unable to parse " + schema.AttributeTypeFrom + " attribute to string",
Summary: "Unable to parse " + schema.AttributeTypePassword + " attribute to string",
Subject: &attr.Range,
})
}
Expand Down

0 comments on commit 1aec5ba

Please sign in to comment.