Skip to content

Commit

Permalink
golanci-lint fix: remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Jan 27, 2022
1 parent 6ae050b commit 1c9cc90
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions internal/service/s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1583,80 +1583,6 @@ func resourceBucketCorsUpdate(conn *s3.S3, d *schema.ResourceData) error {
return nil
}

func resourceBucketWebsitePut(conn *s3.S3, d *schema.ResourceData, website map[string]interface{}) error {
bucket := d.Get("bucket").(string)

var indexDocument, errorDocument, redirectAllRequestsTo, routingRules string
if v, ok := website["index_document"]; ok {
indexDocument = v.(string)
}
if v, ok := website["error_document"]; ok {
errorDocument = v.(string)
}
if v, ok := website["redirect_all_requests_to"]; ok {
redirectAllRequestsTo = v.(string)
}
if v, ok := website["routing_rules"]; ok {
routingRules = v.(string)
}

if indexDocument == "" && redirectAllRequestsTo == "" {
return fmt.Errorf("Must specify either index_document or redirect_all_requests_to.")
}

websiteConfiguration := &s3.WebsiteConfiguration{}

if indexDocument != "" {
websiteConfiguration.IndexDocument = &s3.IndexDocument{Suffix: aws.String(indexDocument)}
}

if errorDocument != "" {
websiteConfiguration.ErrorDocument = &s3.ErrorDocument{Key: aws.String(errorDocument)}
}

if redirectAllRequestsTo != "" {
redirect, err := url.Parse(redirectAllRequestsTo)
if err == nil && redirect.Scheme != "" {
var redirectHostBuf bytes.Buffer
redirectHostBuf.WriteString(redirect.Host)
if redirect.Path != "" {
redirectHostBuf.WriteString(redirect.Path)
}
if redirect.RawQuery != "" {
redirectHostBuf.WriteString("?")
redirectHostBuf.WriteString(redirect.RawQuery)
}
websiteConfiguration.RedirectAllRequestsTo = &s3.RedirectAllRequestsTo{HostName: aws.String(redirectHostBuf.String()), Protocol: aws.String(redirect.Scheme)}
} else {
websiteConfiguration.RedirectAllRequestsTo = &s3.RedirectAllRequestsTo{HostName: aws.String(redirectAllRequestsTo)}
}
}

if routingRules != "" {
var unmarshaledRules []*s3.RoutingRule
if err := json.Unmarshal([]byte(routingRules), &unmarshaledRules); err != nil {
return err
}
websiteConfiguration.RoutingRules = unmarshaledRules
}

putInput := &s3.PutBucketWebsiteInput{
Bucket: aws.String(bucket),
WebsiteConfiguration: websiteConfiguration,
}

log.Printf("[DEBUG] S3 put bucket website: %#v", putInput)

_, err := verify.RetryOnAWSCode(s3.ErrCodeNoSuchBucket, func() (interface{}, error) {
return conn.PutBucketWebsite(putInput)
})
if err != nil {
return fmt.Errorf("Error putting S3 website: %s", err)
}

return nil
}

func websiteEndpoint(client *conns.AWSClient, d *schema.ResourceData) (*S3Website, error) {
// If the bucket doesn't have a website configuration, return an empty
// endpoint
Expand Down

0 comments on commit 1c9cc90

Please sign in to comment.