Skip to content

Commit

Permalink
feat: display policy manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampouille committed Sep 19, 2023
1 parent 4054bb9 commit b6cc80b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,8 @@ def remove_policy():
analyzers[ns].deletePolicy(wl)
return redirect(url_for('home'))

@app.route("/show_policy/<ns>/<wl>")
def get_policy(ns, wl):
return yaml.dump(analyzers[ns].generatePolicy(wl))

app.run(host="0.0.0.0", port=5000)
24 changes: 18 additions & 6 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ <h2 class="mt-4">Workload: {{ wl }}</h2>

<!-- Modal to display TracingPolicies manifest -->
<div class="modal fade" id="yamlPolicyModal" tabindex="-1" aria-labelledby="yamlPolicyModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="yamlPolicyModalLabel">Policy Manifest</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="modal-body p-0">
<pre><code id="yamlPolicyModalBody" class="language-yaml"></code></pre>
</div>
</div>
Expand Down Expand Up @@ -94,12 +94,24 @@ <h1 class="modal-title fs-5" id="yamlPolicyModalLabel">Policy Manifest</h1>
// Extract ns and wl
const ns = button.getAttribute('data-bs-ns')
const wl = button.getAttribute('data-bs-wl')
const yaml = document.getElementById('yamlPolicyModalBody');
yaml.textContent = "";
// fetch yaml manifest
$.ajax({
type: "GET",
url: "/show_policy/" + ns + "/" + wl,
success: function (response) {
console.log("Response:", response);
// Inject yaml in the modal
yaml.textContent = response;
hljs.highlightAll();
},
error: function (error) {
console.error("Error:", error);
}
});


// Inject yaml in the modal
const yaml = document.getElementById('yamlPolicyModalBody');
yaml.textContent = ns + " " + wl;
hljs.highlightAll();
})
}
{% endblock %}

0 comments on commit b6cc80b

Please sign in to comment.