38 lines
1.6 KiB
Plaintext
38 lines
1.6 KiB
Plaintext
const DEST=dest;
|
|
const DOMAIN = config.domain;
|
|
const NAME = instance;
|
|
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`, "sonar-sonar")
|
|
}
|
|
fn gitea_repos() {
|
|
let repos = [];
|
|
let org = "org-solidite";
|
|
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 got = http_get_json(`http://gitea-http.${global::DOMAIN}-ci.svc:3000/api/v1/orgs/${org}/repos`, headers);
|
|
log_warn(got.body);
|
|
repos += got.json.map(|p| p.name);
|
|
repos.sort();
|
|
log_info(`Found ${repos.len} repos`);
|
|
}
|
|
repos
|
|
}
|
|
fn post_template() {
|
|
save_to_tf(`${global::DEST}/conditions.tf`, "conditions", #{
|
|
have_gitea: have_gitea(),
|
|
have_sonar: have_sonar(),
|
|
have_taiga: have_taiga(),
|
|
repos: gitea_repos()
|
|
});
|
|
}
|