Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OC Migrate Blocks to using AttributeHandlers #269

Merged
merged 94 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
f252a7a
Added missing readFTP and readElasticsearch functions
Jun 12, 2020
d8d0405
Removed readFTP and readElasticsearch to align with master
Jun 12, 2020
d51a375
Migrated bigquerylogging to attribute handler
Jun 11, 2020
410b056
Migrated blobstoragelogging to attribute handler
Jun 11, 2020
519bb7d
Migrated cachesetting to attribute handler
Jun 11, 2020
914da46
Migrated condition to attribute handler
Jun 11, 2020
3e85257
Migrated dictionary to attribute handler
Jun 11, 2020
69de779
Migrated director to attribute handler
Jun 11, 2020
f3a6cbd
Migrated domain to attribute handler
Jun 11, 2020
214e47e
Migrated dynamicsnippet to attribute handler
Jun 11, 2020
21eb48c
Incorrect key for domain
Jun 11, 2020
95c5166
Migrated gcslogging to attribute handler
Jun 11, 2020
74e5f7a
Migrated gzip to attribute handler
Jun 11, 2020
13a3625
Migrated header to attribute handler
Jun 11, 2020
5f60d63
Migrated healthcheck to attribute handler
Jun 11, 2020
e321752
Migrated httpslogging to attribute handler
Jun 11, 2020
5c030b8
Migrated logentries to attribute handler
Jun 11, 2020
4b39294
Migrated papertrail to attribute handler
Jun 11, 2020
217ba48
Migrated requestsetting to attribute handler
Jun 11, 2020
2c250f7
Migrated responseobject to attribute handler
Jun 11, 2020
ccf2eed
Migrated s3logging to attribute handler
Jun 11, 2020
7abd682
Migrated snippet to attribute handler
Jun 11, 2020
2918823
Migrated splunk and sumologic to attribute handler
Jun 11, 2020
64e00fa
Sumologic error
Jun 11, 2020
92f7646
Migrated syslogic to attribute handler
Jun 11, 2020
d4242b8
Migrated vcl to attribute handler
Jun 11, 2020
c7dc2b6
Tidy up
Jun 11, 2020
bc6d305
Refactored to make a bit more DRY
Jun 11, 2020
ea950d2
make fmt
Jun 12, 2020
908ef5b
Refactored ElasticSearch & FTP to handler (and ACL which had regresse…
Jun 12, 2020
8c81258
Tidy up cherry-pick
Jun 15, 2020
26ee766
Readded elasticsearch and ftp logging Read
Jun 15, 2020
5ea51e3
Renamed BigQueryLogging test file
Jun 15, 2020
20c89fd
Migrated LogEntries to Logentries
Jun 15, 2020
87c9a38
Update fastly/block_fastly_service_v1_logentries.go
guyrichardson-ockl Jun 15, 2020
f571047
Migrated blobstoragelogging to attribute handler
Jun 11, 2020
52bebb1
Migrated logentries to attribute handler
Jun 11, 2020
7775304
Refactored Logentries
Jun 15, 2020
7881985
Migrated schema for blobstoragelogging to Register
Jun 11, 2020
f3c9061
Migrated schema for cachesetting to Register
Jun 11, 2020
16a90bf
Migrated schema for condition to Register
Jun 11, 2020
7b32d98
Migrated schema for dictionary to Register
Jun 11, 2020
77f3294
Migrated schema for director to Register
Jun 11, 2020
fb73d0e
Migrated schema for domain to Register
Jun 11, 2020
a2c5fa8
Migrated schema for dynamicsnippt to Register
Jun 11, 2020
9b00033
Migrated schema for gcslogging to Register
Jun 11, 2020
0f91189
Migrated schema for gzip to Register
Jun 11, 2020
362b056
Migrated schema for header to Register
Jun 11, 2020
06d7ee6
Migrated schema for healthcheck to Register
Jun 11, 2020
b8fbd42
Migrated schema for httpslogging to Register
Jun 11, 2020
1d4992a
Migrated schema for logentries to Register
Jun 11, 2020
ff18767
Migrated schema for papertrail to Register
Jun 11, 2020
3d150e1
Migrated schema for requestsetting to Register
Jun 11, 2020
47d1119
Migrated schema for responseobject to Register
Jun 11, 2020
c7c9de8
Migrated schema for s3logging to Register
Jun 11, 2020
da99b9a
Migrated schema for snippet to Register
Jun 11, 2020
377d4df
Migrated schema for splunk to Register
Jun 11, 2020
896be40
Migrated schema for sumologic to Register
Jun 11, 2020
3fda396
Migrated schema for syslog to Register
Jun 11, 2020
df4d5de
Migrated schema for vcl to Register
Jun 11, 2020
6fdc9b3
Factored out settings (default_host && default_ttl)
Jun 12, 2020
67c1c59
Post rebase tidy up
Jun 12, 2020
b680962
Migrated SFTP to Register
Jun 15, 2020
38d7002
Factored out settings (default_host && default_ttl)
Jun 12, 2020
d590d16
Post rebase tidy up
Jun 12, 2020
18532e0
Migrated service to base service
Jun 12, 2020
97b011f
Added initial WASM configuration
Jun 12, 2020
a227f70
Documented base_fastly_service_v1.go
Jun 15, 2020
6cbc661
Corrected LogEntries to Logentries
Jun 15, 2020
7e0a9ae
Removed WASM definition from this branch
Jun 16, 2020
431bec3
make fmt
Jun 16, 2020
e84f5b3
Minor fixes to cherry pick
Jun 16, 2020
3975aa5
Refactored documentation
Jun 16, 2020
53b2380
Matched up default format to tests
Jun 16, 2020
2c7f7e4
Fixed some of the tests - migrated certs to their own file since EOF …
Jun 16, 2020
8732312
Renamed AttributeHandlers
Jun 16, 2020
b0b7c1a
Updated comments
Jun 16, 2020
1276189
Converted over new logging blocks to Handlers
Jun 17, 2020
544c90e
Refactored to changes to S3 logging
Jun 17, 2020
d2daeb8
Tidy up from commit history
Jun 19, 2020
fa96876
Migrated Scalyr and GooglePubSub to handlers
Jun 19, 2020
97562e8
Migrated from EOF to Terraform file command
Jun 19, 2020
d60a282
make fmt
Jun 19, 2020
c5a2c8d
Migrated Kafka Logging over to AttributeHandler
Jun 19, 2020
a7d7cb5
Migrated literal block keys to h.GetKey()
Jun 19, 2020
899c040
Migrated keys to test_fixtures directory
Jun 19, 2020
e02b062
Added t *testing.T to key functions to bind into test process
Jun 19, 2020
b679ba6
Fixed Fatalf error
Jun 19, 2020
bb027a4
Tidy of logging_sftp
Jun 23, 2020
36a5e95
A few more literal string --> h.GetKey()
Jun 23, 2020
f17d566
WASM --> Wasm
Jun 23, 2020
c8e3694
Added full-stops to comments
Jun 23, 2020
e9e448a
Extra comments for MustProcess
Jun 23, 2020
9eeaff9
Comments for attribute handler loops
Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
482 changes: 482 additions & 0 deletions fastly/base_fastly_service_v1.go

Large diffs are not rendered by default.

59 changes: 37 additions & 22 deletions fastly/block_fastly_service_v1_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,20 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

var aclSchema = &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// Required fields
"name": {
Type: schema.TypeString,
Required: true,
Description: "Unique name to refer to this ACL",
},
// Optional fields
"acl_id": {
Type: schema.TypeString,
Computed: true,
Description: "Generated acl id",
},
type ACLServiceAttributeHandler struct {
*DefaultServiceAttributeHandler
}

func NewServiceACL() ServiceAttributeDefinition {
return &ACLServiceAttributeHandler{
&DefaultServiceAttributeHandler{
key: "acl",
},
},
}
}

