Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
LogpushJob.Filter is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfaulkner committed Jun 20, 2022
1 parent c966c01 commit e090fee
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/provider/resource_cloudflare_logpush_job.go
Expand Up @@ -81,7 +81,7 @@ func getJobFromResource(d *schema.ResourceData) (cloudflare.LogpushJob, *AccessI
if err != nil {
return job, identifier, err
}
job.Filter = jobFilter
job.Filter = &jobFilter
}

return job, identifier, nil
Expand Down Expand Up @@ -118,13 +118,15 @@ func resourceCloudflareLogpushJobRead(ctx context.Context, d *schema.ResourceDat
return nil
}

if job.Filter.Where.Validate() == nil {
filterstr, err := json.Marshal(job.Filter)
var filter string

if job.Filter != nil {
b, err := json.Marshal(job.Filter)
if err != nil {
return diag.FromErr(err)
}

d.Set("filter", string(filterstr))
filter = string(b)
}

d.Set("name", job.Name)
Expand All @@ -133,6 +135,7 @@ func resourceCloudflareLogpushJobRead(ctx context.Context, d *schema.ResourceDat
d.Set("destination_conf", job.DestinationConf)
d.Set("ownership_challenge", d.Get("ownership_challenge"))
d.Set("frequency", job.Frequency)
d.Set("filter", filter)

return nil
}
Expand Down

0 comments on commit e090fee

Please sign in to comment.