Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

PoC: Allow portusctl to access the API #1403

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inherit_from:

# TODO: (mssola) only the LDAP class and portusctl require this.
Metrics/ClassLength:
Max: 200
Max: 210

# TODO: (mssola) Some methods are offending this cop. In the SUSE's style guide
# the approach is to use Rubocop's default value. In the near future I will
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ after_success:
addons:
code_climate:
repo_token: 18a0cf6c35e0c801678f12f444051c33e0390ce0efa91ec06a2aa5068b10c19e
mariadb: '10.0'
mariadb: '10.2'
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ gem "grape-entity"
gem "grape-swagger"
gem "grape-swagger-entity"
gem "hashie-forbidden_attributes"
gem "omniauth-google-oauth2"
gem "omniauth-openid"
gem "omniauth-github"
gem "omniauth-gitlab"

# Pinning these specific versions because that's what we have on OBS.
gem "ethon", "~> 0.9.0"
Expand Down Expand Up @@ -57,7 +61,7 @@ def packaging?
end

# If the deployment is done through Puma, include it in the bundle.
gem "puma", "~> 3.7.0" if ENV["PORTUS_PUMA_DEPLOYMENT"] == "yes" || !packaging?
gem "puma", "~> 3.9.1" if ENV["PORTUS_PUMA_DEPLOYMENT"] == "yes" || !packaging?

# Configuration management
gem "cconfig", "~> 1.1.0"
Expand Down
50 changes: 42 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ GEM
multipart-post (>= 1.2, < 3)
ffaker (2.0.0)
ffi (1.9.10)
font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
formatador (0.2.5)
git-review (2.0.0)
gli (~> 2.8.0)
Expand Down Expand Up @@ -198,7 +198,7 @@ GEM
json-schema (2.5.1)
addressable (~> 2.3.7)
jsonapi-renderer (0.1.3)
jwt (1.5.0)
jwt (1.5.6)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -230,14 +230,40 @@ GEM
mustermann (~> 1.0.0)
mysql2 (0.4.7)
nenv (0.3.0)
net-ldap (0.11)
net-ldap (0.16.0)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
octokit (2.0.0)
sawyer (~> 0.3.0)
omniauth (1.6.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-github (1.3.0)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
omniauth-gitlab (1.0.2)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.0)
omniauth-google-oauth2 (0.5.0)
jwt (~> 1.5)
multi_json (~> 1.3)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.3.1)
omniauth-oauth2 (1.4.0)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-openid (1.0.1)
omniauth (~> 1.0)
rack-openid (~> 1.3.1)
opener (0.1.0)
orm_adapter (0.5.0)
paint (1.0.0)
Expand All @@ -260,7 +286,7 @@ GEM
activerecord (>= 3.0)
i18n (>= 0.5.0)
railties (>= 3.0.0)
puma (3.7.0)
puma (3.9.1)
pundit (1.0.1)
activesupport (>= 3.0.0)
quiet_assets (1.1.0)
Expand All @@ -270,6 +296,9 @@ GEM
rack (>= 0.4)
rack-mini-profiler (0.9.3)
rack (>= 1.1.3)
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.8)
Expand All @@ -285,9 +314,9 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-erd (1.4.6)
activerecord (>= 3.2)
Expand Down Expand Up @@ -339,6 +368,7 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-graphviz (1.2.2)
ruby-openid (2.7.0)
ruby-progressbar (1.8.1)
ruby2ruby (2.3.0)
ruby_parser (~> 3.1)
Expand Down Expand Up @@ -474,10 +504,14 @@ DEPENDENCIES
md2man (~> 5.1.1)
mysql2 (= 0.4.7)
net-ldap
omniauth-github
omniauth-gitlab
omniauth-google-oauth2
omniauth-openid
poltergeist (~> 1.15.0)
pry-rails
public_activity
puma (~> 3.7.0)
puma (~> 3.9.1)
pundit
quiet_assets
rack-mini-profiler
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Some highlights:

