Skip to content
Snippets Groups Projects
Commit 138cea37 authored by Geoffrey Arthaud's avatar Geoffrey Arthaud
Browse files

Merge branch 'xx-bug-job-token' into 'main'

Fix program crashes when use job token

See merge request !3
parents cb9dff06 2ae7760d
Branches
Tags
1 merge request!3Fix program crashes when use job token
...@@ -45,6 +45,9 @@ include: ...@@ -45,6 +45,9 @@ include:
forceBuild: true forceBuild: true
Dockerfile: ${CI_PROJECT_DIR}/Dockerfile Dockerfile: ${CI_PROJECT_DIR}/Dockerfile
copy-image-rust:
cache: [ ]
release-gpd-image: release-gpd-image:
needs: needs:
- release-linux - release-linux
...@@ -68,6 +71,7 @@ test-rust-current: ...@@ -68,6 +71,7 @@ test-rust-current:
script: script:
- cargo test --verbose - cargo test --verbose
- cargo run -- $TEST_OPTIONS - cargo run -- $TEST_OPTIONS
- cargo run -- $TEST_OPTIONS --token $TEST_GL_TOKEN
allow_failure: true allow_failure: true
test-rust-nightly: test-rust-nightly:
...@@ -124,6 +128,8 @@ release-macos-silicon: ...@@ -124,6 +128,8 @@ release-macos-silicon:
LDD_CMD: otool -L LDD_CMD: otool -L
tags: tags:
- macos_mx - macos_mx
rules:
- if: $CI_COMMIT_TAG
release-macos-x86: release-macos-x86:
extends: .rust-release extends: .rust-release
...@@ -133,6 +139,8 @@ release-macos-x86: ...@@ -133,6 +139,8 @@ release-macos-x86:
LDD_CMD: otool -L LDD_CMD: otool -L
tags: tags:
- macos_mx - macos_mx
rules:
- if: $CI_COMMIT_TAG
release-windows: release-windows:
extends: .rust-release extends: .rust-release
......
...@@ -9,7 +9,7 @@ container-policy-disabled = L'option "Clean up image tags" est désactivée. ...@@ -9,7 +9,7 @@ container-policy-disabled = L'option "Clean up image tags" est désactivée.
container-policy-enabled = L'option "Clean up image tags" est activée container-policy-enabled = L'option "Clean up image tags" est activée
container-report = {$image_count} images dans le container registry. {$old_image_count} datent de plus de {$nb_days} jours container-report = {$image_count} images dans le container registry. {$old_image_count} datent de plus de {$nb_days} jours
container-summary = Taille du container registry : {$registry_size} container-summary = Taille du container registry : {$registry_size}
duplicate-assets-option-error = Cannot get the number of duplicate assets to keep option duplicate-assets-option-error = Impossible d'accéder à l'option "The number of duplicate assets to keep"
duplicate-assets-option-onepackage = L'option "The number of duplicate assets to keep" vaut 1 duplicate-assets-option-onepackage = L'option "The number of duplicate assets to keep" vaut 1
duplicate-assets-option-warn = L'option "The number of duplicate assets to keep" ne vaut PAS 1 duplicate-assets-option-warn = L'option "The number of duplicate assets to keep" ne vaut PAS 1
error = Erreur : error = Erreur :
......
use crate::diagnosis::gitlab_connection::Project;
use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable};
use gitlab::Gitlab; use gitlab::Gitlab;
use graphql_client::*; use graphql_client::*;
use crate::diagnosis::gitlab_connection::{GitlabToken, Project};
use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable};
pub struct ConfAnalysisJob { pub struct ConfAnalysisJob {
pub gitlab: Gitlab, pub gitlab: Gitlab,
pub project: Project, pub project: Project,
pub job_token: bool,
} }
pub struct ConfAnalysisReport { pub struct ConfAnalysisReport {
...@@ -66,6 +68,7 @@ impl ConfAnalysisJob { ...@@ -66,6 +68,7 @@ impl ConfAnalysisJob {
ConfAnalysisJob { ConfAnalysisJob {
gitlab: gitlab.gitlab.clone(), gitlab: gitlab.gitlab.clone(),
project: gitlab.project.clone(), project: gitlab.project.clone(),
job_token: matches!(&gitlab.token, GitlabToken::JobToken(_)),
} }
} }
...@@ -85,6 +88,9 @@ impl ConfAnalysisJob { ...@@ -85,6 +88,9 @@ impl ConfAnalysisJob {
} }
fn _report_duplicate_policy(&self) -> ReportStatus { fn _report_duplicate_policy(&self) -> ReportStatus {
if self.job_token {
return ReportStatus::ERROR(fl!("duplicate-assets-option-error"));
}
if let Some(policy) = self._get_duplicate_policy() { if let Some(policy) = self._get_duplicate_policy() {
return if let conf_package_duplicate_query::PackagesCleanupKeepDuplicatedPackageFilesEnum::ONE_PACKAGE_FILE = policy { return if let conf_package_duplicate_query::PackagesCleanupKeepDuplicatedPackageFilesEnum::ONE_PACKAGE_FILE = policy {
ReportStatus::OK(fl!("duplicate-assets-option-onepackage")) ReportStatus::OK(fl!("duplicate-assets-option-onepackage"))
...@@ -102,15 +108,11 @@ impl ConfAnalysisJob { ...@@ -102,15 +108,11 @@ impl ConfAnalysisJob {
project_path: self.project.path_with_namespace.to_string(), project_path: self.project.path_with_namespace.to_string(),
}; };
let query = ConfPackageDuplicateQuery::build_query(variables); let query = ConfPackageDuplicateQuery::build_query(variables);
let response = self self.gitlab
.gitlab
.graphql::<ConfPackageDuplicateQuery>(&query) .graphql::<ConfPackageDuplicateQuery>(&query)
.unwrap(); .ok()
Some( .and_then(|r| r.project)
response .and_then(|r| r.packages_cleanup_policy)
.project? .map(|r| r.keep_n_duplicated_package_files)
.packages_cleanup_policy?
.keep_n_duplicated_package_files,
)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment