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

[plugins/aws][fix] Migrate the db config on config class change #1108

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugins/aws/resoto_plugin_aws/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import uuid
from datetime import timedelta

from attrs import define, field
from resotolib.types import Json
from attrs import define, field, fields_dict
from functools import lru_cache
from typing import List, ClassVar, Optional, Type, Any, Dict

from resotolib.json import from_json as from_js
from boto3.session import Session as BotoSession

from resotolib.durations import parse_duration
Expand Down Expand Up @@ -156,6 +158,14 @@ class AwsConfig:
},
)

@staticmethod
def from_json(json: Json) -> "AwsConfig":
valid_fields = fields_dict(AwsConfig).keys()
for field_name in json.copy().keys():
if field_name not in valid_fields:
del json[field_name]
return from_js(json, AwsConfig)

def atime_mtime_period(self) -> timedelta:
return parse_duration(self.cloudwatch_metrics_for_atime_mtime_period)

Expand Down