func processACL(d *schema.ResourceData, conn *gofastly.Client, latestVersion int) error {
oldACLVal, newACLVal := d.GetChange("acl")
func (h *ACLServiceAttributeHandler) Process(d *schema.ResourceData, latestVersion int, conn *gofastly.Client) error {
oldACLVal, newACLVal := d.GetChange(h.GetKey())
if oldACLVal == nil {
oldACLVal = new(schema.Set)
}
Expand Down Expand Up @@ -83,7 +74,7 @@ func processACL(d *schema.ResourceData, conn *gofastly.Client, latestVersion int
return nil
}

func readACL(conn *gofastly.Client, d *schema.ResourceData, s *gofastly.ServiceDetail) error {
func (h *ACLServiceAttributeHandler) Read(d *schema.ResourceData, s *gofastly.ServiceDetail, conn *gofastly.Client) error {

log.Printf("[DEBUG] Refreshing ACLs for (%s)", d.Id())
aclList, err := conn.ListACLs(&gofastly.ListACLsInput{
Expand All @@ -96,13 +87,37 @@ func readACL(conn *gofastly.Client, d *schema.ResourceData, s *gofastly.ServiceD

al := flattenACLs(aclList)

if err := d.Set("acl", al); err != nil {
if err := d.Set(h.GetKey(), al); err != nil {
log.Printf("[WARN] Error setting ACLs for (%s): %s", d.Id(), err)
}

return nil
}

func (h *ACLServiceAttributeHandler) Register(s *schema.Resource) error {
s.Schema[h.GetKey()] = &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
// Required fields
"name": {
Type: schema.TypeString,
Required: true,
Description: "Unique name to refer to this ACL",
},
// Optional fields
"acl_id": {
Type: schema.TypeString,
Computed: true,
Description: "Generated acl id",
},
},
},
}
return nil
}

func flattenACLs(aclList []*gofastly.ACL) []map[string]interface{} {
var al []map[string]interface{}
for _, acl := range aclList {
Expand Down
Loading