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 #267

Closed
wants to merge 88 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d367e63
Added missing readFTP and readElasticsearch functions
Jun 12, 2020
d3fdfe1
Removed readFTP and readElasticsearch to align with master
Jun 12, 2020
7978ed7
Migrated bigquerylogging to attribute handler
Jun 11, 2020
a64d58f
Migrated blobstoragelogging to attribute handler
Jun 11, 2020
ab52a7b
Migrated cachesetting to attribute handler
Jun 11, 2020
81992eb
Migrated condition to attribute handler
Jun 11, 2020
86317f4
Migrated dictionary to attribute handler
Jun 11, 2020
7c959d6
Migrated director to attribute handler
Jun 11, 2020
f4b905b
Migrated domain to attribute handler
Jun 11, 2020
96ab33a
Migrated dynamicsnippet to attribute handler
Jun 11, 2020
c5e34ef
Incorrect key for domain
Jun 11, 2020
4a53427
Migrated gcslogging to attribute handler
Jun 11, 2020
7be4498
Migrated gzip to attribute handler
Jun 11, 2020
8780f90
Migrated header to attribute handler
Jun 11, 2020
e0ec7f6
Migrated healthcheck to attribute handler
Jun 11, 2020
d11ca5f
Migrated httpslogging to attribute handler
Jun 11, 2020
4778654
Migrated logentries to attribute handler
Jun 11, 2020
5e7f027
Migrated papertrail to attribute handler
Jun 11, 2020
add2e3b
Migrated requestsetting to attribute handler
Jun 11, 2020
44c81c1
Migrated responseobject to attribute handler
Jun 11, 2020
23d05d5
Migrated s3logging to attribute handler
Jun 11, 2020
83661e3
Migrated snippet to attribute handler
Jun 11, 2020
e3bcde4
Migrated splunk and sumologic to attribute handler
Jun 11, 2020
47d0808
Sumologic error
Jun 11, 2020
053a364
Migrated syslogic to attribute handler
Jun 11, 2020
7578ae9
Migrated vcl to attribute handler
Jun 11, 2020
dbb7bf9
Tidy up
Jun 11, 2020
5e6c3ef
Refactored to make a bit more DRY
Jun 11, 2020
7b4c256
make fmt
Jun 12, 2020
479f78f
Refactored ElasticSearch & FTP to handler (and ACL which had regresse…
Jun 12, 2020
ecf3a63
Tidy up cherry-pick
Jun 15, 2020
d710437
Readded elasticsearch and ftp logging Read
Jun 15, 2020
ad9edcf
Renamed BigQueryLogging test file
Jun 15, 2020
281ba8a
Migrated LogEntries to Logentries
Jun 15, 2020
92490e4
Update fastly/block_fastly_service_v1_logentries.go
guyrichardson-ockl Jun 15, 2020
7552105
Migrated blobstoragelogging to attribute handler
Jun 11, 2020
b0faedc
Migrated logentries to attribute handler
Jun 11, 2020
017233a
Refactored Logentries
Jun 15, 2020
85020d5
Migrated schema for blobstoragelogging to Register
Jun 11, 2020
0cdaed7
Migrated schema for cachesetting to Register
Jun 11, 2020
fd6a9f3
Migrated schema for condition to Register
Jun 11, 2020
b22ee51
Migrated schema for dictionary to Register
Jun 11, 2020
619849a
Migrated schema for director to Register
Jun 11, 2020
dd4e464
Migrated schema for domain to Register
Jun 11, 2020
3757875
Migrated schema for dynamicsnippt to Register
Jun 11, 2020
638d52a
Migrated schema for gcslogging to Register
Jun 11, 2020
7697b50
Migrated schema for gzip to Register
Jun 11, 2020
704f46f
Migrated schema for header to Register
Jun 11, 2020
45cb119
Migrated schema for healthcheck to Register
Jun 11, 2020
138cd4b
Migrated schema for httpslogging to Register
Jun 11, 2020
c13152c
Migrated schema for logentries to Register
Jun 11, 2020
a4b163c
Migrated schema for papertrail to Register
Jun 11, 2020
c7cd8c9
Migrated schema for requestsetting to Register
Jun 11, 2020
74d2699
Migrated schema for responseobject to Register
Jun 11, 2020
203f5f4
Migrated schema for s3logging to Register
Jun 11, 2020
74a4e81
Migrated schema for snippet to Register
Jun 11, 2020
5b3f65e
Migrated schema for splunk to Register
Jun 11, 2020
6fa72bf
Migrated schema for sumologic to Register
Jun 11, 2020
0f7eaa1
Migrated schema for syslog to Register
Jun 11, 2020
4d8a98a
Migrated schema for vcl to Register
Jun 11, 2020
258f173
Factored out settings (default_host && default_ttl)
Jun 12, 2020
2f043fa
Post rebase tidy up
Jun 12, 2020
df2ffd2
Migrated SFTP to Register
Jun 15, 2020
08d5574
Factored out settings (default_host && default_ttl)
Jun 12, 2020
bc9df8e
Post rebase tidy up
Jun 12, 2020
7449355
Migrated service to base service
Jun 12, 2020
e1da0b0
Added initial WASM configuration
Jun 12, 2020
f7f5de5
Documented base_fastly_service_v1.go
Jun 15, 2020
3b75928
Corrected LogEntries to Logentries
Jun 15, 2020
725e5a9
Removed WASM definition from this branch
Jun 16, 2020
153520f
make fmt
Jun 16, 2020
d9aa6f4
Minor fixes to cherry pick
Jun 16, 2020
dd39a25
Refactored documentation
Jun 16, 2020
e38240e
Matched up default format to tests
Jun 16, 2020
332a4f4
Fixed some of the tests - migrated certs to their own file since EOF …
Jun 16, 2020
49be303
Renamed AttributeHandlers
Jun 16, 2020
39c9637
Updated comments
Jun 16, 2020
5d1baff
Converted over new logging blocks to Handlers
Jun 17, 2020
053e1bf
Refactored to changes to S3 logging
Jun 17, 2020
8a0f559
Tidy up from commit history
Jun 19, 2020
746c1c0
Migrated Scalyr and GooglePubSub to handlers
Jun 19, 2020
b6eecea
Migrated from EOF to Terraform file command
Jun 19, 2020
53f1b97
make fmt
Jun 19, 2020
cfcd0f5
Migrated Kafka Logging over to AttributeHandler
Jun 19, 2020
d159492
Migrated literal block keys to h.GetKey()
Jun 19, 2020
78a3f5d
Migrated keys to test_fixtures directory
Jun 19, 2020
bb03b73
Added t *testing.T to key functions to bind into test process
Jun 19, 2020
46ed794
Fixed Fatalf error
Jun 19, 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