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

Fix report month error when run CostReportConfig #275

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spaceone/cost_analysis/conf/global_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"cost-analysis:CostReport.read",
"cost-analysis:CostReportData.read",
"cost-analysis:CostReportConfig.read",
"config:Domain.read",
"config:DomainConfig.read",
"identity:Provider.read",
]

Expand Down
2 changes: 2 additions & 0 deletions src/spaceone/cost_analysis/service/cost_report_serivce.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ def _get_is_create_report_and_report_month(

if retry_date.month != current_date.month:
issue_date = (current_date - relativedelta(months=1)).replace(day=issue_day)

report_date = current_date - relativedelta(months=2)
issue_day = self.get_issue_day(is_last_day, issue_day)
else:
Expand All @@ -738,6 +739,7 @@ def _get_is_create_report_and_report_month(

if issue_day == current_day:
is_create_report = True
report_month = (current_date - relativedelta(months=1)).strftime("%Y-%m")

return is_create_report, report_month

Expand Down
16 changes: 15 additions & 1 deletion src/spaceone/cost_analysis/service/data_source_rule_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def create(self, params):
]
)
@change_date_value(["start", "end"])
def create_data_source_rule(self, params):
def create_data_source_rule(self, params: dict):
domain_id: str = params["domain_id"]
data_source_id: str = params["data_source_id"]
conditions: list = params.get("conditions", [])
Expand Down Expand Up @@ -401,6 +401,20 @@ def _check_conditions(conditions):
)

def _check_actions(self, actions: dict, domain_id: str) -> None:
actions_keys = set(actions.keys())
allowed_actions = {
"match_workspace",
"change_project",
"match_project",
"match_service_account",
}

if len(actions_keys & allowed_actions) > 1:
raise ERROR_INVALID_PARAMETER(
key="actions",
reason="Only one of 'match_workspace', 'change_project', 'match_project', 'match_service_account' can be set.",
)

if match_workspace := actions.get("match_workspace"):
if "source" not in match_workspace:
raise ERROR_REQUIRED_PARAMETER(key="actions.match_workspace.source")
Expand Down
Loading