fix
This commit is contained in:
@@ -1,13 +1,47 @@
|
||||
const SRC=src;
|
||||
const DEST=dest;
|
||||
const duplicates=["auto-ci-detector.py"];
|
||||
fn post_pack() {
|
||||
const duplicates=["auto_ci_detector.py","functions.sh"];
|
||||
const DOMAIN = config.domain;
|
||||
const NAME = instance;
|
||||
fn duplicate_files() {
|
||||
for file in global::duplicates {
|
||||
shell(`cp ${global::SRC}/${file} ${global::DEST}/${file}`);
|
||||
}
|
||||
}
|
||||
fn have_gitea() {
|
||||
have_namespace(`${global::DOMAIN}-ci`) && have_install(`${global::DOMAIN}-ci`, "gitea") && have_service(`${global::DOMAIN}-ci`, "gitea-http") && have_secret(`${global::DOMAIN}-ci`, "gitea-admin-user")
|
||||
}
|
||||
fn have_sonar() {
|
||||
have_namespace(`${global::DOMAIN}-ci`) && have_install(`${global::DOMAIN}-ci`, "sonar") && have_service(`${global::DOMAIN}-ci`, "sonar-sonar") && have_secret(`${global::DOMAIN}-ci`, "sonar-sonar")
|
||||
}
|
||||
fn have_taiga() {
|
||||
have_namespace(`${global::DOMAIN}-ci`) && have_install(`${global::DOMAIN}-ci`, "taiga") && have_service(`${global::DOMAIN}-ci`, "taiga-taiga") && have_secret(`${global::DOMAIN}-ci`, "taiga-taiga")
|
||||
}
|
||||
fn gitea_repos() {
|
||||
let repos = [];
|
||||
let org = global::NAME;
|
||||
org.replace("org-","");
|
||||
if (have_gitea() && have_sonar()) {
|
||||
let gitea = get_secret(`${global::DOMAIN}-ci`, "gitea-admin-user");
|
||||
let username = base64_decode(gitea.data.username);
|
||||
let password = base64_decode(gitea.data.password);
|
||||
let headers = http_header_basic(username,password);
|
||||
let response = http_get_json(`http://gitea-http.${global::DOMAIN}-ci.svc:3000/api/v1/orgs/${org}/repos`, headers);
|
||||
repos += response.json.map(|p| p.name);
|
||||
repos.sort();
|
||||
log_info(`Found ${repos.len} repos`);
|
||||
}
|
||||
repos
|
||||
}
|
||||
fn post_pack() {
|
||||
duplicate_files();
|
||||
}
|
||||
fn post_template() {
|
||||
for file in global::duplicates {
|
||||
shell(`cp ${global::SRC}/${file} ${global::DEST}/${file}`);
|
||||
}
|
||||
save_to_tf(`${global::DEST}/conditions.tf`, "conditions", #{
|
||||
have_gitea: have_gitea(),
|
||||
have_sonar: have_sonar(),
|
||||
have_taiga: have_taiga(),
|
||||
repos: gitea_repos()
|
||||
});
|
||||
duplicate_files();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user