the default GitOps source repository for booting up Jenkins X
Revisão | 145ee48defa6d7ca0620887f1db016f06c4d3a70 (tree) |
---|---|
Hora | 2019-10-04 22:13:26 |
Autor | Cosmin Cojocar <ccojocar@clou...> |
Commiter | GitHub |
Merge pull request #68 from cagiti/add_create_domain_setup_for_bdd
WIP: script which upserts domains for testing
@@ -0,0 +1,61 @@ | ||
1 | +#!/usr/bin/env bash | |
2 | + | |
3 | +BDD_PROJECT="jenkins-x-bdd3" | |
4 | +PARENT_PROJECT="jenkins-x-rocks" | |
5 | +PREFIXES=("boot" "boot1" "boot2" "boot3" "boot4" "boot5" "boot6" "boot7" "boot8" "boot9" "boot10" "boot11" "boot12") | |
6 | +SUBDOMAIN="bdd.jenkins-x.rocks" | |
7 | + | |
8 | +function does_subdomain_exist() | |
9 | +{ | |
10 | + local domain=$1 | |
11 | + gcloud dns managed-zones --project=$BDD_PROJECT list --filter=$domain --format=json | jq length | |
12 | +} | |
13 | + | |
14 | +function get_domain_nameservers() | |
15 | +{ | |
16 | + local domain=$1 | |
17 | + local project=$2 | |
18 | + gcloud dns managed-zones --project=$project list --filter=$domain --format=json | jq .[].nameServers | |
19 | +} | |
20 | + | |
21 | +function get_recordset_nameservers() | |
22 | +{ | |
23 | + #TODO | |
24 | + echo "TODO" | |
25 | +} | |
26 | + | |
27 | +function create_subdomain() | |
28 | +{ | |
29 | + local domain=$1 | |
30 | + gcloud dns managed-zones --project=$BDD_PROJECT create "${domain//\./-}" --dns-name "${domain}." --description="managed-zone for bdd tests" | |
31 | +} | |
32 | + | |
33 | +function create_recordset_ns_entry() | |
34 | +{ | |
35 | + #TODO | |
36 | + echo "TODO" | |
37 | +} | |
38 | + | |
39 | +function create_managed_zone() | |
40 | +{ | |
41 | + #TODO | |
42 | + echo "TODO" | |
43 | +} | |
44 | + | |
45 | +for prefix in "${PREFIXES[@]}" | |
46 | +do | |
47 | + domain="${prefix}.${SUBDOMAIN}" | |
48 | + exists=$(does_subdomain_exist "${domain}") | |
49 | + | |
50 | + if [[ $exists -eq 0 ]] | |
51 | + then | |
52 | + echo "$domain doesn't exist" | |
53 | + #create_subdomain "${domain}" | |
54 | + else | |
55 | + echo "$domain exists" | |
56 | + child_nameservers="$(get_domain_nameservers "${domain}" "${BDD_PROJECT}")" | |
57 | + parent_nameservers="$(get_recordset_nameservers "${domain}" "${PARENT_PROJECT}")" | |
58 | + echo "${child_nameservers}" | |
59 | + fi | |
60 | +done | |
61 | + |