-
Notifications
You must be signed in to change notification settings - Fork 161
Custom images list implementation #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DominikAlberski
merged 16 commits into
prd_custom_images_dev
from
prd_custom_images_us3_am
Aug 18, 2025
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b96553c
List custom images endpoint
AndriiMysko 012542c
Return size_bytes for custom images
AndriiMysko 3b5ebad
Implement deleting custom images
AndriiMysko eba3667
Add specs
AndriiMysko dc885e0
Fix spec
AndriiMysko 56ca7a9
Address review comments
AndriiMysko d12e949
custom image restart (#1371)
GbArc bce0e10
Address review comments
AndriiMysko 6f78487
Fixes
AndriiMysko 50b160f
Show only active images
AndriiMysko e3aa4cd
Fix typo
AndriiMysko 72ff6dc
Fix permissions for custom images list
AndriiMysko 2a705d3
Add default artifact manager config
AndriiMysko 08405b3
expose membership /build_permission (#1373)
GbArc 4a66eb4
Merge branch 'prd_custom_images_us3_am' into prd_custom_images_us4_am
DominikAlberski fd3ddfe
Merge pull request #1369 from travis-ci/prd_custom_images_us4_am
DominikAlberski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,20 @@ | ||
module Travis::API::V3 | ||
class Models::CustomImage < Model | ||
after_initialize :readonly! | ||
belongs_to :owner, polymorphic: true | ||
has_many :custom_image_logs | ||
|
||
scope :available, -> { where(state: 'available') } | ||
|
||
def created_by | ||
user_id = custom_image_logs.where(action: 'created').first&.sender_id | ||
return unless user_id | ||
|
||
User.find(user_id) | ||
end | ||
|
||
def private | ||
true | ||
end | ||
end | ||
end |
This file contains hidden or 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,6 @@ | ||
module Travis::API::V3 | ||
class Models::CustomImageLog < Model | ||
after_initialize :readonly! | ||
belongs_to :custom_image | ||
AndriiMysko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end |
This file contains hidden or 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,13 @@ | ||
module Travis::API::V3 | ||
class Queries::CustomImages < Query | ||
def for_owner(owner) | ||
Models::CustomImage.where(owner_id: owner.id, owner_type: owner_type(owner)) | ||
end | ||
|
||
private | ||
|
||
def owner_type(owner) | ||
owner.vcs_type =~ /User/ ? 'User' : 'Organization' | ||
end | ||
end | ||
end |
This file contains hidden or 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,20 @@ | ||
module Travis::API::V3 | ||
class Renderer::CustomImage < ModelRenderer | ||
representation :minimal, :id, :owner_id, :owner_type, :name, :usage, :created_at, :updated_at, :os_version, | ||
:created_by, :private, :size_bytes | ||
representation :standard, *representations[:minimal] | ||
|
||
def created_by | ||
return nil unless user = model.created_by | ||
{ | ||
'@type' => 'user', | ||
'@href' => "/v3/user/#{user.id}", | ||
'@representation' => 'minimal'.freeze, | ||
'id' => user.id, | ||
'login' => user.login, | ||
'name' => user.name, | ||
'avatar_url' => user.avatar_url | ||
} | ||
end | ||
end | ||
end |
This file contains hidden or 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,6 @@ | ||
module Travis::API::V3 | ||
class Renderer::CustomImages < CollectionRenderer | ||
type :custom_images | ||
collection_key :custom_images | ||
end | ||
end |
This file contains hidden or 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 hidden or 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 hidden or 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,20 @@ | ||
module Travis::API::V3 | ||
class Services::CustomImages::ForOwner < Service | ||
result_type :custom_images | ||
|
||
def run! | ||
raise MethodNotAllowed if Travis.config.org? | ||
raise LoginRequired unless access_control.logged_in? | ||
|
||
owner = query(:owner).find | ||
|
||
raise NotFound unless owner | ||
repo = owner.repositories.first | ||
raise InsufficientAccess unless repo | ||
access_control.permissions(repo).build_create! | ||
|
||
results = query(:custom_images).for_owner(owner) | ||
result results | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.