-
Notifications
You must be signed in to change notification settings - Fork 565
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
Unable to create lifecycle rules to cleanup old versions #2611
base: master
Are you sure you want to change the base?
Changes from 8 commits
3c7889f
36da279
6eae18c
eaef261
71d0601
1dd76d4
8f6a6fe
0a69222
4a4ae63
69d54f5
960a6f8
92d7b90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,20 @@ func resourceAlicloudOssBucket() *schema.Resource { | |
}, | ||
}, | ||
}, | ||
"noncurrent_version_expiration": { | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"days": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
ValidateFunc: validation.IntAtLeast(1), | ||
}, | ||
}, | ||
}, | ||
}, | ||
"transitions": { | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
|
@@ -204,6 +218,30 @@ func resourceAlicloudOssBucket() *schema.Resource { | |
}, | ||
}, | ||
}, | ||
"noncurrent_version_transition": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个接口实现有问题。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @huiguangjun , it seems like the go sdk currently does not support the above said configuration. I have made changes as per the go sdk. Here is the goDoc for Lifecycle Rules struct - https://godoc.org/github.com/aliyun/aliyun-oss-go-sdk/oss#LifecycleRule The Also, it would be great if you continue conversation in english :) ! I have to translate the above comment :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @huiguangjun any updates on this ? Let me know your thoughts. |
||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Optional: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"days": { | ||
Type: schema.TypeInt, | ||
Optional: true, | ||
ValidateFunc: validation.IntAtLeast(1), | ||
}, | ||
"storage_class": { | ||
Type: schema.TypeString, | ||
Default: oss.StorageStandard, | ||
Optional: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(oss.StorageStandard), | ||
string(oss.StorageIA), | ||
string(oss.StorageArchive), | ||
}, false), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
MaxItems: 1000, | ||
|
@@ -932,6 +970,18 @@ func resourceAlicloudOssBucketLifecycleRuleUpdate(client *connectivity.AliyunCli | |
rule.Expiration = &i | ||
} | ||
|
||
//NoncurrentVersionExpiration | ||
nc_expiration := d.Get(fmt.Sprintf("lifecycle_rule.%d.noncurrent_version_expiration", i)).(*schema.Set).List() | ||
if len(nc_expiration) > 0 && nc_expiration[0] != nil { | ||
e := nc_expiration[0].(map[string]interface{}) | ||
i := oss.LifecycleVersionExpiration{} | ||
|
||
if val, ok := e["days"].(int); ok && val > 0 { | ||
i.NoncurrentDays = val | ||
rule.NonVersionExpiration = &i | ||
} | ||
} | ||
|
||
// Transitions | ||
transitions := d.Get(fmt.Sprintf("lifecycle_rule.%d.transitions", i)).(*schema.Set).List() | ||
if len(transitions) > 0 { | ||
|
@@ -960,6 +1010,20 @@ func resourceAlicloudOssBucketLifecycleRuleUpdate(client *connectivity.AliyunCli | |
} | ||
} | ||
|
||
// NoncurrentVersionTransition | ||
nc_transition := d.Get(fmt.Sprintf("lifecycle_rule.%d.noncurrent_version_transition", i)).(*schema.Set).List() | ||
if len(nc_transition) > 0 && nc_expiration[0] != nil { | ||
e := nc_transition[0].(map[string]interface{}) | ||
i := oss.LifecycleVersionTransition{} | ||
valDays := e["days"].(int) | ||
valStorageClass := e["storage_class"].(string) | ||
|
||
i.NoncurrentDays = valDays | ||
i.StorageClass = oss.StorageClassType(valStorageClass) | ||
|
||
rule.NonVersionTransition = &i | ||
} | ||
|
||
rules = append(rules, rule) | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是否需要和之前 expiration 类型保持一致?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have this changed to
schema.TypeSet
. Modified the code as per the same.