Skip to content
Draft
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
45 changes: 45 additions & 0 deletions .github/workflows/build-6.0.0-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build Docker 6.0.0 image

on:
push:
branches: [ ui ]

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v6
with:
ref: 'ui'

- name: Retrieve Repomanager version
run: |
echo "VERSION=$(cat ${GITHUB_WORKSPACE}/www/version)" >> $GITHUB_ENV
echo "Version: ${{ env.VERSION }}"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

# Build the images
- name: Build and push docker
uses: docker/build-push-action@v6
with:
file: Dockerfile
push: true
tags: lbr38/repomanager:6.0.0-beta
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max
8 changes: 6 additions & 2 deletions .github/workflows/test-database-update.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Database update tests
# TODO debug
# Crash en boucle - à corriger une fois 6.0.0 mergé dans devel
# name: Database update tests

on:
push:
Expand Down Expand Up @@ -91,7 +93,9 @@ jobs:

cd ${GITHUB_WORKSPACE}

sed -i 's/branch:.*/branch: devel/g' docker-compose.yml
# TODO debug
# sed -i 's/branch:.*/branch: devel/g' docker-compose.yml
sed -i 's/branch:.*/branch: ui/g' docker-compose.yml
sed -i 's/FQDN:.*/FQDN: repomanager.test.com/g' docker-compose.yml

docker-compose -f docker-compose.yml up -d
Expand Down
7 changes: 7 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Approach
- Read existing files before writing. Don't re-read unless changed.
- Thorough in reasoning, concise in output.
- Skip files over 100KB unless required.
- No sycophantic openers or closing fluff.
- No emojis or em-dashes.
- Do not guess APIs, versions, flags, commit SHAs, or package names. Verify by reading code or docs before asserting.
27 changes: 27 additions & 0 deletions docker-compose-dev-6.0.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# TODO debug
# For my dev environment only
version: "3"
services:
repomanager:
container_name: repomanager-dev-600
image: repomanager
network_mode: host
environment:
FQDN: repomanager-dev-600.localhost
MAX_UPLOAD_SIZE: 64M
NGINX_LISTEN_PORT: 7777
PUID: 1000
PGID: 1000
build:
context: .
dockerfile: Dockerfile
args:
branch: ui
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/lib/docker/volumes/repomanager-dev-600-logs:/var/log/nginx
- /var/lib/docker/volumes/repomanager-dev-600-www:/var/www/repomanager
- /var/lib/docker/volumes/repomanager-dev-600-data:/var/lib/repomanager
- /var/lib/docker/volumes/repomanager-dev-600-repo:/home/repo
8 changes: 6 additions & 2 deletions docker/config/nginx/repomanager.conf
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ server {
access_log off;
}

location /repo {
alias $REPOS_DIR;
# Matches /repo/ and /repo/xxx but not /repository
location ^~ /repo/ {
# Final slash is important, otherwise it could break the download of packages
alias $REPOS_DIR/;

# Uncomment the following lines to enable directory listing (autoindex) for repositories
# autoindex on;
# autoindex_exact_size off;
# autoindex_localtime on;
Expand Down
3 changes: 2 additions & 1 deletion www/bin/repomanager
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ echo '
| | \| ___/| |_> ) (_) ) Y Y \/ __ \| | \/ __ \/ /_/ > ___/| | \/
|__| \___ > __/ \____/|__|_| (____ /___| (____ |___ / \___ >__|
\/|__| \/ \/ \/ \/_____/ \/

'

echo -e "Version $(cat $WWW_DIR/version)\n"

while [ $# -ge 1 ];do
case "$1" in
--help|-help|-h)
Expand Down
1 change: 1 addition & 0 deletions www/config/tasks/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'env',
'group',
'description',
'tags',
'advanced-params' // Advanced params include package include/exclude and metadata custom fields, it is optional
],

Expand Down
1 change: 1 addition & 0 deletions www/config/tasks/duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'env',
'group',
'description',
'tags'
],

// Conditional params must be compared with form values
Expand Down
7 changes: 6 additions & 1 deletion www/config/tasks/env.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@
// Form configuration
$formConfig = [
// Allowed schedule types for this task
'allowed-schedule-types' => ['unique']
// Recurring is only allowed when the task targets a dynamic set of repositories,
// as pointing an environment on a fixed snapshot repeatedly makes no sense
'allowed-schedule-types' => ['unique'],

// This task can target a dynamic set of repositories (all latest snapshots matching filters)
'allow-dynamic-target' => true
];
5 changes: 4 additions & 1 deletion www/config/tasks/rebuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
// Form configuration
$formConfig = [
// Allowed schedule types for this task
'allowed-schedule-types' => ['unique', 'recurring']
'allowed-schedule-types' => ['unique', 'recurring'],

// This task can target a dynamic set of repositories (all latest snapshots matching filters)
'allow-dynamic-target' => true
];
7 changes: 3 additions & 4 deletions www/config/tasks/rename.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
$taskConfig = [
'description' => 'Rename repository',

// Retrieve repository info from snap id
'retrieve-repo-from-snap-id' => true,
// Retrieve repository info from repo id
'retrieve-repo-from-repo-id' => true,

// Required params
'required-params' => [
'name',
'snap-id',
'gpg-sign' // Required to make sure deb metadata is regenerated correctly
'repo-id'
],

// Conditional params must be compared with form values
Expand Down
5 changes: 4 additions & 1 deletion www/config/tasks/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@
// Form configuration
$formConfig = [
// Allowed schedule types for this task
'allowed-schedule-types' => ['unique', 'recurring']
'allowed-schedule-types' => ['unique', 'recurring'],

// This task can target a dynamic set of repositories (all latest snapshots matching filters)
'allow-dynamic-target' => true
];
22 changes: 7 additions & 15 deletions www/controllers/App/Config/Env.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@

namespace Controllers\App\Config;

use Exception;
use Controllers\Environment;

class Env
{
/**
* Load environments
*/
public static function get()
public static function get(): void
{
$myenv = new \Controllers\Environment();
$envController = new Environment();

if (!defined('ENVS')) {
define('ENVS', $myenv->listAll());
}
if (!defined('ENVS_TOTAL')) {
define('ENVS_TOTAL', $myenv->total());
define('ENVS', $envController->listAll());
}
if (!defined('DEFAULT_ENV')) {
define('DEFAULT_ENV', $myenv->default());
}
if (!defined('LAST_ENV')) {
define('LAST_ENV', $myenv->last());
define('DEFAULT_ENV', $envController->default());
}

/**
* If there is no environment configured then __LOAD_ERROR_EMPTY_ENVS = 1
*/
// If there is no environment configured then __LOAD_ERROR_EMPTY_ENVS = 1
if (empty(ENVS)) {
if (!defined('__LOAD_ERROR_EMPTY_ENVS')) {
define('__LOAD_ERROR_EMPTY_ENVS', 1);
Expand All @@ -39,6 +31,6 @@ public static function get()
}
}

unset($myenv);
unset($envController);
}
}
2 changes: 1 addition & 1 deletion www/controllers/App/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct(string $level = 'all')

// Errors related to the loading of the environments
if (defined('__LOAD_ERROR_EMPTY_ENVS') && __LOAD_ERROR_EMPTY_ENVS > 0) {
$__LOAD_ERROR_MESSAGES[] = '<b>You must at least configure 1 environment.</b>';
$__LOAD_ERROR_MESSAGES[] = '<b>You should at least configure one environment.</b>';
$__LOAD_GENERAL_ERROR++;
}

Expand Down
2 changes: 1 addition & 1 deletion www/controllers/App/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Permissions
public static function load()
{
$userController = new \Controllers\User\User();
$userPermissionController = new \Controllers\User\Permission();
$userPermissionController = new \Controllers\User\Permission\Permission();
$isAdmin = false;
$isSuperAdmin = false;

Expand Down
47 changes: 34 additions & 13 deletions www/controllers/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function add(string $name, string $color) : void
* Check if environment already exists
*/
if ($this->exists($name)) {
throw new Exception('Environment <b>' . $name . '</b> already exists');
throw new Exception('Environment ' . $name . ' already exists');
}

/**
Expand All @@ -72,7 +72,7 @@ public function add(string $name, string $color) : void
/**
* Add env to database
*/
$this->model->add($name, $color);
$this->model->add($name, $color, 'false');
}

/**
Expand Down Expand Up @@ -106,17 +106,14 @@ public function edit(array $envs) : void
throw new Exception('You are not allowed to perform this action');
}

/**
* Delete all envs from database before inserting the new ones
*/
// Delete all envs from database before inserting the new ones
$this->model->deleteAll();

/**
* Check if all specified envs are valid then add them to $envsToInsert array
*/
// Check that all specified env values are valid
foreach ($envs as $env) {
$name = Validate::string($env['name']);
$color = Validate::string($env['color']);
$protected = Validate::string($env['protected']);

if (empty($name)) {
throw new Exception('Environment name is empty');
Expand All @@ -126,30 +123,54 @@ public function edit(array $envs) : void
throw new Exception('Environment color is empty');
}

if (!in_array($protected, ['true', 'false'])) {
throw new Exception('Environment protected value is invalid');
}

if (!Validate::alphaNumericHyphen($name)) {
throw new Exception('Environment <b>' . $name . '</b> contains invalid characters');
throw new Exception('Environment ' . $name . ' contains invalid characters');
}

if ($this->exists($name)) {
throw new Exception('Environment <b>' . $name . '</b> already exists');
throw new Exception('Environment ' . $name . ' already exists');
}

$this->model->add($name, $color);
$this->model->add($name, $color, $protected);
}
}

/**
* Return all environments list
*/
public function listAll()
public function listAll(): array
{
return $this->model->listAll();
}

/**
* Return the list of protected environments
*/
public function getProtected(): array
{
return $this->model->getProtected();
}

/**
* Return true if the environment is protected
*/
public function isProtected(string $name): bool
{
if (in_array($name, $this->getProtected())) {
return true;
}

return false;
}

/**
* Return default environment
*/
public function default()
public function default(): string
{
return $this->model->default();
}
Expand Down
8 changes: 8 additions & 0 deletions www/controllers/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ public function getReposMembers(int $id): array
return $this->model->getReposMembers($id);
}

/**
* Return the list of group Ids the specified repo is member of
*/
public function getRepoGroupsIds(int $repoId): array
{
return $this->model->getRepoGroupsIds($repoId);
}

/**
* Return the list of repos not in any group
*/
Expand Down
Loading
Loading