Skip to content

Commit

Permalink
fix: migrate source location to aws go sdk v2
Browse files Browse the repository at this point in the history
OTT-6334
  • Loading branch information
thatsddr committed Aug 30, 2024
1 parent 3298ec4 commit 6f04b74
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 272 deletions.
10 changes: 5 additions & 5 deletions awsmt/data_source_source_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package awsmt

import (
"context"
"github.com/aws/aws-sdk-go/service/mediatailor"
"github.com/aws/aws-sdk-go-v2/service/mediatailor"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -19,7 +19,7 @@ func DataSourceSourceLocation() datasource.DataSource {
}

type dataSourceSourceLocation struct {
client *mediatailor.MediaTailor
client *mediatailor.Client
}

func (d *dataSourceSourceLocation) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
Expand Down Expand Up @@ -84,7 +84,7 @@ func (d *dataSourceSourceLocation) Configure(_ context.Context, req datasource.C
return
}

d.client = req.ProviderData.(clients).v1
d.client = req.ProviderData.(clients).v2
}

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

sourceLocationName := data.Name

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

data = readSourceLocationToPlan(data, mediatailor.CreateSourceLocationOutput(*sourceLocation))
data = writeSourceLocationToPlan(data, mediatailor.CreateSourceLocationOutput(*sourceLocation))

resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}
5 changes: 2 additions & 3 deletions awsmt/helpers_channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/aws/aws-sdk-go-v2/service/mediatailor"
awsTypes "github.com/aws/aws-sdk-go-v2/service/mediatailor/types"
"github.com/aws/aws-sdk-go/aws"
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
"github.com/hashicorp/terraform-plugin-framework/types"
"reflect"
Expand Down Expand Up @@ -230,11 +229,11 @@ func readChannelComputedValues(model channelModel, arn *string, channelName *str
model.Name = channelName

if creationTime != nil {
model.CreationTime = types.StringValue((aws.TimeValue(creationTime)).String())
model.CreationTime = types.StringValue(creationTime.String())
}

if lastModifiedTime != nil {
model.LastModifiedTime = types.StringValue((aws.TimeValue(lastModifiedTime)).String())
model.LastModifiedTime = types.StringValue(lastModifiedTime.String())
}

return model
Expand Down
Loading

0 comments on commit 6f04b74

Please sign in to comment.