build cloud provider credential

This commit is contained in:
Chris
2025-08-23 13:40:10 -07:00
parent fff3ca7a26
commit 034eb8cc8a
6 changed files with 23 additions and 4 deletions

View File

@@ -52,7 +52,8 @@ module Projects
BuildConfiguration.new(
project:,
driver: build_config_params[:driver],
build_cloud_id: build_config_params[:build_cloud_id]
build_cloud_id: build_config_params[:build_cloud_id],
provider_id: build_config_params[:provider_id] || project.project_credential_provider.provider_id
)
end

View File

@@ -8,16 +8,19 @@
# updated_at :datetime not null
# build_cloud_id :bigint
# project_id :bigint not null
# provider_id :bigint not null
#
# Indexes
#
# index_build_configurations_on_build_cloud_id (build_cloud_id)
# index_build_configurations_on_project_id (project_id)
# index_build_configurations_on_provider_id (provider_id)
#
# Foreign Keys
#
# fk_rails_... (build_cloud_id => build_clouds.id)
# fk_rails_... (project_id => projects.id)
# fk_rails_... (provider_id => providers.id)
#
class BuildConfiguration < ApplicationRecord
belongs_to :project

View File

@@ -0,0 +1,5 @@
class AddProviderIdToBuildConfigurations < ActiveRecord::Migration[7.2]
def change
add_reference :build_configurations, :provider, null: false, foreign_key: true
end
end

5
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_08_18_215548) do
ActiveRecord::Schema[7.2].define(version: 2025_08_23_202522) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -107,8 +107,10 @@ ActiveRecord::Schema[7.2].define(version: 2025_08_18_215548) do
t.bigint "build_cloud_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "provider_id", null: false
t.index ["build_cloud_id"], name: "index_build_configurations_on_build_cloud_id"
t.index ["project_id"], name: "index_build_configurations_on_project_id"
t.index ["provider_id"], name: "index_build_configurations_on_provider_id"
end
create_table "builds", force: :cascade do |t|
@@ -475,6 +477,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_08_18_215548) do
add_foreign_key "build_clouds", "clusters"
add_foreign_key "build_configurations", "build_clouds"
add_foreign_key "build_configurations", "projects"
add_foreign_key "build_configurations", "providers"
add_foreign_key "builds", "projects"
add_foreign_key "clusters", "accounts"
add_foreign_key "cron_schedules", "services"

View File

@@ -8,20 +8,24 @@
# updated_at :datetime not null
# build_cloud_id :bigint
# project_id :bigint not null
# provider_id :bigint not null
#
# Indexes
#
# index_build_configurations_on_build_cloud_id (build_cloud_id)
# index_build_configurations_on_project_id (project_id)
# index_build_configurations_on_provider_id (provider_id)
#
# Foreign Keys
#
# fk_rails_... (build_cloud_id => build_clouds.id)
# fk_rails_... (project_id => projects.id)
# fk_rails_... (provider_id => providers.id)
#
FactoryBot.define do
factory :build_configuration do
project { nil }
driver { 1 }
provider
project
driver { :docker }
end
end

View File

@@ -8,16 +8,19 @@
# updated_at :datetime not null
# build_cloud_id :bigint
# project_id :bigint not null
# provider_id :bigint not null
#
# Indexes
#
# index_build_configurations_on_build_cloud_id (build_cloud_id)
# index_build_configurations_on_project_id (project_id)
# index_build_configurations_on_provider_id (provider_id)
#
# Foreign Keys
#
# fk_rails_... (build_cloud_id => build_clouds.id)
# fk_rails_... (project_id => projects.id)
# fk_rails_... (provider_id => providers.id)
#
require 'rails_helper'