feat(static): adds new static origins feature
This commit is contained in:
parent
6a29d68985
commit
15a85b1efe
20 changed files with 843 additions and 7 deletions
|
@ -53,6 +53,16 @@ class HcloudAccountForm(FlaskForm): # type: ignore
|
|||
submit = SubmitField('Save Changes')
|
||||
|
||||
|
||||
class GitlabAccountForm(FlaskForm): # type: ignore
|
||||
provider = StringField('Platform', render_kw={"disabled": ""})
|
||||
description = StringField('Description', validators=[InputRequired()])
|
||||
gitlab_token = StringField('GitLab Access Token', validators=[InputRequired()])
|
||||
enabled = BooleanField('Enable this account', default=True,
|
||||
description="New resources will not be deployed to disabled accounts, however existing "
|
||||
"resources will persist until destroyed at the end of their lifecycle.")
|
||||
submit = SubmitField('Save Changes')
|
||||
|
||||
|
||||
class OvhHorizonForm(Form): # type: ignore[misc]
|
||||
ovh_openstack_user = StringField("User")
|
||||
ovh_openstack_password = StringField("Password")
|
||||
|
@ -102,6 +112,7 @@ provider_forms: Dict[str, Type[CloudAccountForm]] = {
|
|||
CloudProvider.AWS.name: AWSAccountForm,
|
||||
CloudProvider.HCLOUD.name: HcloudAccountForm,
|
||||
CloudProvider.GANDI.name: GandiAccountForm,
|
||||
CloudProvider.GITLAB.name: GitlabAccountForm,
|
||||
CloudProvider.OVH.name: OvhAccountForm,
|
||||
}
|
||||
|
||||
|
@ -140,6 +151,10 @@ def cloud_account_save(account: Optional[CloudAccount], provider: CloudProvider,
|
|||
account.max_distributions = 0
|
||||
account.max_sub_distributions = 0
|
||||
account.max_instances = form.max_instances.data
|
||||
elif provider == CloudProvider.GITLAB and isinstance(form, GitlabAccountForm):
|
||||
account.credentials = {
|
||||
"gitlab_token": form.gitlab_token.data,
|
||||
}
|
||||
elif provider == CloudProvider.OVH and isinstance(form, OvhAccountForm):
|
||||
account.credentials = {
|
||||
"ovh_openstack_user": form.horizon.data["ovh_openstack_user"],
|
||||
|
@ -174,6 +189,8 @@ def cloud_account_populate(form: CloudAccountForm, account: CloudAccount) -> Non
|
|||
form.horizon.form.gandi_openstack_password.data = account.credentials["gandi_openstack_password"]
|
||||
form.horizon.form.gandi_openstack_tenant_id.data = account.credentials["gandi_openstack_tenant_id"]
|
||||
form.max_instances.data = account.max_instances
|
||||
elif account.provider == CloudProvider.GITLAB and isinstance(form, GitlabAccountForm):
|
||||
form.gitlab_token.data = account.credentials["gitlab_token"]
|
||||
elif account.provider == CloudProvider.OVH and isinstance(form, OvhAccountForm):
|
||||
form.horizon.form.ovh_openstack_user.data = account.credentials["ovh_openstack_user"]
|
||||
form.horizon.form.ovh_openstack_password.data = account.credentials["ovh_openstack_password"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue