Skip to content
Snippets Groups Projects
Verified Commit 2ae7760d authored by Geoffrey Arthaud's avatar Geoffrey Arthaud
Browse files

Fix program crashes when use job token

parent cb9dff06
No related branches found
No related tags found
1 merge request!3Fix program crashes when use job token
......@@ -45,6 +45,9 @@ include:
forceBuild: true
Dockerfile: ${CI_PROJECT_DIR}/Dockerfile
copy-image-rust:
cache: [ ]
release-gpd-image:
needs:
- release-linux
......@@ -68,6 +71,7 @@ test-rust-current:
script:
- cargo test --verbose
- cargo run -- $TEST_OPTIONS
- cargo run -- $TEST_OPTIONS --token $TEST_GL_TOKEN
allow_failure: true
test-rust-nightly:
......@@ -124,6 +128,8 @@ release-macos-silicon:
LDD_CMD: otool -L
tags:
- macos_mx
rules:
- if: $CI_COMMIT_TAG
release-macos-x86:
extends: .rust-release
......@@ -133,6 +139,8 @@ release-macos-x86:
LDD_CMD: otool -L
tags:
- macos_mx
rules:
- if: $CI_COMMIT_TAG
release-windows:
extends: .rust-release
......
......@@ -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-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}
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-warn = L'option "The number of duplicate assets to keep" ne vaut PAS 1
error = Erreur :
......
use crate::diagnosis::gitlab_connection::Project;
use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable};
use gitlab::Gitlab;
use graphql_client::*;
use crate::diagnosis::gitlab_connection::{GitlabToken, Project};
use crate::{fl, GitlabRepository, ReportJob, ReportPending, ReportStatus, Reportable};
pub struct ConfAnalysisJob {
pub gitlab: Gitlab,
pub project: Project,
pub job_token: bool,
}
pub struct ConfAnalysisReport {
......@@ -66,6 +68,7 @@ impl ConfAnalysisJob {
ConfAnalysisJob {
gitlab: gitlab.gitlab.clone(),
project: gitlab.project.clone(),
job_token: matches!(&gitlab.token, GitlabToken::JobToken(_)),
}
}
......@@ -85,6 +88,9 @@ impl ConfAnalysisJob {
}
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() {
return if let conf_package_duplicate_query::PackagesCleanupKeepDuplicatedPackageFilesEnum::ONE_PACKAGE_FILE = policy {
ReportStatus::OK(fl!("duplicate-assets-option-onepackage"))
......@@ -102,15 +108,11 @@ impl ConfAnalysisJob {
project_path: self.project.path_with_namespace.to_string(),
};
let query = ConfPackageDuplicateQuery::build_query(variables);
let response = self
.gitlab
self.gitlab
.graphql::<ConfPackageDuplicateQuery>(&query)
.unwrap();
Some(
response
.project?
.packages_cleanup_policy?
.keep_n_duplicated_package_files,
)
.ok()
.and_then(|r| r.project)
.and_then(|r| r.packages_cleanup_policy)
.map(|r| r.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