Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion tencentcloud/resource_tc_ci_bucket_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func testAccCheckCiBucketAttachmentExists(re string) resource.TestCheckFunc {
const testAccCiBucketAttachment = `

resource "tencentcloud_ci_bucket_attachment" "bucket_attachment" {
bucket = "terraform-ci-1308919341"
bucket = "terraform-ci-test-1308919341"
}

`
54 changes: 27 additions & 27 deletions tencentcloud/resource_tc_ci_media_animation_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ resource "tencentcloud_ci_media_animation_template" "media_animation_template" {
}
}
```

Import

ci media_animation_template can be imported using the bucket#templateId, e.g.

```
terraform import tencentcloud_ci_media_animation_template.media_animation_template terraform-ci-xxxxxx#t18210645f96564eaf80e86b1f58c20152
```
*/
package tencentcloud

Expand All @@ -58,9 +50,9 @@ func resourceTencentCloudCiMediaAnimationTemplate() *schema.Resource {
Read: resourceTencentCloudCiMediaAnimationTemplateRead,
Update: resourceTencentCloudCiMediaAnimationTemplateUpdate,
Delete: resourceTencentCloudCiMediaAnimationTemplateDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
// Importer: &schema.ResourceImporter{
// State: schema.ImportStatePassthrough,
// },
Schema: map[string]*schema.Schema{
"bucket": {
Required: true,
Expand Down Expand Up @@ -244,7 +236,7 @@ func resourceTencentCloudCiMediaAnimationTemplateCreate(d *schema.ResourceData,
if e != nil {
return retryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%v], response body [%v]\n", logId, "CreateMediaAnimationTemplate", request, result)
log.Printf("[DEBUG]%s api[%s] success, request body [%+v], response body [%+v]\n", logId, "CreateMediaAnimationTemplate", request, result)
}
response = result
return nil
Expand Down Expand Up @@ -287,11 +279,13 @@ func resourceTencentCloudCiMediaAnimationTemplateRead(d *schema.ResourceData, me
return fmt.Errorf("resource `track` %s does not exist", d.Id())
}

_ = d.Set("bucket", bucket)

if template.Name != "" {
_ = d.Set("name", template.Name)
}

mediaAnimationTemplate := template.Animation
mediaAnimationTemplate := template.TransTpl
if mediaAnimationTemplate != nil {
if mediaAnimationTemplate.Container != nil {
containerMap := map[string]interface{}{}
Expand Down Expand Up @@ -322,23 +316,26 @@ func resourceTencentCloudCiMediaAnimationTemplateRead(d *schema.ResourceData, me
videoMap["fps"] = mediaAnimationTemplate.Video.Fps
}

if mediaAnimationTemplate.Video.AnimateOnlyKeepKeyFrame != "" {
videoMap["animate_only_keep_key_frame"] = mediaAnimationTemplate.Video.AnimateOnlyKeepKeyFrame
}
// if mediaAnimationTemplate.Video.AnimateOnlyKeepKeyFrame != "" {
// videoMap["animate_only_keep_key_frame"] = mediaAnimationTemplate.Video.AnimateOnlyKeepKeyFrame
// }

if mediaAnimationTemplate.Video.AnimateTimeIntervalOfFrame != "" {
videoMap["animate_time_interval_of_frame"] = mediaAnimationTemplate.Video.AnimateTimeIntervalOfFrame
}
// if mediaAnimationTemplate.Video.AnimateTimeIntervalOfFrame != "" {
// videoMap["animate_time_interval_of_frame"] = mediaAnimationTemplate.Video.AnimateTimeIntervalOfFrame
// }

if mediaAnimationTemplate.Video.AnimateFramesPerSecond != "" {
videoMap["animate_frames_per_second"] = mediaAnimationTemplate.Video.AnimateFramesPerSecond
}
// if mediaAnimationTemplate.Video.AnimateFramesPerSecond != "" {
// videoMap["animate_frames_per_second"] = mediaAnimationTemplate.Video.AnimateFramesPerSecond
// }

if mediaAnimationTemplate.Video.Quality != "" {
videoMap["quality"] = mediaAnimationTemplate.Video.Quality
}
// if mediaAnimationTemplate.Video.Quality != "" {
// videoMap["quality"] = mediaAnimationTemplate.Video.Quality
// }

_ = d.Set("video", []interface{}{videoMap})
err = d.Set("video", []interface{}{videoMap})
if err != nil {
return err
}
}

if mediaAnimationTemplate.TimeInterval != nil {
Expand All @@ -352,7 +349,10 @@ func resourceTencentCloudCiMediaAnimationTemplateRead(d *schema.ResourceData, me
timeIntervalMap["duration"] = mediaAnimationTemplate.TimeInterval.Duration
}

_ = d.Set("time_interval", []interface{}{timeIntervalMap})
err = d.Set("time_interval", []interface{}{timeIntervalMap})
if err != nil {
return err
}
}
}

Expand Down
148 changes: 119 additions & 29 deletions tencentcloud/resource_tc_ci_media_animation_template_test.go
Original file line number Diff line number Diff line change
@@ -1,56 +1,146 @@
package tencentcloud

import (
"context"
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

// go test -i; go test -test.run TestAccTencentCloudCiMediaAnimationTemplateResource_basic -v
func TestAccTencentCloudCiMediaAnimationTemplateResource_basic(t *testing.T) {
t.Parallel()

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCiMediaAnimationTemplateDestroy,
Steps: []resource.TestStep{
{
Config: testAccCiMediaAnimationTemplate,
Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_ci_media_animation_template.media_animation_template", "id")),
},
{
ResourceName: "tencentcloud_ci_media_animation_template.media_animation_template",
ImportState: true,
ImportStateVerify: true,
Check: resource.ComposeTestCheckFunc(
testAccCheckCiMediaAnimationTemplateExists("tencentcloud_ci_media_animation_template.media_animation_template"),
resource.TestCheckResourceAttrSet("tencentcloud_ci_media_animation_template.media_animation_template", "id"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "bucket", defaultCiBucket),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "name", "animation_template_test"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "container.#", "1"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "container.0.format", "gif"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.#", "1"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.0.codec", "gif"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.0.width", "1280"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.0.height", ""),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.0.fps", "20"),
// resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "video.0.animate_only_keep_key_frame", "true"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "time_interval.#", "1"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "time_interval.0.start", "0"),
resource.TestCheckResourceAttr("tencentcloud_ci_media_animation_template.media_animation_template", "time_interval.0.duration", "60"),
),
},
// {
// ResourceName: "tencentcloud_ci_media_animation_template.media_animation_template",
// ImportState: true,
// ImportStateVerify: true,
// },
},
})
}

const testAccCiMediaAnimationTemplate = `
func testAccCheckCiMediaAnimationTemplateDestroy(s *terraform.State) error {
logId := getLogId(contextNil)
ctx := context.WithValue(context.TODO(), logIdKey, logId)
service := CiService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn}
for _, rs := range s.RootModule().Resources {
if rs.Type != "tencentcloud_ci_media_animation_template" {
continue
}

resource "tencentcloud_ci_media_animation_template" "media_animation_template" {
name = <nil>
container {
format = <nil>
idSplit := strings.Split(rs.Primary.ID, FILED_SP)
if len(idSplit) != 2 {
return fmt.Errorf("id is broken,%s", rs.Primary.ID)
}
bucket := idSplit[0]
templateId := idSplit[1]

}
video {
codec = <nil>
width = <nil>
height = <nil>
fps = <nil>
animate_only_keep_key_frame = <nil>
animate_time_interval_of_frame = <nil>
animate_frames_per_second = <nil>
quality = <nil>
res, err := service.DescribeCiMediaTemplateById(ctx, bucket, templateId)
if err != nil {
return err
}

}
time_interval {
start = <nil>
duration = <nil>
if res != nil {
return fmt.Errorf("ci media animation template still exist, Id: %v\n", rs.Primary.ID)
}
}
return nil
}

func testAccCheckCiMediaAnimationTemplateExists(re string) resource.TestCheckFunc {
return func(s *terraform.State) error {
logId := getLogId(contextNil)
ctx := context.WithValue(context.TODO(), logIdKey, logId)
service := CiService{client: testAccProvider.Meta().(*TencentCloudClient).apiV3Conn}

rs, ok := s.RootModule().Resources[re]
if !ok {
return fmt.Errorf("ci media animation template %s is not found", re)
}
if rs.Primary.ID == "" {
return fmt.Errorf(" id is not set")
}

idSplit := strings.Split(rs.Primary.ID, FILED_SP)
if len(idSplit) != 2 {
return fmt.Errorf("id is broken,%s", rs.Primary.ID)
}
bucket := idSplit[0]
templateId := idSplit[1]

result, err := service.DescribeCiMediaTemplateById(ctx, bucket, templateId)
if err != nil {
return err
}

if result == nil {
return fmt.Errorf("ci media animation template not found, Id: %v", rs.Primary.ID)
}

return nil
}
}

const testAccCiMediaAnimationTemplateVar = `
variable "bucket" {
default = "` + defaultCiBucket + `"
}

`

const testAccCiMediaAnimationTemplate = testAccCiMediaAnimationTemplateVar + `

resource "tencentcloud_ci_media_animation_template" "media_animation_template" {
bucket = var.bucket
name = "animation_template_test"
container {
format = "gif"
}
video {
codec = "gif"
width = "1280"
height = ""
fps = "20"
animate_only_keep_key_frame = ""
animate_time_interval_of_frame = ""
animate_frames_per_second = ""
quality = ""

}
time_interval {
start = "0"
duration = "60"

}
}

`
12 changes: 8 additions & 4 deletions tencentcloud/resource_tc_ci_media_concat_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "tencentcloud_ci_media_concat_template" "media_concat_template" {
codec = "H.264"
width = "1280"
height = ""
bitrate = "1000"
bitrate = "1000"
fps = "25"
crf = ""
remove = ""
Expand All @@ -43,7 +43,7 @@ resource "tencentcloud_ci_media_concat_template" "media_concat_template" {
enable_start_fadein = "true"
start_fadein_time = "3"
enable_end_fadeout = "false"
end_fadeout_time = "0"
end_fadeout_time = "0.1"
enable_bgm_fade = "true"
bgm_fade_time = "1.7"
}
Expand Down Expand Up @@ -193,6 +193,7 @@ func resourceTencentCloudCiMediaConcatTemplate() *schema.Resource {
"remove": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Whether to delete the source audio stream, the value is true, false.",
},
"rotate": {
Expand Down Expand Up @@ -264,6 +265,7 @@ func resourceTencentCloudCiMediaConcatTemplate() *schema.Resource {
"end_fadeout_time": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "fade out time, greater than 0, support floating point numbers.",
},
"enable_bgm_fade": {
Expand Down Expand Up @@ -469,6 +471,8 @@ func resourceTencentCloudCiMediaConcatTemplateRead(d *schema.ResourceData, meta
return fmt.Errorf("resource `track` %s does not exist", d.Id())
}

_ = d.Set("bucket", bucket)

if mediaConcatTemplate.Name != "" {
_ = d.Set("name", mediaConcatTemplate.Name)
}
Expand All @@ -488,7 +492,7 @@ func resourceTencentCloudCiMediaConcatTemplateRead(d *schema.ResourceData, meta
}
concatFragmentList = append(concatFragmentList, concatFragmentMap)
}
concatTemplateMap["concat_fragment"] = []interface{}{concatFragmentList}
concatTemplateMap["concat_fragment"] = concatFragmentList
}

if mediaConcatTemplate.ConcatTemplate.Audio != nil {
Expand Down Expand Up @@ -611,7 +615,7 @@ func resourceTencentCloudCiMediaConcatTemplateRead(d *schema.ResourceData, meta
audioMixList = append(audioMixList, audioMixMap)
}

concatTemplateMap["audio_mix"] = []interface{}{audioMixList}
concatTemplateMap["audio_mix"] = audioMixList
}

_ = d.Set("concat_template", []interface{}{concatTemplateMap})
Expand Down
Loading