Skip to content
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

aws[s3]: Add versioning support #1085

Merged
merged 1 commit into from Jan 29, 2019

Conversation

PsyanticY
Copy link
Contributor

No description provided.

@@ -40,6 +40,12 @@ with lib;
description = "The JSON lifecycle management string to apply to the bucket.";
};

versioning = mkOption {
default = "Suspended";
type = types.str;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a string, should use an enum:

unit = mkOption {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type = types.str;
type = types.enum [ "Suspended" "Enabled" ];

should do it, I think (please test it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Updated ( and tested)

@@ -105,10 +107,21 @@ def create(self, defn, check, allow_reboot, allow_recreate):
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] != "BucketAlreadyOwnedByYou": raise

try:
current = s3client.get_bucket_versioning(Bucket=defn.bucket_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is more correct but we typically check against the api only with --check or within the _check() method. The assumption is that nixops is the only thing updating the bucket config, so we should check against self.versioning.

@@ -105,10 +107,21 @@ def create(self, defn, check, allow_reboot, allow_recreate):
except botocore.exceptions.ClientError as e:
if e.response['Error']['Code'] != "BucketAlreadyOwnedByYou": raise

try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this out of the if check or self.state != self.UP: block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@AmineChikhaoui AmineChikhaoui merged commit 725ee81 into NixOS:master Jan 29, 2019
@PsyanticY PsyanticY deleted the s3-versionning branch January 30, 2019 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants