-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle env vars * seperate controllers for app/revisions and revisions/guid/x [finishes #163440535] Signed-off-by: Eric Promislow <eric.promislow@suse.com>
- Loading branch information
Showing
12 changed files
with
425 additions
and
420 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
app/actions/app_revisions_update.rb → app/actions/revisions_update.rb
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'messages/revisions_update_message' | ||
require 'actions/revisions_update' | ||
require 'presenters/v3/revision_presenter' | ||
require 'presenters/v3/revision_environment_variables_presenter' | ||
|
||
class RevisionsController < ApplicationController | ||
def show | ||
revision = fetch_revision(hashed_params[:revision_guid]) | ||
render status: :ok, json: Presenters::V3::RevisionPresenter.new(revision) | ||
end | ||
|
||
def update | ||
message = RevisionsUpdateMessage.new(hashed_params[:body]) | ||
unprocessable!(message.errors.full_messages) unless message.valid? | ||
|
||
revision = fetch_revision(hashed_params[:revision_guid], needs_write_permissions: true) | ||
|
||
revision = RevisionsUpdate.new.update(revision, message) | ||
|
||
render status: :ok, json: Presenters::V3::RevisionPresenter.new(revision) | ||
end | ||
|
||
def show_environment_variables | ||
revision = fetch_revision(hashed_params[:revision_guid], needs_secrets_read_permission: true) | ||
render status: :ok, json: Presenters::V3::RevisionEnvironmentVariablesPresenter.new(revision) | ||
end | ||
|
||
private | ||
|
||
def fetch_revision(guid, needs_write_permissions: false, needs_secrets_read_permission: false) | ||
revision = RevisionModel.find(guid: guid) | ||
resource_not_found!(:revision) unless revision | ||
|
||
app = revision.app | ||
space = app.space | ||
org = space.organization | ||
resource_not_found!(:revision) unless permission_queryer.can_read_from_space?(space.guid, org.guid) | ||
unauthorized! if needs_write_permissions && !permission_queryer.can_write_to_space?(space.guid) | ||
unauthorized! if needs_secrets_read_permission && !permission_queryer.can_read_secrets_in_space?(space.guid, org.guid) | ||
|
||
revision | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
app/messages/app_revisions_update_message.rb → app/messages/revisions_update_message.rb
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
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
Oops, something went wrong.