Skip to content

Commit

Permalink
[plugins/aws][fix] Migrate the db config on config class change (#1108)
Browse files Browse the repository at this point in the history
  • Loading branch information
meln1k committed Aug 22, 2022
1 parent 1e6dd83 commit 6a216d6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugins/aws/resoto_plugin_aws/config.py
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

0 comments on commit 6a216d6

Please sign in to comment.