Skip to content

Commit

Permalink
🔥feat: Add opentofu UI mic
Browse files Browse the repository at this point in the history
  • Loading branch information
D10S0VSkY-OSS committed Dec 3, 2023
1 parent 598f58b commit da23311
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sld-dashboard/app/base/static/assets/img/iac_type/tf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sld-dashboard/app/base/static/assets/img/iac_type/tofu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
13 changes: 9 additions & 4 deletions sld-dashboard/app/home/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
from flask_wtf import FlaskForm
from wtforms import (BooleanField, PasswordField, StringField, TextAreaField,
from wtforms import (BooleanField, PasswordField, StringField, TextAreaField, SelectField,
validators)
from wtforms.fields import EmailField

Expand Down Expand Up @@ -36,11 +36,16 @@ class StackForm(FlaskForm):
default="*",
render_kw={"rows": 1},
)

iac_type = SelectField(
"IaC Type",
choices=[('terraform', 'Terraform'), ('openTofu', 'openTofu')],
validators=[validators.DataRequired()],
coerce=lambda x: 'tofu' if x == 'openTofu' else x
)
tf_version = StringField(
"Terraform version",
"IaC version",
[
validators.length(min=5, max=5, message="tf version out of reange."),
validators.length(min=5, max=15, message="tf version out of reange."),
validators.DataRequired(message="tf version requerid."),
],
)
Expand Down
3 changes: 3 additions & 0 deletions sld-dashboard/app/home/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ def new_stack():
"git_repo": form.git.data.replace(" ",""),
"branch": form.branch.data.replace(" ",""),
"squad_access": squad_acces_form_to_list,
"iac_type": form.iac_type.data,
"tf_version": form.tf_version.data.replace(" ",""),
"project_path": form.project_path.data.replace(" ",""),
"description": form.description.data,
Expand Down Expand Up @@ -871,6 +872,7 @@ def edit_stack(stack_id):
"git_repo": form.git.data.replace(" ",""),
"branch": form.branch.data.replace(" ",""),
"squad_access": squad_acces_form_to_list,
"iac_type": form.iac_type.data,
"tf_version": form.tf_version.data.replace(" ",""),
"project_path": form.project_path.data.replace(" ",""),
"description": form.description.data,
Expand Down Expand Up @@ -940,6 +942,7 @@ def resync_stack(stack_id):
"git_repo": response.get("json").get("git_repo"),
"branch": response.get("json").get("branch"),
"squad_access": response.get("json").get("squad_access"),
"iac_type": response.get("json").get("iac_type"),
"tf_version": response.get("json").get("tf_version"),
"project_path": response.get("json").get("project_path"),
"description": response.get("json").get("description"),
Expand Down
4 changes: 4 additions & 0 deletions sld-dashboard/app/home/templates/stack-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ <h3>{{stack.stack_name}}</h3>
{{ render_field(form.squad_access_edit, autocomplete="off", class='form-control', value=stack.squad_access|join(',')) }}
</div>

<div class="form-group">
{{ render_field(form.iac_type, autocomplete="off", class='form-control',) }}
</div>

<div class="form-group">
{{ render_field(form.tf_version, autocomplete="off", class='form-control', value=stack.tf_version) }}
</div>
Expand Down
10 changes: 9 additions & 1 deletion sld-dashboard/app/home/templates/stacks-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ <h2 class="h4">All Stacks</h2>
{% if "yoda" in current_user.role or "darth_vader" in current_user.role %}
<th>Stack Repo</th>
<th>Branch</th>
<th>Tf version</th>
<th>IaC Type</th>
<th>IaC version</th>
<th>squad_access</th>
{% endif %}
<th>Description</th>
Expand All @@ -75,6 +76,13 @@ <h2 class="h4">All Stacks</h2>
{% if "yoda" in current_user.role or "darth_vader" in current_user.role %}
<td><span class="font-weight-normal">{{ stack.git_repo }}</span></td>
<td><span class="font-weight-normal">{{ stack.branch }}</span></td>
<td><span >
{% if stack.iac_type == 'terraform' %}
<img src="{{ url_for('static', filename='/assets/img/iac_type/tf.svg') }}" alt="Terraform Icon">
{% elif stack.iac_type == 'tofu' %}
<img src="{{ url_for('static', filename='/assets/img/iac_type/tofu.svg') }}" alt="Tofu Icon">
{% endif %}
</span></td>
<td><span class="tag-style">{{ stack.tf_version }}</span></td>
<td><span class="font-weight-normal">{{ stack.squad_access }}</span></td>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions sld-dashboard/app/home/templates/stacks-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h1 class="h4">Add New Stack</h1>
{{ render_field(form.squad_access, autocomplete="off", class='form-control') }}
</div>

<div class="form-group">
{{ render_field(form.iac_type, autocomplete="off", class='form-control') }}
</div>

<div class="form-group">
{{ render_field(form.tf_version, autocomplete="off", class='form-control', value='1.3.2') }}
</div>
Expand Down

0 comments on commit da23311

Please sign in to comment.