Skip to content

Commit c625ff0

Browse files
authored
Merge pull request #87 from spring-media/chore/OTT-6361
Chore/ott 6361
2 parents 3298ec4 + c11fdca commit c625ff0

8 files changed

+408
-394
lines changed

awsmt/data_source_source_location.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package awsmt
22

33
import (
44
"context"
5-
"github.com/aws/aws-sdk-go/service/mediatailor"
5+
"github.com/aws/aws-sdk-go-v2/service/mediatailor"
66
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
77
"github.com/hashicorp/terraform-plugin-framework/datasource"
88
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
@@ -19,7 +19,7 @@ func DataSourceSourceLocation() datasource.DataSource {
1919
}
2020

2121
type dataSourceSourceLocation struct {
22-
client *mediatailor.MediaTailor
22+
client *mediatailor.Client
2323
}
2424

2525
func (d *dataSourceSourceLocation) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
@@ -84,7 +84,7 @@ func (d *dataSourceSourceLocation) Configure(_ context.Context, req datasource.C
8484
return
8585
}
8686

87-
d.client = req.ProviderData.(clients).v1
87+
d.client = req.ProviderData.(clients).v2
8888
}
8989

9090
func (d *dataSourceSourceLocation) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
@@ -97,13 +97,13 @@ func (d *dataSourceSourceLocation) Read(ctx context.Context, req datasource.Read
9797

9898
sourceLocationName := data.Name
9999

100-
sourceLocation, err := d.client.DescribeSourceLocation(&mediatailor.DescribeSourceLocationInput{SourceLocationName: sourceLocationName})
100+
sourceLocation, err := d.client.DescribeSourceLocation(ctx, &mediatailor.DescribeSourceLocationInput{SourceLocationName: sourceLocationName})
101101
if err != nil {
102102
resp.Diagnostics.AddError("Error while describing source location", err.Error())
103103
return
104104
}
105105

106-
data = readSourceLocationToPlan(data, mediatailor.CreateSourceLocationOutput(*sourceLocation))
106+
data = writeSourceLocationToPlan(data, mediatailor.CreateSourceLocationOutput(*sourceLocation), false)
107107

108108
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
109109
}

awsmt/helpers_channels.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"github.com/aws/aws-sdk-go-v2/service/mediatailor"
77
awsTypes "github.com/aws/aws-sdk-go-v2/service/mediatailor/types"
8-
"github.com/aws/aws-sdk-go/aws"
98
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
109
"github.com/hashicorp/terraform-plugin-framework/types"
1110
"reflect"
@@ -230,11 +229,11 @@ func readChannelComputedValues(model channelModel, arn *string, channelName *str
230229
model.Name = channelName
231230

232231
if creationTime != nil {
233-
model.CreationTime = types.StringValue((aws.TimeValue(creationTime)).String())
232+
model.CreationTime = types.StringValue(creationTime.String())
234233
}
235234

236235
if lastModifiedTime != nil {
237-
model.LastModifiedTime = types.StringValue((aws.TimeValue(lastModifiedTime)).String())
236+
model.LastModifiedTime = types.StringValue(lastModifiedTime.String())
238237
}
239238

240239
return model

awsmt/helpers_common.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,11 @@ import (
44
"context"
55
"fmt"
66
mediatailorV2 "github.com/aws/aws-sdk-go-v2/service/mediatailor"
7-
"github.com/aws/aws-sdk-go/aws"
8-
"github.com/aws/aws-sdk-go/service/mediatailor"
97
"github.com/hashicorp/terraform-plugin-framework/path"
108
"github.com/hashicorp/terraform-plugin-framework/resource"
11-
"reflect"
129
"strings"
1310
)
1411

15-
func untagResource(client *mediatailor.MediaTailor, oldTags map[string]*string, resourceArn string) error {
16-
var removeTags []*string
17-
for k := range oldTags {
18-
removeTags = append(removeTags, aws.String(k))
19-
}
20-
_, err := client.UntagResource(&mediatailor.UntagResourceInput{ResourceArn: &resourceArn, TagKeys: removeTags})
21-
if err != nil {
22-
return err
23-
}
24-
return nil
25-
}
26-
27-
func tagResource(client *mediatailor.MediaTailor, newTags map[string]*string, resourceArn string) error {
28-
_, err := client.TagResource(&mediatailor.TagResourceInput{ResourceArn: &resourceArn, Tags: newTags})
29-
if err != nil {
30-
return err
31-
}
32-
return nil
33-
}
34-
35-
func updatesTags(client *mediatailor.MediaTailor, oldTags map[string]*string, newTags map[string]*string, resourceArn string) error {
36-
if !reflect.DeepEqual(oldTags, newTags) {
37-
if err := untagResource(client, oldTags, resourceArn); err != nil {
38-
return err
39-
}
40-
if err := tagResource(client, newTags, resourceArn); err != nil {
41-
return err
42-
}
43-
}
44-
return nil
45-
}
46-
4712
func v2Untag(client *mediatailorV2.Client, oldTags map[string]string, resourceArn string) error {
4813
var removeTags []string
4914
for k := range oldTags {

0 commit comments

Comments
 (0)