gitlab-org--gitlab-foss/app/controllers/projects/variables_controller.rb

43 lines
1.1 KiB
Ruby
Raw Normal View History

class Projects::VariablesController < Projects::ApplicationController
before_action :authorize_admin_build!
layout 'project_settings'
def show
2016-04-27 08:01:43 +00:00
@variable = @project.variables.find(params[:id])
end
def update
2016-04-27 08:01:43 +00:00
@variable = @project.variables.find(params[:id])
if @variable.update_attributes(project_params)
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variable was successfully updated.'
2016-04-27 08:01:43 +00:00
else
render action: "show"
end
end
def create
@variable = Ci::Variable.new(project_params)
if @variable.valid? && @project.variables << @variable
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variables were successfully updated.'
else
2016-04-27 08:01:43 +00:00
render action: "index"
end
end
2016-04-27 08:01:43 +00:00
def destroy
@key = @project.variables.find(params[:id])
@key.destroy
redirect_to namespace_project_settings_ci_cd_path(project.namespace, project), notice: 'Variable was successfully removed.'
2016-04-27 08:01:43 +00:00
end
private
def project_params
2016-04-27 08:01:43 +00:00
params.require(:variable).permit([:id, :key, :value, :_destroy])
end
end