- [Synchronization with your private registry in order to fetch which images and tags are available](http://port.us.org/features/1_Synchronizing-the-Registry-and-Portus.html).
- [LDAP user authentication](http://port.us.org/features/2_LDAP-support.html).
- OAuth and OpenID-Connect authentication
- [Monitoring of all the activities performed onto your private registry and Portus itself](http://port.us.org/features/4_audit.html).
- [Search for repositories and tags inside of your private registry](http://port.us.org/features/5_search.html).
- [Star your favorite repositories](http://port.us.org/features/6_starring.html).
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import './bootstrap';
// new modules structure
import './modules/users';
import './modules/dashboard';
import './modules/explore';
import './modules/repositories';
import './modules/namespaces';
import './modules/teams';
Expand Down
19 changes: 19 additions & 0 deletions app/assets/javascripts/modules/explore/components/result-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import moment from 'moment';

import Tag from '~/modules/repositories/components/tag';

export default {
template: '#js-result-item-tmpl',

props: ['repository'],

components: {
Tag,
},

computed: {
updatedAt() {
return moment(this.repository.updated_at).fromNow();
},
},
};
1 change: 1 addition & 0 deletions app/assets/javascripts/modules/explore/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './pages/index';
30 changes: 30 additions & 0 deletions app/assets/javascripts/modules/explore/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Vue from 'vue';

import ResultItem from '../components/result-item';

const { set } = Vue;

$(() => {
if (!$('body[data-route="explore/index"]').length) {
return;
}

// eslint-disable-next-line no-new
new Vue({
el: 'body[data-route="explore/index"] .vue-root',

components: {
ResultItem,
},

data() {
return {
repositories: [],
};
},

mounted() {
set(this, 'repositories', window.repositories);
},
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export default {

this.toggleForm();
this.$v.$reset();
set(this.namespace, 'namespace', {});
set(this.namespace, 'namespace', {
name: '',
team: this.teamName || '',
});

Alert.show(`Namespace '${name}' was created successfully`);
EventBus.$emit('namespaceCreated', namespace);
Expand Down
42 changes: 42 additions & 0 deletions app/assets/javascripts/modules/repositories/components/tag.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<style scoped>
.label {
cursor: pointer;
}
</style>

<template>
<div class="label label-success" title="Copy to clipboard" @click="copyToClipboard">
{{ tag.name }}
</div>
</template>

<script>
import Alert from '~/shared/components/alert';

export default {
props: ['tag', 'repository'],

computed: {
commandToPull() {
const hostname = this.repository.registry_hostname;
const repoName = this.repository.full_name;
const tagName = this.tag.name;

return `docker pull ${hostname}/${repoName}:${tagName}`;
},
},

methods: {
copyToClipboard() {
const $temp = $('<input>');

$('body').append($temp);
$temp.val(this.commandToPull).select();
document.execCommand('copy');
$temp.remove();

Alert.show('Copied pull command to clipboard');
},
},
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<input type="checkbox" v-model="selected" @change="toggleTag()">
</td>
<td>
<div class="label label-success" v-for="t in tag">{{ t.name }}</div>
<tag v-for="t in tag" :key="t.name" :tag="t" :repository="state.repository"></tag>
</td>

<td>{{ tag[0].author.username }}</td>
Expand All @@ -33,6 +33,8 @@
</template>

<script>
import Tag from './tag';

import VulnerabilitiesParser from '../services/vulnerabilities-parser';

export default {
Expand All @@ -43,6 +45,10 @@
state: Object,
},

components: {
Tag,
},

data() {
return {
tagsPath: '/tags',
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/modules/repositories/pages/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ $(() => {
const id = this.$refs.repoTitle.dataset.id;

RepositoriesService.get(id).then((response) => {
set(this.state, 'repository', response.body);
set(this, 'tags', response.body.tags);
set(this, 'notLoaded', false);
set(this, 'unableToFetchBefore', false);
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/components/layout.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

header {
height: 60px;
.logo-header {
Expand Down
9 changes: 9 additions & 0 deletions app/assets/stylesheets/includes/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ section.sign-up {
.btn-link {
color: $white
}
.social-login-title {
color: $white;
margin-top: 25px;
margin-bottom: 15px;
}
.social-btns a.btn{
margin-bottom: 5px;
border-radius: 4px;
}
}

textarea.fixed-size {
Expand Down
30 changes: 30 additions & 0 deletions app/assets/stylesheets/pages/explore.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.explore {
h2 {
color: $white;
margin-bottom: 15px;
}

.result-list {
list-style-type: none;
padding: 0;
}

.result-item {
background: rgba(255, 255, 255, 0.85);
border-radius: 5px;
margin-bottom: 10px;
padding: 15px;
}

.result-item-name {
margin-top: 0;
}

.result-item-stars {
line-height: 23px; // 18 height + 5 diff between fonts

.fa-star {
color: $primary-colour;
}
}
}
Loading