File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ from abc import ABCMeta , abstractmethod
2+ import dataclasses as dc
3+ from typing import Any , Dict
4+
5+ @dc .dataclass (frozen = True )
6+ class DeploymentState (metaclass = ABCMeta ):
7+ type : str
8+
9+ @abstractmethod
10+ def to_dict (self ) -> Dict :
11+ """
12+ Serializes given DeploymentState instance to Dict.
13+ :return:
14+ """
15+
16+ @dc .dataclass (frozen = True )
17+ class DeploymentStateEcs (DeploymentState ):
18+ blue : Any
19+ green : Any
20+ candidate : Any
21+
22+ def to_dict (self ) -> Dict :
23+ return {
24+ 'type' : self .type ,
25+ 'blue' : dc .asdict (self .blue ),
26+ 'green' : dc .asdict (self .green ),
27+ 'candidate' : self .candidate .value ,
28+ }
29+
30+ @dc .dataclass (frozen = True )
31+ class DeploymentStateLambda (DeploymentState ):
32+ current : Any
33+ candidate : Any
34+
35+ def to_dict (self ) -> Dict :
36+ return {
37+ 'type' : self .type ,
38+ 'current' : dc .asdict (self .current ),
39+ 'candidate' : dc .asdict (self .candidate ) if self .candidate else None ,
40+ }
Original file line number Diff line number Diff line change 1+ [testoptions]
2+ min_pyver=3.7
3+
4+ [MESSAGES CONTROL]
5+ disable=fixme,
6+ logging-too-many-args,
7+ logging-fstring-interpolation,
8+ missing-docstring,
9+ no-else-return,
10+ too-few-public-methods,
You can’t perform that action at this time.
0 commit comments