Created
March 5, 2024 11:41
-
-
Save TomerAdmon/4e0355eec662bcc96eef9b4c17411b07 to your computer and use it in GitHub Desktop.
limit space launches except for specific users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package torque.environment | |
import future.keywords.if | |
equals(a, b) { | |
a == b | |
} | |
contains_case_insensitive(arr, elem) { | |
lower_elem:= lower(elem) | |
equals(lower(arr[_]), lower_elem) | |
} | |
result = {"decision": "Approved"} if { | |
contains_case_insensitive(data.admin_emails, input.user_email) | |
} | |
result := {"decision": "Denied", "reason": "max_active_envs_in_account_per_owner must be a number"} if { | |
data.max_active_envs_in_account_per_owner | |
not is_number(data.max_active_envs_in_account_per_owner) | |
} | |
result = {"decision": "Denied", "reason": "Owner has reached the maximum number of active environments allowed in account"} if { | |
is_number(data.max_active_envs_in_account_per_owner) | |
data.max_active_envs_in_account_per_owner < input.owner_active_environments_in_account + 1 | |
not contains_case_insensitive(data.admin_emails, input.user_email) | |
} | |
result = {"decision": "Approved"} if { | |
is_number(data.max_active_envs_in_account_per_owner) | |
data.max_active_envs_in_account_per_owner >= input.owner_active_environments_in_account + 1 | |
} | |
result = {"decision": "Approved"} if { | |
is_number(data.max_active_envs_in_account_per_owner) | |
data.max_active_envs_in_account_per_owner >= input.owner_active_environments_in_account + 1 | |
contains_case_insensitive(data.admin_emails, input.user_email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment