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
WIP - Fixes #11612 - Enables use of Ostree Units #5838
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Katello | ||
class Api::V2::OstreeBranchesController < Api::V2::ApiController | ||
apipie_concern_subst(:a_resource => N_("an ostree branch"), :resource => "ostree_branch") | ||
include Katello::Concerns::Api::V2::RepositoryContentController | ||
|
||
private | ||
|
||
def resource_class | ||
OstreeBranch | ||
end | ||
|
||
def filter_by_content_view_filter(filter) | ||
resource_class.where(:uuid => filter.send("#{singular_resource_name}_rules").pluck(:uuid)) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
module Katello | ||
class OstreeBranch < Katello::Model | ||
belongs_to :repository, :class_name => "Katello::Repository", :inverse_of => :ostree_branches | ||
validates :name, presence: true, uniqueness: {scope: :repository_id} | ||
validates :repository, :presence => true | ||
validate :ensure_ostree_repository | ||
|
||
def ensure_ostree_repository | ||
unless self.repository.ostree? | ||
errors.add(:base, _("Branch cannot be created since it does not belong to an RPM OSTree repository.")) | ||
end | ||
include Concerns::PulpDatabaseUnit | ||
|
||
has_many :repository_ostree_branches, :dependent => :destroy | ||
has_many :repositories, :through => :repository_ostree_branches, :inverse_of => :ostree_branches | ||
|
||
scoped_search :on => :name, :complete_value => true | ||
scoped_search :on => :version, :complete_value => true | ||
scoped_search :on => :commit, :complete_value => true | ||
scoped_search :on => :uuid, :complete_value => true | ||
|
||
CONTENT_TYPE = Pulp::DockerManifest::CONTENT_TYPE | ||
|
||
def self.repository_association_class | ||
RepositoryOstreeBranch | ||
end | ||
|
||
def update_from_json(json) | ||
update_attributes(:name => json[:branch], | ||
:version => json[:metadata][:version], | ||
:commit => json[:commit] | ||
) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Katello | ||
class RepositoryOstreeBranch < Katello::Model | ||
self.include_root_in_json = false | ||
|
||
# Do not use active record callbacks in this join model. Direct INSERTs and DELETEs are done | ||
belongs_to :repository, :inverse_of => :repository_ostree_branches, :class_name => 'Katello::Repository' | ||
belongs_to :ostree_branch, :inverse_of => :repository_ostree_branches | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Katello | ||
module Pulp | ||
class OstreeBranch < PulpContentUnit | ||
CONTENT_TYPE = "ostree" | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
object false | ||
|
||
extends "katello/api/v2/common/metadata" | ||
|
||
child @collection[:results] => :results do | ||
extends 'katello/api/v2/ostree_branches/show' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object @resource | ||
|
||
attributes :uuid, :id | ||
attributes :name, :version, :commit |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class AddVersionOstreeBranches < ActiveRecord::Migration | ||
def up | ||
drop_table :katello_ostree_branches if ActiveRecord::Base.connection.table_exists? "katello_ostree_branches" | ||
|
||
create_table :katello_ostree_branches do |t| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to drop the table entirely and recreate it instead of migrating the current table? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to recreate the content by reindexing anyway so dropping the table and creating it seems easier than dropping all rows and migrating the table. Either works for me though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough - given the way the down looks I'd wonder if a change migration would be cleaner? I do not claim to be a migration expert which is why I ask these questions :) |
||
t.string :version, :limit => 255 | ||
t.string :name, :limit => 255 | ||
t.string :uuid, :null => false, :limit => 255 | ||
t.string :commit, :limit => 255 | ||
t.timestamps | ||
end | ||
|
||
create_table :katello_repository_ostree_branches do |t| | ||
t.references :ostree_branch, :null => false | ||
t.references :repository, :null => true | ||
t.timestamps | ||
end | ||
|
||
add_index :katello_repository_ostree_branches, [:ostree_branch_id, :repository_id], | ||
:name => :katello_repo_ostree_branch_repo_id, :unique => true | ||
|
||
add_foreign_key :katello_repository_ostree_branches, :katello_repositories, | ||
:column => :repository_id | ||
end | ||
|
||
def down | ||
drop_table :katello_repository_ostree_branches | ||
drop_table :katello_ostree_branches | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to create the index and table from this down migration or else it will fail: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @daviddavis updated |
||
create_table :katello_ostree_branches do |t| | ||
t.string :name, :null => false, :limits => 255 | ||
t.references :repository, :null => false | ||
t.timestamps | ||
end | ||
|
||
add_index :katello_ostree_branches, [:repository_id], | ||
:name => :index_branches_on_repository | ||
|
||
add_index :katello_ostree_branches, [:repository_id, :name], | ||
:name => :katello_ostree_branches_repo_branch, :unique => true | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc factory | ||
* @name Bastion.ostree-branches.factory:OstreeBranch | ||
* | ||
* @description | ||
* Provides a BastionResource for interacting with Ostree Branches | ||
*/ | ||
function OstreeBranch(BastionResource) { | ||
return BastionResource('/katello/api/v2/ostree_branches/:id', | ||
{'id': '@id'} | ||
); | ||
} | ||
|
||
angular | ||
.module('Bastion.ostree-branches') | ||
.factory('OstreeBranch', OstreeBranch); | ||
|
||
OstreeBranch.$inject = ['BastionResource']; | ||
|
||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc module | ||
* @name Bastion.ostree-branches | ||
* | ||
* @description | ||
* Module for Ostree Branch related functionality. | ||
*/ | ||
angular | ||
.module('Bastion.ostree-branches', ['Bastion']); | ||
|
||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<span page-title ng-model="repository">{{ 'Manage Ostree Branchesfor Repository:' | translate }} {{ repository.name }}</span> | ||
|
||
<a ui-sref="products.details.repositories.info({productId: product.id, repositoryId: repository.id})"> | ||
<i class="fa fa-angle-double-left"></i> | ||
{{ "Back to Repository Details" | translate }} | ||
</a> | ||
|
||
<div data-extend-template="layouts/details-nutupane.html"> | ||
|
||
<div data-block="pane-loading"></div> | ||
|
||
<div data-block="messages"> | ||
<div bst-alerts success-messages="successMessages" error-messages="errorMessages"></div> | ||
|
||
<div bst-alert="success" ng-hide="generationTaskId === undefined"> | ||
<button type="button" class="close" ng-click="clearTaskId()">×</button> | ||
<p translate> | ||
Ostree Branch metadata generation has been initiated in the background. Click | ||
<a ng-href="{{ taskUrl() }}">Here</a> to monitor the progress. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div data-block="header"> | ||
<h3 translate>Ostree Branches in {{ repository.name }}</h3> | ||
</div> | ||
|
||
<div data-block="table"> | ||
<table class="table table-striped table-bordered" > | ||
|
||
<thead> | ||
<tr bst-table-head> | ||
<th bst-table-column><span translate>Branch Name</span></th> | ||
<th bst-table-column><span translate>Version</span></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<tr bst-table-row ng-repeat="item in detailsTable.rows" row-select="item"> | ||
<td bst-table-cell> | ||
{{ item.name }} | ||
</td> | ||
<td bst-table-cell> | ||
{{ item.version }} | ||
</td> | ||
</tr> | ||
</tbody> | ||
|
||
</table> | ||
</div> | ||
|
||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I make content view filters with ostree content?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No but this method is needed for the index call -> look at https://github.com/Katello/katello/blob/master/app/controllers/katello/concerns/api/v2/repository_content_controller.rb#L87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nonsensical addition though is it not? You can't filter by content view filters for ostree branches and someone looking at this code would think you could.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bbuckingham @ehelms @jlsherrill @daviddavis What would be your suggested approach to fix this
Also this seems like a change that is arguably outside the scope of this PR which already seems to be doing a lot. I say this because I would have to change controllers that include this RepositoryContentController concern for either option.
Would you prefer a separate story or want me to change here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just raising an error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway created http://projects.theforeman.org/issues/14046 .. I 'll update the message in this PR if I fix it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably re-word it to capture that the API is specifying content view filters as an API param on types that it does not apply to (
katello/app/controllers/katello/concerns/api/v2/repository_content_controller.rb
Line 25 in f8509ae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does DockerManifest ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehelms thing is even if filter id is not provided this method is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it?