Skip to content

Commit

Permalink
Improved homControl
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryGF committed Oct 30, 2023
1 parent c1682af commit 386f394
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
42 changes: 39 additions & 3 deletions docker/homControl/app/Home.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
# app.py
import streamlit as st
from PIL import Image

st.set_page_config(
layout="wide",
page_icon="https://raw.githubusercontent.com/LarryGF/pi-k8s/c1682af8f077bce0dcfd04c7d70b64375f2fa042/docker/homControl/app/files/logo_dark-transparent.svg"
)

def main():
st.title("Streamlit & Terraform CDK Example")


image = Image.open('./logo.png')
st.image(image,width=300)
st.title("homControl")

st.markdown("""
Welcome to **homControl**!
This is part of the terraHom repo and provides an interactive way to deploy and manage your infrastructure using Terraform. 🚀
## Core Features
- **Terraform Integration** 🛠: Skip the command line and interact directly with your Terraform configurations.
- **Module Control** 📦: Handpick specific Terraform modules for deployment.
- **Real-time Feedback** 📢: Stay in the loop with instant feedback on your deployments.
- **Docker Enthusiast?** 🐳: Yep, we got you covered! Easily run this app inside a Docker environment.
## Navigating homControl
1. **Application 📱**: Choose which apps to deploy and set the basics like namespace and priority.
2. **Variables 🧮**: Tweak and tune your terraform variables as you see fit.
3. **Terraform 🌐**:
- **Initialization** (Optional but recommended) 🔍: Prep your Terraform configurations.
- **Planning Ahead** 📝: Peek into the planned changes for your infrastructure.
- **Deploy** 🚀: Satisfied with the plan? Go ahead and bring those changes to life!
All set to simplify your Terraform deployment process? Let's make Infrastructure as Code (IAC) fun and accessible!
## Kick-start Your Journey
🧭 Use the sidebar to glide through the app. Begin with setting up your Terraform configurations and then march ahead to plan and deploy your modules.
Ready. Set. Automate! 🤖
""")

if __name__ == "__main__":
main()
Binary file added docker/homControl/app/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docker/homControl/app/pages/Applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from uuid import uuid4
from streamlit_extras.stylable_container import stylable_container

st.set_page_config(layout="wide")
st.set_page_config(
layout="wide",
page_icon="https://raw.githubusercontent.com/LarryGF/pi-k8s/c1682af8f077bce0dcfd04c7d70b64375f2fa042/docker/homControl/app/files/logo_dark-transparent.svg"
)
st.title("Applications Configuration Dashboard")

def load_yaml(file_path):
Expand Down
13 changes: 8 additions & 5 deletions docker/homControl/app/pages/Terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from streamlit_extras.stylable_container import stylable_container
from python_terraform import *

st.set_page_config(layout="wide")
st.set_page_config(
layout="wide",
page_icon="https://raw.githubusercontent.com/LarryGF/pi-k8s/c1682af8f077bce0dcfd04c7d70b64375f2fa042/docker/homControl/app/files/logo_dark-transparent.svg"
)
st.title("Terraform Modules")
def main():
st.session_state.initial_keys = set(st.session_state.keys())
# Determine YAML path based on environment
base_path = determine_base_path()
tf_modules_path = os.path.join(base_path, 'terraform')
st.session_state.base_path = determine_base_path()
tf_modules_path = os.path.join(st.session_state.base_path, 'terraform')
terraform_client = Terraform(working_dir=tf_modules_path)

if 'deploy_stage' not in st.session_state:
Expand All @@ -31,7 +34,7 @@ def main():
handle_init(terraform_client)

if st.session_state.deploy_stage == "plan":
variables = load_json(os.path.join(base_path, 'terraform', 'terraform.tfvars.json'))
variables = load_json(os.path.join(st.session_state.base_path, 'terraform', 'terraform.tfvars.json'))
deploy_terraform_modules(terraform_client, variables, modules_to_deploy)

def determine_base_path():
Expand Down Expand Up @@ -195,7 +198,7 @@ def deploy_terraform_modules(tf_client,variables,modules_to_deploy):
clear_new_session_keys(st.session_state.initial_keys)
# Delete the plan file after writing to stdout
try:
os.remove(os.path.join(base_path,'terraform',st.session_state.plan_name))
os.remove(os.path.join(st.session_state.base_path,'terraform',st.session_state.plan_name))
st.write("Plan file deleted successfully.")
except Exception as e:
st.write(f"Error deleting plan file: {e}")
Expand Down
7 changes: 5 additions & 2 deletions docker/homControl/app/pages/Variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import json
import hcl2

st.set_page_config(layout="wide")
st.set_page_config(
layout="wide",
page_icon="https://raw.githubusercontent.com/LarryGF/pi-k8s/c1682af8f077bce0dcfd04c7d70b64375f2fa042/docker/homControl/app/files/logo_dark-transparent.svg"
)
st.title("Terraform Variables")

def load_hcl(file_path):
Expand Down Expand Up @@ -33,7 +36,7 @@ def main():

# Initialize session state for tfvars
if 'tfvars' not in st.session_state:
if os.path.exists(tfvars_path):
if os.path.exists(tfvars_path_json):
st.session_state.tfvars = load_json(tfvars_path_json)
st.toast(":green[Loaded vars from generated JSON!]")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ homepage:
- Home Services:
- homControl:
href: http://localhost:8501
icon: https://raw.githubusercontent.com/LarryGF/pi-k8s/homControl/docker/homControl/app/files/logo.png
icon: https://raw.githubusercontent.com/LarryGF/pi-k8s/c1682af8f077bce0dcfd04c7d70b64375f2fa042/docker/homControl/app/files/logo_dark-transparent.svg
widgets:
- resources:
# change backend to 'kubernetes' to use Kubernetes integration. Requires RBAC.
Expand Down

0 comments on commit 386f394

Please sign in to comment.