This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Argo API Integration
- Loading branch information
Showing
43 changed files
with
1,570 additions
and
14 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ jobs: | |
DATABASE_URL: "postgres://postgres:[email protected]:5432/platform_console_test?pool=4" | ||
REDIS_URL: redis://localhost:6379/0 | ||
TERM: xterm-256color | ||
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | ||
runs-on: ubuntu-20.04 | ||
|
||
services: | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
//= link_tree ../../javascript .js | ||
//= link_tree ../../../vendor/javascript .js | ||
//= link_tree ../builds | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'argo_cd/client' | ||
|
||
# Handles creating deployments which are owned by an app | ||
class DeploymentsController < ApplicationController | ||
before_action :authorize_session! | ||
before_action :set_app, :set_team | ||
before_action :set_deployment, only: %i[show edit update destroy] | ||
|
||
# GET /apps or /apps.json | ||
def index | ||
@deployments = @app.deployments | ||
@pagy, @deployments = pagy @deployments | ||
end | ||
|
||
# GET /apps/1 or /apps/1.json | ||
def show | ||
argo_client = ArgoCd::Client.new(@app.id, @deployment.name, @current_user.id) | ||
@response = argo_client.app_info | ||
end | ||
|
||
# GET /apps/new | ||
def new | ||
@deployment = @app.deployments.build | ||
end | ||
|
||
# GET /apps/1/edit | ||
def edit; end | ||
|
||
# POST /apps or /apps.json | ||
def create | ||
@deployment = @app.deployments.build(deployment_params) | ||
|
||
respond_to do |format| | ||
if @app.save | ||
format.html do | ||
redirect_to team_app_deployment_url(@team, @app, @deployment), notice: 'Deployment was successfully created.' | ||
end | ||
format.json { render :show, status: :created, location: @deployment } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @deployment.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /apps/1 or /apps/1.json | ||
def update | ||
respond_to do |format| | ||
if @deployment.update(deployment_params) | ||
format.html do | ||
redirect_to team_app_deployment_url(@team, @app, @deployment), notice: 'Deployment was successfully updated.' | ||
end | ||
format.json { render :show, status: :ok, location: @deployment } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @deployment.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /apps/1 or /apps/1.json | ||
def destroy | ||
@deployment.destroy | ||
|
||
respond_to do |format| | ||
format.html do | ||
redirect_to team_app_deployments_url(@team, @app), notice: 'Deployment was successfully destroyed.' | ||
end | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_team | ||
@team = Team.find(params[:team_id]) | ||
end | ||
|
||
def set_app | ||
@app = App.find(params[:app_id]) | ||
end | ||
|
||
# Find the app deployment | ||
def set_deployment | ||
@deployment = @app.deployments.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def deployment_params | ||
params.require(:deployment).permit(:name, :app_id) | ||
end | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Deployment < ApplicationRecord | ||
belongs_to :app | ||
has_paper_trail | ||
validates :name, presence: true | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<div class="flex justify-between"> | ||
<h3 class="text-lg leading-7 text-gray-900 sm:text-lg sm:truncate mt-4"> | ||
Deployments | ||
</h3> | ||
<%= link_to new_team_app_deployment_path(@team, @app), class: 'place-self-center inline-flex items-center mt-4 px-2 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-900 hover:bg-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-900' do %> | ||
<span class="sr-only">New app</span> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" /> | ||
</svg> | ||
<% end %> | ||
</div> | ||
|
||
<br> | ||
|
||
<% if @app.deployments.present? %> | ||
<div class="flex flex-col"> | ||
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | ||
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8"> | ||
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"> | ||
<table class="table-fixed min-w-full divide-y divide-gray-200" id="apps"> | ||
<thead class="bg-gray-50"> | ||
<tr> | ||
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase w-full"> | ||
Name | ||
</th> | ||
<th scope="col" class="relative px-6 py-3"> | ||
<span class="sr-only">Edit</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @app.deployments.each do |deployment| %> | ||
<tr class="<%= cycle 'bg-white', 'bg-gray-50' %>"> | ||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> | ||
<%= link_to deployment.name, [@team, @app, deployment], class: 'text-blue-900 hover:text-blue-800' %> | ||
</td> | ||
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> | ||
<div class="flex space-x-2"> | ||
<%= link_to 'Edit', edit_team_app_deployment_path(@team, @app, deployment), class: 'inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-900 hover:bg-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500' %> | ||
<%= button_to 'Destroy', [@team, @app, deployment], method: :delete, form: { data: { turbo_confirm: 'Are you sure?' } }, class: 'inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-md text-white bg-red-900 hover:bg-red-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-900 sm:text-sm' %> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<% if @pagy %> | ||
<div class="md:flex justify-between text-center mt-6 md:mt-0"> | ||
<%== pagy_info @pagy %> | ||
<%== pagy_nav @pagy %> | ||
</div> | ||
<% end %> | ||
<% else %> | ||
<div class="text-center border-dashed border-gray-300 hover:border-gray-400 border-2 rounded-lg p-6 max-w-lg m-auto"> | ||
<svg width="96" height="96" fill="none" class="mx-auto mb-6 text-gray-900"><path d="M36 28.024A18.05 18.05 0 0025.022 39M59.999 28.024A18.05 18.05 0 0170.975 39" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><ellipse cx="37.5" cy="43.5" rx="4.5" ry="7.5" fill="currentColor"></ellipse><ellipse cx="58.5" cy="43.5" rx="4.5" ry="7.5" fill="currentColor"></ellipse><path d="M24.673 75.42a9.003 9.003 0 008.879 5.563m-8.88-5.562A8.973 8.973 0 0124 72c0-7.97 9-18 9-18s9 10.03 9 18a9 9 0 01-8.448 8.983m-8.88-5.562C16.919 68.817 12 58.983 12 48c0-19.882 16.118-36 36-36s36 16.118 36 36-16.118 36-36 36a35.877 35.877 0 01-14.448-3.017" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M41.997 71.75A14.94 14.94 0 0148 70.5c2.399 0 4.658.56 6.661 1.556a3 3 0 003.999-4.066 12 12 0 00-10.662-6.49 11.955 11.955 0 00-7.974 3.032c1.11 2.37 1.917 4.876 1.972 7.217z" fill="currentColor"></path></svg> | ||
<h3 class="mt-2 text-sm font-medium text-gray-900">No Deployments for <%= @app.name %></h3> | ||
<p class="mt-1 text-sm text-gray-500"> | ||
Get started by creating a new deployment. | ||
</p> | ||
<div class="mt-6"> | ||
<%= link_to new_team_app_deployment_path(@team, @app), class: 'inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-900 hover:bg-blue-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-900' do %> | ||
<svg class="-ml-1 mr-2 h-5 w-5" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" /> | ||
</svg> | ||
New Deployment | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> |
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
Oops, something went wrong.