From 1193f6d509eae70241d354f9ba518c211cd38cb8 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Fri, 6 Mar 2026 13:13:11 -0300 Subject: [PATCH] chore: organize loose scripts into scripts/auto-organized --- .../auto-organized/approve_mfe_pipelines.ps1 | 38 ++ scripts/auto-organized/bs_inspect.json | Bin 0 -> 31416 bytes scripts/auto-organized/bs_labels.json | Bin 0 -> 8360 bytes scripts/auto-organized/bs_parsed.yaml | 97 +++++ scripts/auto-organized/bs_parsed_v2.yaml | 104 ++++++ scripts/auto-organized/check_builds.ps1 | 19 + scripts/auto-organized/check_builds2.ps1 | 19 + scripts/auto-organized/check_cf_dns.ps1 | 44 +++ scripts/auto-organized/check_cf_dns2.ps1 | 44 +++ scripts/auto-organized/check_ms_pipeline.ps1 | 10 + scripts/auto-organized/check_oke.ps1 | 23 ++ scripts/auto-organized/check_oke2.ps1 | 25 ++ scripts/auto-organized/check_oke3.ps1 | 12 + scripts/auto-organized/check_oke4.ps1 | 18 + scripts/auto-organized/check_pr.ps1 | 50 +++ scripts/auto-organized/check_stage.ps1 | 15 + scripts/auto-organized/check_stage2.ps1 | 15 + scripts/auto-organized/check_templates.ps1 | 29 ++ scripts/auto-organized/check_vg.ps1 | 55 +++ scripts/auto-organized/check_vg2.ps1 | 31 ++ scripts/auto-organized/complete_pr.ps1 | 46 +++ .../auto-organized/coolify_create_api2.json | 1 + .../coolify_create_backend.json | 14 + .../coolify_create_frontend.json | 14 + .../coolify_patch_api2_domain.json | 1 + .../auto-organized/coolify_patch_backend.json | 3 + scripts/auto-organized/coolify_patch_db.json | 1 + .../coolify_patch_frontend.json | 3 + scripts/auto-organized/coolify_patch_tmp.json | 1 + .../create_mfe_shell_deployment.json | 28 ++ scripts/auto-organized/fetch_env.ps1 | 5 + scripts/auto-organized/final_status.ps1 | 35 ++ scripts/auto-organized/final_status2.ps1 | 35 ++ .../auto-organized/fix_cf_dns_mfe_shell.ps1 | 66 ++++ .../fix_cf_dns_mfe_shell_oci.ps1 | 44 +++ .../auto-organized/fix_mfe_pipelines_oci.ps1 | 117 ++++++ scripts/auto-organized/fix_ms_pipelines.ps1 | 81 +++++ scripts/auto-organized/fix_vg.ps1 | 74 ++++ scripts/auto-organized/fix_vg2.ps1 | 79 ++++ scripts/auto-organized/fix_vg3.ps1 | 91 +++++ scripts/auto-organized/fix_vg4.ps1 | 80 ++++ scripts/auto-organized/fix_vg5.ps1 | 95 +++++ scripts/auto-organized/fix_vg6.ps1 | 98 +++++ scripts/auto-organized/fix_vg7.ps1 | 93 +++++ .../auto-organized/forgejo_create_icatu.json | 1 + scripts/auto-organized/get_build_log.ps1 | 38 ++ scripts/auto-organized/get_build_log2.ps1 | 38 ++ scripts/auto-organized/get_cf_records.ps1 | 13 + scripts/auto-organized/inspect_vg.ps1 | 23 ++ scripts/auto-organized/lb_rules.json | 27 ++ scripts/auto-organized/merge_templates.ps1 | 66 ++++ .../auto-organized/mfe_shell_spa_spec.json | 40 ++ scripts/auto-organized/mfe_shell_spec.json | 40 ++ scripts/auto-organized/private_key.pem | 28 ++ scripts/auto-organized/remotes.txt | 12 + .../retrigger_mfe_pipelines.ps1 | 60 +++ .../retrigger_mfe_pipelines2.ps1 | 60 +++ .../auto-organized/retrigger_mfe_shell.ps1 | 42 +++ .../revert_cf_mfe_shell_dev.ps1 | 24 ++ scripts/auto-organized/rsa_base64.txt | 1 + scripts/auto-organized/start.sh | 341 ++++++++++++++++++ scripts/auto-organized/verify_vg.ps1 | 20 + scripts/auto-organized/vw_full.json | 135 +++++++ scripts/auto-organized/wait_builds.ps1 | 48 +++ scripts/auto-organized/wait_builds2.ps1 | 48 +++ scripts/auto-organized/watch_approvals.ps1 | 35 ++ scripts/auto-organized/watch_approvals2.ps1 | 35 ++ 67 files changed, 2928 insertions(+) create mode 100644 scripts/auto-organized/approve_mfe_pipelines.ps1 create mode 100644 scripts/auto-organized/bs_inspect.json create mode 100644 scripts/auto-organized/bs_labels.json create mode 100644 scripts/auto-organized/bs_parsed.yaml create mode 100644 scripts/auto-organized/bs_parsed_v2.yaml create mode 100644 scripts/auto-organized/check_builds.ps1 create mode 100644 scripts/auto-organized/check_builds2.ps1 create mode 100644 scripts/auto-organized/check_cf_dns.ps1 create mode 100644 scripts/auto-organized/check_cf_dns2.ps1 create mode 100644 scripts/auto-organized/check_ms_pipeline.ps1 create mode 100644 scripts/auto-organized/check_oke.ps1 create mode 100644 scripts/auto-organized/check_oke2.ps1 create mode 100644 scripts/auto-organized/check_oke3.ps1 create mode 100644 scripts/auto-organized/check_oke4.ps1 create mode 100644 scripts/auto-organized/check_pr.ps1 create mode 100644 scripts/auto-organized/check_stage.ps1 create mode 100644 scripts/auto-organized/check_stage2.ps1 create mode 100644 scripts/auto-organized/check_templates.ps1 create mode 100644 scripts/auto-organized/check_vg.ps1 create mode 100644 scripts/auto-organized/check_vg2.ps1 create mode 100644 scripts/auto-organized/complete_pr.ps1 create mode 100644 scripts/auto-organized/coolify_create_api2.json create mode 100644 scripts/auto-organized/coolify_create_backend.json create mode 100644 scripts/auto-organized/coolify_create_frontend.json create mode 100644 scripts/auto-organized/coolify_patch_api2_domain.json create mode 100644 scripts/auto-organized/coolify_patch_backend.json create mode 100644 scripts/auto-organized/coolify_patch_db.json create mode 100644 scripts/auto-organized/coolify_patch_frontend.json create mode 100644 scripts/auto-organized/coolify_patch_tmp.json create mode 100644 scripts/auto-organized/create_mfe_shell_deployment.json create mode 100644 scripts/auto-organized/fetch_env.ps1 create mode 100644 scripts/auto-organized/final_status.ps1 create mode 100644 scripts/auto-organized/final_status2.ps1 create mode 100644 scripts/auto-organized/fix_cf_dns_mfe_shell.ps1 create mode 100644 scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1 create mode 100644 scripts/auto-organized/fix_mfe_pipelines_oci.ps1 create mode 100644 scripts/auto-organized/fix_ms_pipelines.ps1 create mode 100644 scripts/auto-organized/fix_vg.ps1 create mode 100644 scripts/auto-organized/fix_vg2.ps1 create mode 100644 scripts/auto-organized/fix_vg3.ps1 create mode 100644 scripts/auto-organized/fix_vg4.ps1 create mode 100644 scripts/auto-organized/fix_vg5.ps1 create mode 100644 scripts/auto-organized/fix_vg6.ps1 create mode 100644 scripts/auto-organized/fix_vg7.ps1 create mode 100644 scripts/auto-organized/forgejo_create_icatu.json create mode 100644 scripts/auto-organized/get_build_log.ps1 create mode 100644 scripts/auto-organized/get_build_log2.ps1 create mode 100644 scripts/auto-organized/get_cf_records.ps1 create mode 100644 scripts/auto-organized/inspect_vg.ps1 create mode 100644 scripts/auto-organized/lb_rules.json create mode 100644 scripts/auto-organized/merge_templates.ps1 create mode 100644 scripts/auto-organized/mfe_shell_spa_spec.json create mode 100644 scripts/auto-organized/mfe_shell_spec.json create mode 100644 scripts/auto-organized/private_key.pem create mode 100644 scripts/auto-organized/remotes.txt create mode 100644 scripts/auto-organized/retrigger_mfe_pipelines.ps1 create mode 100644 scripts/auto-organized/retrigger_mfe_pipelines2.ps1 create mode 100644 scripts/auto-organized/retrigger_mfe_shell.ps1 create mode 100644 scripts/auto-organized/revert_cf_mfe_shell_dev.ps1 create mode 100644 scripts/auto-organized/rsa_base64.txt create mode 100644 scripts/auto-organized/start.sh create mode 100644 scripts/auto-organized/verify_vg.ps1 create mode 100644 scripts/auto-organized/vw_full.json create mode 100644 scripts/auto-organized/wait_builds.ps1 create mode 100644 scripts/auto-organized/wait_builds2.ps1 create mode 100644 scripts/auto-organized/watch_approvals.ps1 create mode 100644 scripts/auto-organized/watch_approvals2.ps1 diff --git a/scripts/auto-organized/approve_mfe_pipelines.ps1 b/scripts/auto-organized/approve_mfe_pipelines.ps1 new file mode 100644 index 0000000..b21629b --- /dev/null +++ b/scripts/auto-organized/approve_mfe_pipelines.ps1 @@ -0,0 +1,38 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# 1. Listar aprovacoes pendentes +Write-Host "Buscando aprovacoes pendentes..." -ForegroundColor Cyan +$approvals = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h + +if ($approvals.count -eq 0) { + Write-Host "Nenhuma aprovacao pendente no momento." -ForegroundColor Yellow + exit 0 +} + +Write-Host "Encontradas $($approvals.count) aprovacao(oes) pendente(s):" -ForegroundColor Green +$approvals.value | ForEach-Object { + Write-Host " ID: $($_.id) | Pipeline: $($_.pipeline.name) | Stage: $($_.steps[0].actualApprover.displayName)" -ForegroundColor White +} + +# 2. Aprovar todas +Write-Host "" +Write-Host "Aprovando todas..." -ForegroundColor Cyan + +$items = @($approvals.value | ForEach-Object { + @{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' } +}) +$body = ConvertTo-Json -InputObject $items -Depth 5 + +$result = Invoke-RestMethod ` + -Uri "$base/pipelines/approvals?api-version=7.1-preview.1" ` + -Method PATCH -Headers $h -Body $body + +$result.value | ForEach-Object { + Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green +} + +Write-Host "" +Write-Host "Concluido." -ForegroundColor Green diff --git a/scripts/auto-organized/bs_inspect.json b/scripts/auto-organized/bs_inspect.json new file mode 100644 index 0000000000000000000000000000000000000000..1085e78a24250d0c7b400c7d1b177fd55dd51f6d GIT binary patch literal 31416 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 literal 0 HcmV?d00001 diff --git a/scripts/auto-organized/bs_labels.json b/scripts/auto-organized/bs_labels.json new file mode 100644 index 0000000000000000000000000000000000000000..c22c82bf5772ae9938666a615030941bce7b29be GIT binary patch literal 8360 zcmd6sTW=ai6vyYeQoqB>Pe~gVY~$-&`;atJQ>9I$C~7O0t4)o8a*5+u`RZ-|zd0Ue zmtBk@B#IEQJ3DhO|8tphX8-&5)_v=~amn3h$2Hx|^<3Yz-I;smI&SPHx*xiM+i|CU z){gsGBLmHQuV>7#d8wb5EUY?p6|H*b_S}I>-LC#qcciht*6z8wt`qm;oM%OR8*VD9 zwrW9eLb(cWBt}N_Pu^<{<r87wY$`=`$RrlQk zOfs}?=jeQtWL3=ow~jPPh1gUQ_Y31AJsGW#9y;e9CH&w_cO6l~ zi^lS*h|#)USElVyQl^r6=sg*%QtwAsl5!~SoxA&iN8nt(j%6n~k7&z-Te1t^hUPWp z*(dsR6@Oh(=!pKYJbPbHjy*!Vx@-C9WK~<9-&E{c1lRRn*BT;z&#&Cq^{(b|PqZB9 zYFG2QI@HWh(~BquadfZfe`7Z9 z!*a}6)(68=q1lj6F>6zud(y5U@5*Kgtl1E@pm{1j}r+KBMH?BhB8|m-RJ0J=8d>5A;3O6Zo={>$>K(H`WYfJHofC zPqf@qariXEMzYY*{Vm!p*&$N?Qqh;^Z_yc|u{m`9yoXIR zvaTLbkJ+N)Ib^fNjn8|V`sbpyA?sOAJQMGp>=CW-d3D`X3wErLP^Uh~M%p%NhfQV5 zTRtLKlxb5A%c?-?IjWkyC9xg-)9RRa-p0i9mCzf=lYbGCTt}(RPuj}XL}jQuixpkg z`%|C$2BJm&Bh!Qmk6nJ|>93-|>bxXH{MN4r%Ms7wl8=ib9+t!LyJZU*K6$LZswY_z%}i9;fKtcbQD-M}%O;u=vs2>UXw{{@ ziDscoPqI)ovZkw#F)Kbi+nMUgpKPYpz`U^`Td>{L&mYLpT3VxWSgaHLkE zlYF9k&QPZMr`NjH*mzF=jeDz3^|>T|>z-)_GJ=}P$Q8Pi!&wOuL4JHCbj!@oY6M1T zZgGPYXm0&}B3X#$)fy(^Xcj~+xB7Q)}i5-y;jEmkAe1|FkZYC#KUHf}FwZzv7_=?H4 z+}_N@Do8^2VS1R2!3H1T86FSP_Ppg~=1D~Esi%{r2Y1t$j29vfKF}%CjM@n=!#^w! zQZIv1N8V;nkS5q1Ip}OIHD;@bm#MFe7UT9>RIVj&Q~dK$ZhKsaWjtXU*>5@KF%vGz zXluyd_vL2JYC<1O4`iz@g#>2+Mg6v+ja2|-3%oYFi#&5L6&n@pbhiIt-M*q`8(i_Q zuILVA@qFD%Uw$NA>D=p@)6{)i*GKBji3|Gw6OD3)!wCTAr}z-Pdqba^p0bJ)9nJ@~ zC2jCvP>6Q^8l}zdEm6`%k1XHq%DwZ;cp`aZDi6z6sUerxi4*x?8}=mk^)pudyx3H= z16bu?9Ud{Z*w3wB^-!@=Rj@Kzx!iusPU|=0TJ}cezV{^z(jX}^ zEzY5aW!EDg(p|>8C}Ui|8r3itPPTipkHEROljJ3{+L1R5RDkUE(;QNPa+xPDx6Qgz zaQ2b+h@T`4nc$K8%X>a=u>y{q2M6n-;aGDXmqgn36)TH)kl; z!A4I3Ijn{)=^d~o=fsPd=izt+tMe{%{j;R9`o$t232szt+~;Xuo80AjCZZqm&DSRP z{V`RR7uG$8=N& mL-HV9ti1!Hr=>TsxFb6oEq+s $($updateResp.result.content) proxied=$($updateResp.result.proxied)" + } else { + Write-Host "ERRO: $($updateResp.errors | ConvertTo-Json)" + } +} else { + # Criar novo record + $body = @{ + type = "A" + name = $name + content = $fortiIP + ttl = 1 + proxied = $true + } | ConvertTo-Json -Depth 3 + + Write-Host "" + Write-Host "Criando A record $name -> $fortiIP (proxied)..." + $createResp = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records" ` + -Method POST -Headers $cfh -Body $body + if ($createResp.success) { + Write-Host "OK: $($createResp.result.type) $($createResp.result.name) -> $($createResp.result.content) proxied=$($createResp.result.proxied)" + } else { + Write-Host "ERRO: $($createResp.errors | ConvertTo-Json)" + } +} diff --git a/scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1 b/scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1 new file mode 100644 index 0000000..c26b057 --- /dev/null +++ b/scripts/auto-organized/fix_cf_dns_mfe_shell_oci.ps1 @@ -0,0 +1,44 @@ +$email = 'tiago.ribeiro@inventcloud.com.br' +$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186' +$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' } + +$zoneName = 'invista.com.br' +$recordName = 'mfe-shell-dev-oci.invista.com.br' +$gwHostname = 'bjlibdhd5wqhf7p3ua4pgv3zly.apigateway.sa-saopaulo-1.oci.customer-oci.com' + +# Buscar Zone ID +$zones = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones?name=$zoneName" -Headers $h +$zoneId = $zones.result[0].id +Write-Host "Zone ID: $zoneId" + +# Buscar todos os records existentes para o subdomain +$existing = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName" -Headers $h +Write-Host "Records existentes: $($existing.result.Count)" +$existing.result | ForEach-Object { Write-Host " $($_.type) $($_.name) -> $($_.content)" } + +# Deletar records existentes (A record → FortiGate) +foreach ($rec in $existing.result) { + Write-Host "Deletando $($rec.id)..." + $del = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$($rec.id)" ` + -Method DELETE -Headers $h + Write-Host " Deleted: $($del.success)" +} + +# Criar CNAME proxied → OCI API Gateway público +$payload = @{ + type = 'CNAME' + name = $recordName + content = $gwHostname + proxied = $true + ttl = 1 +} | ConvertTo-Json + +$result = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records" ` + -Method POST -Headers $h -Body $payload + +if ($result.success) { + Write-Host "DNS criado: $recordName -> $gwHostname (CNAME proxied)" +} else { + Write-Host "ERRO:" + $result | ConvertTo-Json | Write-Host +} diff --git a/scripts/auto-organized/fix_mfe_pipelines_oci.ps1 b/scripts/auto-organized/fix_mfe_pipelines_oci.ps1 new file mode 100644 index 0000000..32eb109 --- /dev/null +++ b/scripts/auto-organized/fix_mfe_pipelines_oci.ps1 @@ -0,0 +1,117 @@ +# fix_mfe_pipelines_oci.ps1 +# Atualiza azure-pipelines.yml na branch devops de cada MFE repo para usar +# o novo template deploy-mfe-oci.yaml (OCI Object Storage). +# +# Uso: ./fix_mfe_pipelines_oci.ps1 +# Requer: PAT com permissao Code (Read & Write) no Azure DevOps + +$pat = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$tok = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $pat)) +$h = @{ Authorization = 'Basic ' + $tok; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Configuracao dos MFEs: nome do repo -> parametros do template +$mfe_config = [ordered]@{ + 'mfe-shell' = @{ mfeName = 'mfe-shell'; isShell = $true } + 'mfe-auth' = @{ mfeName = 'mfe-auth'; isShell = $false } + 'mfe-user' = @{ mfeName = 'mfe-user'; isShell = $false } + 'mfe-person' = @{ mfeName = 'mfe-person'; isShell = $false } + 'mfe-poc' = @{ mfeName = 'mfe-poc'; isShell = $false } +} + +# Buscar todos os repos do projeto +Write-Host "Buscando repositorios..." -ForegroundColor Cyan +$repos = Invoke-RestMethod -Uri "$base/git/repositories?api-version=7.0" -Headers $h +$repo_map = @{} +foreach ($r in $repos.value) { + $repo_map[$r.name] = $r.id +} + +foreach ($mfe_name in $mfe_config.Keys) { + $cfg = $mfe_config[$mfe_name] + $repoId = $repo_map[$mfe_name] + $isShell = if ($cfg.isShell) { 'true' } else { 'false' } + + Write-Host "" + Write-Host "=== $mfe_name ===" -ForegroundColor Cyan + + if (-not $repoId) { + Write-Host " AVISO: repo '$mfe_name' nao encontrado no Azure DevOps. Pulando." -ForegroundColor Yellow + continue + } + Write-Host " Repo ID: $repoId" + + # 1. Verificar se branch devops existe + $ref = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/devops&api-version=7.0" -Headers $h + if ($ref.count -eq 0) { + Write-Host " AVISO: branch devops nao encontrada. Pulando." -ForegroundColor Yellow + continue + } + $oldSha = $ref.value[0].objectId + Write-Host " SHA devops: $oldSha" + + # 2. Verificar se azure-pipelines.yml existe na branch devops + $fileExists = $true + try { + $current = Invoke-RestMethod ` + -Uri "$base/git/repositories/$repoId/items?path=/azure-pipelines.yml&versionDescriptor.version=devops&api-version=7.0" ` + -Headers $h -ErrorAction Stop + } catch { + $fileExists = $false + Write-Host " azure-pipelines.yml nao existe na branch devops (sera criado)." + } + + # 3. Montar novo conteudo do pipeline + $newContent = @" +trigger: + branches: + include: + - devops + +resources: + repositories: + - repository: templates + type: git + name: azure-pipelines-templates + ref: refs/heads/main + +extends: + template: mfe/deploy-mfe-oci.yaml@templates + parameters: + mfeName: '$($cfg.mfeName)' + envName: 'dev' + isShell: $isShell +"@ + + # 4. Nao atualizar se conteudo identico + if ($fileExists -and $current -eq $newContent) { + Write-Host " Sem alteracoes necessarias." -ForegroundColor Yellow + continue + } + + # 5. Push para branch devops + $changeType = if ($fileExists) { 'edit' } else { 'add' } + $body = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "feat(pipeline): migrar $mfe_name para deploy OCI Object Storage via template" + changes = @(@{ + changeType = $changeType + item = @{ path = '/azure-pipelines.yml' } + newContent = @{ content = $newContent; contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + + try { + $result = Invoke-RestMethod ` + -Uri "$base/git/repositories/$repoId/pushes?api-version=7.0" ` + -Method POST -Headers $h -Body $body -ErrorAction Stop + Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green + } catch { + Write-Host " ERRO ao fazer push: $_" -ForegroundColor Red + } +} + +Write-Host "" +Write-Host "Concluido." -ForegroundColor Green diff --git a/scripts/auto-organized/fix_ms_pipelines.ps1 b/scripts/auto-organized/fix_ms_pipelines.ps1 new file mode 100644 index 0000000..02f9eee --- /dev/null +++ b/scripts/auto-organized/fix_ms_pipelines.ps1 @@ -0,0 +1,81 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$ms_repos = @{ + 'ms-auth-external' = '976a0237-6006-4dae-a084-f054c815d601' + 'ms-auth-sso' = '9932e1e0-48ab-417a-b712-36e3b618d758' + 'ms-barramento' = 'ce4eff9f-0d40-4e27-b210-8c18b87d03f0' + 'ms-belt' = 'f6223ed1-ab1e-47f9-8ec9-e0ca05c8feac' + 'ms-notify' = '76c0279c-55d7-4001-97ed-8d279f7baa07' + 'ms-parameters' = '4de79bf2-403b-4e60-ba36-87449ccbdc34' + 'ms-person' = '58f9c27e-9f46-4e4c-b1fb-1b2ff63e021b' + 'ms-poc' = '7e85222f-c166-4d52-8d37-3cf6ebeaeefa' + 'ms-user' = '24bdf218-522a-45e2-8a31-96db3962997d' +} + +foreach ($name in $ms_repos.Keys | Sort-Object) { + $id = $ms_repos[$name] + Write-Host "=== $name ===" -ForegroundColor Cyan + + # 1. Pegar commit atual do branch devops + try { + $ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h -ErrorAction Stop + $oldSha = $ref.value[0].objectId + Write-Host " SHA devops: $oldSha" + } catch { + Write-Host " ERRO: nao consegui pegar SHA do devops" -ForegroundColor Red + continue + } + + # 2. Pegar conteudo atual do pipeline + try { + $current = Invoke-RestMethod -Uri "$base/git/repositories/$id/items?path=/azure-pipelines.yaml&versionDescriptor.version=devops&api-version=7.0" -Headers $h -ErrorAction Stop + } catch { + Write-Host " ERRO: nao encontrei azure-pipelines.yaml" -ForegroundColor Red + continue + } + + # 3. Aplicar as correcoes + $newContent = $current + + # P1: Corrige template branch feature/cd-deploy-oci-oke -> main + $newContent = $newContent -replace 'refs/heads/feature/cd-deploy-oci-oke', 'refs/heads/main' + + # P2: ms-barramento especifico - corrige trigger e default + if ($name -eq 'ms-barramento') { + # Corrige condition de deploy: 'develop' -> 'devops' + $newContent = $newContent -replace "eq\(variables\['Build\.SourceBranchName'\], 'develop'\)", "eq(variables['Build.SourceBranchName'], 'devops')" + # Corrige default deployTarget: aws -> oci-argocd + $newContent = $newContent -replace "default: aws`n values: \[aws, oci-argocd\]", "default: oci-argocd`n values: [aws, oci-argocd]" + } + + if ($newContent -eq $current) { + Write-Host " Sem alteracoes necessarias." -ForegroundColor Yellow + continue + } + + # 4. Fazer push com o conteudo atualizado + $contentBytes = [System.Text.Encoding]::UTF8.GetBytes($newContent) + $contentB64 = [Convert]::ToBase64String($contentBytes) + + $body = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "fix(pipeline): atualiza template ref para main e corrige deploy target OCI" + changes = @(@{ + changeType = 'edit' + item = @{ path = '/azure-pipelines.yaml' } + newContent = @{ content = $newContent; contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + + try { + $result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop + Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green + } catch { + Write-Host " ERRO ao fazer push: $_" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg.ps1 b/scripts/auto-organized/fix_vg.ps1 new file mode 100644 index 0000000..a310137 --- /dev/null +++ b/scripts/auto-organized/fix_vg.ps1 @@ -0,0 +1,74 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform (ID 34) +# ===================================================================== +Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan + +$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' } +$vgId = $vg.id + +# Reconstruir o objeto de variaveis sem OCIR_REPOSITORY_NAME +$newVars = @{} +$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object { + $newVars[$_.Name] = $_.Value +} + +$updateBody = @{ + id = $vgId + name = $vg.name + type = $vg.type + variables = $newVars + description = $vg.description +} | ConvertTo-Json -Depth 10 + +try { + $result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop + $stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' } + if ($stillHas) { + Write-Host " AVISO: variavel ainda presente apos update" -ForegroundColor Yellow + } else { + Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green + } +} catch { + Write-Host " ERRO: $_" -ForegroundColor Red +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev (ID 34 nao existe, criar novo) +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existingMsParams) { + Write-Host " VG ms-parameters-dev ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow +} else { + # Pegar ms-notify-dev como modelo de estrutura + $modelo = $vgs.value | Where-Object { $_.name -eq 'ms-notify-dev' } + + $newVgBody = @{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = @{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + } | ConvertTo-Json -Depth 5 + + try { + $created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - VG criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + Write-Host " ERRO: $_" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg2.ps1 b/scripts/auto-organized/fix_vg2.ps1 new file mode 100644 index 0000000..031552c --- /dev/null +++ b/scripts/auto-organized/fix_vg2.ps1 @@ -0,0 +1,79 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h +$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' } +$vgId = $vg.id + +# Ver projectReferences do VG existente +Write-Host "projectReferences:" +$vg.projectReferences | ConvertTo-Json -Depth 5 + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform +# ===================================================================== +Write-Host "`n=== Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan + +$newVars = @{} +$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object { + $newVars[$_.Name] = $_.Value +} + +$updateBody = @{ + id = $vgId + name = $vg.name + type = $vg.type + variables = $newVars + description = $vg.description + projectReferences = $vg.projectReferences +} | ConvertTo-Json -Depth 10 + +try { + $result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop + $stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' } + if ($stillHas) { + Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green + } +} catch { + Write-Host " ERRO: $_" -ForegroundColor Red +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev +# ===================================================================== +Write-Host "`n=== Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existingMsParams) { + Write-Host " Ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow +} else { + # Usar o mesmo projectReferences do VG modelo + $modelo = $vgs.value | Where-Object { $_.name -eq 'ms-notify-dev' } + $modeloFull = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$($modelo.id)`?api-version=7.0" -Headers $h + + $newVgBody = @{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = @{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + projectReferences = $modeloFull.projectReferences + } | ConvertTo-Json -Depth 5 + + try { + $created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + Write-Host " ERRO: $_" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg3.ps1 b/scripts/auto-organized/fix_vg3.ps1 new file mode 100644 index 0000000..b81a1e6 --- /dev/null +++ b/scripts/auto-organized/fix_vg3.ps1 @@ -0,0 +1,91 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$baseOrg = 'https://dev.azure.com/CN-Squad/_apis' +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Pegar o ID do projeto +$proj = Invoke-RestMethod -Uri "$baseOrg/projects/Invista%20FIDC%20-%20Nexus?api-version=7.0" -Headers $h +Write-Host "Projeto: $($proj.name) | ID: $($proj.id)" + +$projectRef = @( + @{ + projectReference = @{ id = $proj.id; name = $proj.name } + name = 'oci-terraform' + } +) + +$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h +$vg = $vgs.value | Where-Object { $_.name -eq 'oci-terraform' } +$vgId = $vg.id + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME do VG oci-terraform +# ===================================================================== +Write-Host "`n=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan + +$newVars = @{} +$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object { + $newVars[$_.Name] = $_.Value +} + +$updateBody = @{ + id = $vgId + name = $vg.name + type = $vg.type + variables = $newVars + description = $vg.description + projectReferences = $projectRef +} | ConvertTo-Json -Depth 10 + +try { + $result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop + $stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' } + if ($stillHas) { + Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green + Write-Host " Variaveis restantes: $($result.variables.PSObject.Properties.Name -join ', ')" + } +} catch { + Write-Host " ERRO: $_" -ForegroundColor Red +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$existingMsParams = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existingMsParams) { + Write-Host " Ja existe (ID: $($existingMsParams.id))" -ForegroundColor Yellow +} else { + $msParamsRef = @( + @{ + projectReference = @{ id = $proj.id; name = $proj.name } + name = 'ms-parameters-dev' + } + ) + + $newVgBody = @{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = @{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + projectReferences = $msParamsRef + } | ConvertTo-Json -Depth 5 + + try { + $created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + Write-Host " ERRO: $_" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg4.ps1 b/scripts/auto-organized/fix_vg4.ps1 new file mode 100644 index 0000000..c983acd --- /dev/null +++ b/scripts/auto-organized/fix_vg4.ps1 @@ -0,0 +1,80 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$baseOrg = 'https://dev.azure.com/CN-Squad/_apis' +$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85' +$vgId = 34 + +# Ler VG atual completo +$wc = New-Object System.Net.WebClient +$wc.Headers['Authorization'] = 'Basic ' + $t +$raw = $wc.DownloadString("$baseOrg/distributedtask/variablegroups/$vgId`?api-version=7.0") +$vg = $raw | ConvertFrom-Json + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME via PUT no endpoint de organizacao +# ===================================================================== +Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan + +$newVars = @{} +$vg.variables.PSObject.Properties | Where-Object { $_.Name -ne 'OCIR_REPOSITORY_NAME' } | ForEach-Object { + $newVars[$_.Name] = $_.Value +} + +$updateBody = @{ + id = $vg.id + name = $vg.name + type = $vg.type + variables = $newVars + description = $vg.description +} | ConvertTo-Json -Depth 10 + +$url = "$baseOrg/distributedtask/variablegroups/$vgId`?projectIds=$projectId`&api-version=7.0" +try { + $hWithCT = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } + $result = Invoke-RestMethod -Uri $url -Method PUT -Headers $hWithCT -Body $updateBody -ErrorAction Stop + $stillHas = $result.variables.PSObject.Properties | Where-Object { $_.Name -eq 'OCIR_REPOSITORY_NAME' } + if ($stillHas) { + Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK - OCIR_REPOSITORY_NAME removido" -ForegroundColor Green + } +} catch { + $errMsg = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue + Write-Host " ERRO: $($errMsg.message)" -ForegroundColor Red +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev via endpoint de organizacao +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +# Verificar se ja existe +$allVgs = Invoke-RestMethod -Uri "$baseOrg/distributedtask/variablegroups?api-version=7.0" -Headers $h +$existing = $allVgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existing) { + Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow +} else { + $newVgBody = @{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = @{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + } | ConvertTo-Json -Depth 5 + + $createUrl = "$baseOrg/distributedtask/variablegroups?projectIds=$projectId`&api-version=7.0" + try { + $created = Invoke-RestMethod -Uri $createUrl -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + $errMsg = $_.ErrorDetails.Message | ConvertFrom-Json -ErrorAction SilentlyContinue + Write-Host " ERRO: $($errMsg.message)" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg5.ps1 b/scripts/auto-organized/fix_vg5.ps1 new file mode 100644 index 0000000..0f6f881 --- /dev/null +++ b/scripts/auto-organized/fix_vg5.ps1 @@ -0,0 +1,95 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' +$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85' +$vgId = 34 + +# Ler VG atual como string raw +$wc = New-Object System.Net.WebClient +$wc.Headers['Authorization'] = 'Basic ' + $t +$raw = $wc.DownloadString("$base/distributedtask/variablegroups/$vgId`?api-version=7.0") + +# Usar .NET JSON para remover a chave +Add-Type -AssemblyName System.Web.Extensions +$serializer = New-Object System.Web.Script.Serialization.JavaScriptSerializer +$serializer.MaxJsonLength = 10000000 + +$obj = $serializer.DeserializeObject($raw) + +# Remover OCIR_REPOSITORY_NAME das variaveis +if ($obj['variables'].ContainsKey('OCIR_REPOSITORY_NAME')) { + $obj['variables'].Remove('OCIR_REPOSITORY_NAME') + Write-Host " Chave OCIR_REPOSITORY_NAME removida do objeto" -ForegroundColor Green +} else { + Write-Host " OCIR_REPOSITORY_NAME nao encontrada" -ForegroundColor Yellow +} + +# Adicionar projectReferences obrigatorio +$projRef = New-Object System.Collections.Generic.Dictionary'[string,object]' +$projRef['name'] = 'oci-terraform' +$innerProj = New-Object System.Collections.Generic.Dictionary'[string,object]' +$innerProj['id'] = $projectId +$innerProj['name'] = 'Invista FIDC - Nexus' +$projRef['projectReference'] = $innerProj +$obj['projectReferences'] = @($projRef) + +$updatedJson = $serializer.Serialize($obj) + +Write-Host "=== 1. PUT oci-terraform sem OCIR_REPOSITORY_NAME ===" -ForegroundColor Cyan +try { + $result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updatedJson -ErrorAction Stop + $vars = $result.variables.PSObject.Properties.Name + if ('OCIR_REPOSITORY_NAME' -in $vars) { + Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK - removida. Variaveis: $($vars -join ', ')" -ForegroundColor Green + } +} catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO: $errMsg" -ForegroundColor Red + # Debug: mostrar os primeiros 300 chars do body + Write-Host " Body (300 chars): $($updatedJson.Substring(0, [Math]::Min(300, $updatedJson.Length)))" +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$vgs = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h +$existing = $vgs.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existing) { + Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow +} else { + $newProjRef = @( + @{ + name = 'ms-parameters-dev' + projectReference = @{ id = $projectId; name = 'Invista FIDC - Nexus' } + } + ) + $newVg = @{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = @{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + projectReferences = $newProjRef + } | ConvertTo-Json -Depth 6 + + try { + $created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVg -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO: $errMsg" -ForegroundColor Red + } +} diff --git a/scripts/auto-organized/fix_vg6.ps1 b/scripts/auto-organized/fix_vg6.ps1 new file mode 100644 index 0000000..23fd0df --- /dev/null +++ b/scripts/auto-organized/fix_vg6.ps1 @@ -0,0 +1,98 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' +$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85' +$vgId = 34 + +# GET VG por ID (nao pela lista) +$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Headers $h + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME +# ===================================================================== +Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan +Write-Host " Variaveis atuais: $($vg.variables.PSObject.Properties.Name -join ', ')" + +# Construir novo objeto de variaveis +$newVars = [ordered]@{} +foreach ($prop in $vg.variables.PSObject.Properties) { + if ($prop.Name -ne 'OCIR_REPOSITORY_NAME') { + # Preservar isSecret e value + $entry = @{} + if ($null -ne $prop.Value.isSecret -and $prop.Value.isSecret -eq $true) { + $entry['isSecret'] = $true + # Nao incluir value para secrets (o servidor mantem o valor) + } else { + $entry['isSecret'] = $false + $entry['value'] = if ($null -ne $prop.Value.value) { $prop.Value.value } else { '' } + } + $newVars[$prop.Name] = $entry + } +} +Write-Host " Variaveis novas ($($newVars.Count)): $($newVars.Keys -join ', ')" + +$updateBody = [ordered]@{ + id = $vg.id + name = $vg.name + type = $vg.type + description = $vg.description + variables = $newVars +} | ConvertTo-Json -Depth 8 + +try { + $result = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop + $vars = $result.variables.PSObject.Properties.Name + if ('OCIR_REPOSITORY_NAME' -in $vars) { + Write-Host " AVISO: variavel ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK - removida. Total: $($vars.Count) variaveis" -ForegroundColor Green + } +} catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO: $errMsg" -ForegroundColor Red +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$vgsCheck = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h +$existing = $vgsCheck.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existing) { + Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow +} else { + # Tentar criar sem projectReferences (endpoint de projeto ja tem contexto) + $newVgBody = [ordered]@{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = [ordered]@{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + projectReferences = @( + [ordered]@{ + name = 'ms-parameters-dev' + projectReference = [ordered]@{ id = $projectId } + } + ) + } | ConvertTo-Json -Depth 6 + + try { + $created = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id))" -ForegroundColor Green + } catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO: $errMsg" -ForegroundColor Red + Write-Host " Body enviado:" -ForegroundColor Gray + Write-Host $newVgBody + } +} diff --git a/scripts/auto-organized/fix_vg7.ps1 b/scripts/auto-organized/fix_vg7.ps1 new file mode 100644 index 0000000..ab0b4f6 --- /dev/null +++ b/scripts/auto-organized/fix_vg7.ps1 @@ -0,0 +1,93 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' +$projectId = '28c26924-b0a7-485d-b8c2-c86e48377e85' +$vgId = 34 + +$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/$vgId`?api-version=7.0" -Headers $h + +# ===================================================================== +# 1. Remover OCIR_REPOSITORY_NAME +# ===================================================================== +Write-Host "=== 1. Removendo OCIR_REPOSITORY_NAME do oci-terraform ===" -ForegroundColor Cyan + +$newVars = [ordered]@{} +foreach ($prop in $vg.variables.PSObject.Properties) { + if ($prop.Name -ne 'OCIR_REPOSITORY_NAME') { + $entry = @{} + if ($prop.Value.isSecret -eq $true) { + $entry['isSecret'] = $true + } else { + $entry['isSecret'] = $false + $entry['value'] = if ($null -ne $prop.Value.value) { [string]$prop.Value.value } else { '' } + } + $newVars[$prop.Name] = $entry + } +} + +# Tentar diferentes versoes da API +foreach ($apiVer in @('7.1-preview.2', '7.0', '6.0', '5.1-preview.1')) { + $updateBody = [ordered]@{ + id = [int]$vg.id + name = [string]$vg.name + type = [string]$vg.type + variables = $newVars + } | ConvertTo-Json -Depth 8 + + $url = "$base/distributedtask/variablegroups/$vgId`?api-version=$apiVer" + Write-Host " Tentando api-version=$apiVer ..." + try { + $result = Invoke-RestMethod -Uri $url -Method PUT -Headers $h -Body $updateBody -ErrorAction Stop + $vars = $result.variables.PSObject.Properties.Name + if ('OCIR_REPOSITORY_NAME' -in $vars) { + Write-Host " AVISO: ainda presente" -ForegroundColor Yellow + } else { + Write-Host " OK com api-version=$apiVer" -ForegroundColor Green + } + break + } catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO ($apiVer): $errMsg" -ForegroundColor Red + } +} + +# ===================================================================== +# 2. Criar VG ms-parameters-dev +# ===================================================================== +Write-Host "`n=== 2. Criando VG ms-parameters-dev ===" -ForegroundColor Cyan + +$vgsCheck = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups?api-version=7.0" -Headers $h +$existing = $vgsCheck.value | Where-Object { $_.name -eq 'ms-parameters-dev' } +if ($existing) { + Write-Host " Ja existe (ID: $($existing.id))" -ForegroundColor Yellow +} else { + foreach ($apiVer in @('7.1-preview.2', '7.0', '6.0', '5.1-preview.1')) { + $newVgBody = [ordered]@{ + name = 'ms-parameters-dev' + type = 'Vsts' + variables = [ordered]@{ + CLUSTER_NAME = @{ value = 'NexusCluster'; isSecret = $false } + LOG_GROUP_NAME = @{ value = '/ecs/logs'; isSecret = $false } + TASK_CONTAINER_NAME = @{ value = 'ms-parameters'; isSecret = $false } + TASK_FAMILY = @{ value = 'ms-parameters'; isSecret = $false } + TASK_EXECUTION_ROLE_ARN = @{ value = ''; isSecret = $true } + TASK_ROLE_ARN = @{ value = ''; isSecret = $true } + LAST_SWAGGER_HASH = @{ value = ''; isSecret = $false } + } + } | ConvertTo-Json -Depth 6 + + $url = "$base/distributedtask/variablegroups?api-version=$apiVer" + Write-Host " Tentando api-version=$apiVer ..." + try { + $created = Invoke-RestMethod -Uri $url -Method POST -Headers $h -Body $newVgBody -ErrorAction Stop + Write-Host " OK - criado: $($created.name) (ID: $($created.id)) com api-version=$apiVer" -ForegroundColor Green + break + } catch { + $errRaw = $_.ErrorDetails.Message + try { $errMsg = ($errRaw | ConvertFrom-Json).message } catch { $errMsg = $errRaw } + Write-Host " ERRO ($apiVer): $errMsg" -ForegroundColor Red + } + } +} diff --git a/scripts/auto-organized/forgejo_create_icatu.json b/scripts/auto-organized/forgejo_create_icatu.json new file mode 100644 index 0000000..b768627 --- /dev/null +++ b/scripts/auto-organized/forgejo_create_icatu.json @@ -0,0 +1 @@ +{"name":"icatu","private":true,"description":"Monorepo icatu"} \ No newline at end of file diff --git a/scripts/auto-organized/get_build_log.ps1 b/scripts/auto-organized/get_build_log.ps1 new file mode 100644 index 0000000..032be2a --- /dev/null +++ b/scripts/auto-organized/get_build_log.ps1 @@ -0,0 +1,38 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Buscar os 10 builds mais recentes do projeto (qualquer pipeline, branch devops) +$builds = Invoke-RestMethod -Uri "$base/build/builds?branchName=refs/heads/devops&`$top=10&api-version=7.0" -Headers $h +Write-Host "Builds recentes na branch devops:" +$builds.value | Select-Object id, + @{n='pipeline';e={$_.definition.name}}, + @{n='status';e={$_.status}}, + @{n='result';e={if($_.result){$_.result}else{'(running)'}}}, + @{n='queued';e={$_.queueTime}} | + Format-Table + +# Pegar o mais recente do mfe-shell +$shell = $builds.value | Where-Object { $_.definition.name -eq 'mfe-shell' } | Select-Object -First 1 +if ($shell) { + $buildId = $shell.id + Write-Host "=== mfe-shell build mais recente: $buildId ===" + if ($shell.validationResults) { + Write-Host "VALIDATION ERRORS:" + $shell.validationResults | ForEach-Object { Write-Host " [$($_.result)] $($_.message)" } + } + $tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h + if ($tl.records.Count -gt 0) { + $tl.records | Where-Object { $_.result -eq 'failed' } | + Select-Object type, name, result, errorCount | Format-Table + $failedStep = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1 + if ($failedStep -and $failedStep.log) { + Write-Host "LOG: $($failedStep.name)" + $logContent = Invoke-RestMethod -Uri "$($failedStep.log.url)?api-version=7.0" -Headers $h + $logContent -split "`n" | Select-Object -Last 40 | ForEach-Object { Write-Host $_ } + } + } else { + Write-Host "Timeline vazia." + } +} diff --git a/scripts/auto-organized/get_build_log2.ps1 b/scripts/auto-organized/get_build_log2.ps1 new file mode 100644 index 0000000..1ece3dd --- /dev/null +++ b/scripts/auto-organized/get_build_log2.ps1 @@ -0,0 +1,38 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Buscar os 10 builds mais recentes do projeto (qualquer pipeline, branch devops) +$builds = Invoke-RestMethod -Uri "$base/build/builds?branchName=refs/heads/devops&`$top=10&api-version=7.0" -Headers $h +Write-Host "Builds recentes na branch devops:" +$builds.value | Select-Object id, + @{n='pipeline';e={$_.definition.name}}, + @{n='status';e={$_.status}}, + @{n='result';e={if($_.result){$_.result}else{'(running)'}}}, + @{n='queued';e={$_.queueTime}} | + Format-Table + +# Pegar o mais recente do mfe-shell +$shell = $builds.value | Where-Object { $_.definition.name -eq 'mfe-shell' } | Select-Object -First 1 +if ($shell) { + $buildId = $shell.id + Write-Host "=== mfe-shell build mais recente: $buildId ===" + if ($shell.validationResults) { + Write-Host "VALIDATION ERRORS:" + $shell.validationResults | ForEach-Object { Write-Host " [$($_.result)] $($_.message)" } + } + $tl = Invoke-RestMethod -Uri "$base/build/builds/$buildId/timeline?api-version=7.0" -Headers $h + if ($tl.records.Count -gt 0) { + $tl.records | Where-Object { $_.result -eq 'failed' } | + Select-Object type, name, result, errorCount | Format-Table + $failedStep = $tl.records | Where-Object { $_.result -eq 'failed' -and $_.type -eq 'Task' } | Select-Object -First 1 + if ($failedStep -and $failedStep.log) { + Write-Host "LOG: $($failedStep.name)" + $logContent = Invoke-RestMethod -Uri "$($failedStep.log.url)?api-version=7.0" -Headers $h + $logContent -split "`n" | Select-Object -Last 40 | ForEach-Object { Write-Host $_ } + } + } else { + Write-Host "Timeline vazia." + } +} diff --git a/scripts/auto-organized/get_cf_records.ps1 b/scripts/auto-organized/get_cf_records.ps1 new file mode 100644 index 0000000..69284f8 --- /dev/null +++ b/scripts/auto-organized/get_cf_records.ps1 @@ -0,0 +1,13 @@ +$email = 'tiago.ribeiro@inventcloud.com.br' +$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186' +$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' } + +$zones = Invoke-RestMethod 'https://api.cloudflare.com/client/v4/zones?name=invista.com.br' -Headers $h +$zoneId = $zones.result[0].id +Write-Host "Zone ID: $zoneId" + +$records = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?per_page=100" -Headers $h +$records.result | Where-Object { $_.name -match 'crivo|mfe|shell|user' } | ForEach-Object { + $proxied = if ($_.proxied) { "PROX" } else { "NOPROX" } + Write-Host "$($_.type) $proxied $($_.name) -> $($_.content)" +} diff --git a/scripts/auto-organized/inspect_vg.ps1 b/scripts/auto-organized/inspect_vg.ps1 new file mode 100644 index 0000000..9d05774 --- /dev/null +++ b/scripts/auto-organized/inspect_vg.ps1 @@ -0,0 +1,23 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# GET raw JSON do VG 34 (oci-terraform) via WebClient para ver estrutura completa +$wc = New-Object System.Net.WebClient +$wc.Headers['Authorization'] = 'Basic ' + $t +$raw = $wc.DownloadString("$base/distributedtask/variablegroups/34?api-version=7.0") +$json = $raw | ConvertFrom-Json + +# Mostrar apenas a estrutura (sem os valores das variaveis) +Write-Host "=== Estrutura do VG ===" -ForegroundColor Cyan +Write-Host "id: $($json.id)" +Write-Host "name: $($json.name)" +Write-Host "type: $($json.type)" +Write-Host "projectReferences: $($json.projectReferences | ConvertTo-Json -Depth 5)" +Write-Host "variables (keys): $($json.variables.PSObject.Properties.Name -join ', ')" + +# Mostrar o JSON completo (sem valores secretos) +Write-Host "`n=== JSON completo (sem variaveis) ===" -ForegroundColor Cyan +$jsonClean = $json | Select-Object id, name, type, projectReferences, description +$jsonClean | ConvertTo-Json -Depth 5 diff --git a/scripts/auto-organized/lb_rules.json b/scripts/auto-organized/lb_rules.json new file mode 100644 index 0000000..5535e04 --- /dev/null +++ b/scripts/auto-organized/lb_rules.json @@ -0,0 +1,27 @@ +[ + { + "name": "crivo_dev_adm", + "condition": "all(http.request.headers[(i 'host')] eq (i 'crivo-dev-adm.invista.com.br'))", + "actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "Dev_Crivo_BS_84"}] + }, + { + "name": "crivo_dev", + "condition": "all(http.request.headers[(i 'host')] eq (i 'crivo-dev.invista.com.br'))", + "actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "Dev_Crivo_BS_80"}] + }, + { + "name": "mfe_user_dev", + "condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-user-dev.invista.com.br'))", + "actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-user-dev"}] + }, + { + "name": "mfe_shell_dev", + "condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-shell-dev.invista.com.br'))", + "actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-shell-dev"}] + }, + { + "name": "mfe_shell_dev_oci", + "condition": "all(http.request.headers[(i 'host')] eq (i 'mfe-shell-dev-oci.invista.com.br'))", + "actions": [{"name": "FORWARD_TO_BACKENDSET", "backendSetName": "bs-mfe-shell-dev-oci"}] + } +] diff --git a/scripts/auto-organized/merge_templates.ps1 b/scripts/auto-organized/merge_templates.ps1 new file mode 100644 index 0000000..0fab14b --- /dev/null +++ b/scripts/auto-organized/merge_templates.ps1 @@ -0,0 +1,66 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# 1. Achar o repo azure-pipelines-templates +$repos = Invoke-RestMethod -Uri "$base/git/repositories?api-version=7.0" -Headers $h +$repo = $repos.value | Where-Object { $_.name -eq 'azure-pipelines-templates' } + +if (-not $repo) { + Write-Host "ERRO: repo azure-pipelines-templates nao encontrado" -ForegroundColor Red + $repos.value | Select-Object name, id | Format-Table + exit 1 +} + +Write-Host "Repo: $($repo.name) - ID: $($repo.id)" -ForegroundColor Cyan +$repoId = $repo.id + +# 2. Pegar SHA da feature branch +$featureRef = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/feature/cd-deploy-oci-oke`&api-version=7.0" -Headers $h +if ($featureRef.count -eq 0) { + Write-Host "ERRO: branch feature/cd-deploy-oci-oke nao encontrada" -ForegroundColor Red + exit 1 +} +$featureSha = $featureRef.value[0].objectId +Write-Host " SHA feature: $featureSha" + +# 3. Pegar SHA do main +$mainRef = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/refs?filter=heads/main`&api-version=7.0" -Headers $h +if ($mainRef.count -eq 0) { + Write-Host "ERRO: branch main nao encontrada" -ForegroundColor Red + exit 1 +} +$mainSha = $mainRef.value[0].objectId +Write-Host " SHA main: $mainSha" + +# 4. Criar PR de feature/cd-deploy-oci-oke -> main +$prBody = @{ + title = 'chore: merge feature/cd-deploy-oci-oke into main' + description = 'Merge dos templates OCI/OKE para main' + sourceRefName = 'refs/heads/feature/cd-deploy-oci-oke' + targetRefName = 'refs/heads/main' + completionOptions = @{ + mergeStrategy = 'squash' + deleteSourceBranch = $false + } +} | ConvertTo-Json -Depth 5 + +Write-Host "Criando PR..." -ForegroundColor Cyan +$pr = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests?api-version=7.0" -Method POST -Headers $h -Body $prBody -ErrorAction Stop +$prId = $pr.pullRequestId +Write-Host " PR criado: #$prId" -ForegroundColor Green + +# 5. Completar o PR (merge) +$completeBody = @{ + status = 'completed' + lastMergeSourceCommit = @{ commitId = $featureSha } + completionOptions = @{ + mergeStrategy = 'squash' + deleteSourceBranch = $false + } +} | ConvertTo-Json -Depth 5 + +Write-Host " Completando PR #$prId..." -ForegroundColor Cyan +$result = Invoke-RestMethod -Uri "$base/git/repositories/$repoId/pullrequests/$prId`?api-version=7.0" -Method PATCH -Headers $h -Body $completeBody -ErrorAction Stop +Write-Host " Status: $($result.status)" -ForegroundColor Green diff --git a/scripts/auto-organized/mfe_shell_spa_spec.json b/scripts/auto-organized/mfe_shell_spa_spec.json new file mode 100644 index 0000000..e14a06b --- /dev/null +++ b/scripts/auto-organized/mfe_shell_spa_spec.json @@ -0,0 +1,40 @@ +{ + "routes": [ + { + "path": "/", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + }, + { + "path": "/{file}", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/${request.path[file]}", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + }, + { + "path": "/{path*}", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + } + ] +} diff --git a/scripts/auto-organized/mfe_shell_spec.json b/scripts/auto-organized/mfe_shell_spec.json new file mode 100644 index 0000000..e14a06b --- /dev/null +++ b/scripts/auto-organized/mfe_shell_spec.json @@ -0,0 +1,40 @@ +{ + "routes": [ + { + "path": "/", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + }, + { + "path": "/{file}", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/${request.path[file]}", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + }, + { + "path": "/{path*}", + "methods": ["GET"], + "backend": { + "type": "HTTP_BACKEND", + "url": "https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-shell-dev/o/index.html", + "connectTimeoutInSeconds": 10, + "readTimeoutInSeconds": 30, + "sendTimeoutInSeconds": 10, + "isSslVerifyDisabled": true + } + } + ] +} diff --git a/scripts/auto-organized/private_key.pem b/scripts/auto-organized/private_key.pem new file mode 100644 index 0000000..bb7dce1 --- /dev/null +++ b/scripts/auto-organized/private_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCc9suDobwJwCGJ +VFvga1BxKkmmGOxoF8zNibv6l33/SCFEBb5fFaenxvYotEGWUw0fed4zIcX3s6hA +q2yLr3nIygpLpcOfzpzPxas49P17NA3Chvo3k/0eGkBD6PHM1s62qPP+fKEZtwlS +q1WaFxfc949iqJAQvW6w/7WgMZDineq3IzhVVUAFdw3icZru97hCjPDU/v3eFTS7 +kvGrDYGAHZXzylu3Er9ifKYHdKxOrWFmGaSsPsYMdKNxWFk+Z38NVUnwSH3TEiV/ +S4e33tTkdMmNpY+6e9Cigb09RnOalj5lPjFGA9nTHMJxpsHvSKu8vMBr+OZ4CM3U +RH7MUX01AgMBAAECggEAMKxdFo/4MePY4m984B4W/0iYNv/iizLaKOBtoLsKcLeK +zT+ktXKPHzlUyvF+pyFQ3/JYA24VKAcXhRpDWhuLfcadI7Ee9PbKbKmEu3BJDEPr +gmd9vu9Ond+RDx30oUr5Je5FXySBhmpaYz7LGDHSDgzcc0EHD5HWed+JkEfegE7w +Mvt9KK41mGdaQwiPHS43uzZhQJEqybP3i/6SUnV2CntOhutxLlPk2rpHnns0p/St +Dvlcv61vduIaej4IFBrpSwTE45pvIfkvNZx0pJapM1jZhe8F/2T7GtXDkoFQveo1 +3YB1aadpCx7u28IzQTwBZVwqhCpi2a5+qVYUT0AU3wKBgQDYYUxQUBiUn6bXoAsx +JTozoX0K50cX2d8LVY1OUuhpRXbztS2XXtyfeoAQtEWoT3UO7vjEedWswfo2j+N3 +ZIXig7Vyj/LN5lZyCwWYn4S4inESjKlzi4Pv8D4F+Fkgg0WsVgzbTa4P7faHnDNn +eEHdyJ/ZQ8+XYxBpSAE8ecWQlwKBgQC5tGbfzh77REsv1h6b87vulrGHc+OBITTU +YFu1YfXpvbXx9geRfNLDtUhUis6vgfcQV6sxZVf78UdlqiTBebRLpcvoBlHV/MPZ +T3TsZH1vXwiitOsBIFzKkn8xdjuN6mN5lLjI6KkYeVoULYiUNbiZ+Wi7PXBPnc5I +jBO5EayOEwKBgQDU2pnso24avhatJKX92WYwphpQoISCBPPxvV38/3fbHtdOFBte +PZYAV8wlIoEnecpoP1J+TG+Su1r9U3xq1XsTAYd7w/kQ7RZ6pzcBFWLE+oMSwUZs +AIFwhb8ttklOv3PJfPi2vuqMhwUuD81NarI4jwQYASnz/SKGvqtgp1VezwKBgDoL +DOx+/GgE3ItDHaYY9HCKYUq5Ci7eNij7RS7YQ4ifZzMNdygeH7JUAxuJlzh8IsDU +5gk2Z92zeGFqYLqoU5YhaC5Ja2K68mwFzcHlVt9skMJqUdm0R8x5JZBMKCkfTaA+ +v9LsBY5Ev8b2xG2urNhTgEyl02jPJh6+yZtazthJAoGAHRIX/W0IlyaLno7WzAwM +lSsNfJpTvZmkri0UOGXM2YaKuQZ652t6EBDtfM7O16eV3KNBblt1LjItz/S8kiFi +Q8tGluO27Hn5/auixJjlcZnzoUXrEjAra8lmgAo41Dm0icDpLUzhixZ0qS8d6Yfp +RIT1IoWSuu2fvOOvqezq6bg= +-----END PRIVATE KEY----- diff --git a/scripts/auto-organized/remotes.txt b/scripts/auto-organized/remotes.txt new file mode 100644 index 0000000..c7cef7c --- /dev/null +++ b/scripts/auto-organized/remotes.txt @@ -0,0 +1,12 @@ +dokku dokku@localhost:gohorsejobs (fetch) +dokku dokku@localhost:gohorsejobs (push) +dokku-frontend dokku@localhost:gohorse-frontend (fetch) +dokku-frontend dokku@localhost:gohorse-frontend (push) +dokku-restore dokku@localhost:gohorse-frontend (fetch) +dokku-restore dokku@localhost:gohorse-frontend (push) +forgejo git@pipe.gohorsejobs.com:bohessefm/gohorsejobs.git (fetch) +forgejo git@pipe.gohorsejobs.com:bohessefm/gohorsejobs.git (push) +origin git@github.com:rede5/gohorsejobs.git (fetch) +origin git@github.com:rede5/gohorsejobs.git (push) +pipe https://pipe.gohorsejobs.com/bohessefm/gohorsejobs.git (fetch) +pipe https://pipe.gohorsejobs.com/bohessefm/gohorsejobs.git (push) diff --git a/scripts/auto-organized/retrigger_mfe_pipelines.ps1 b/scripts/auto-organized/retrigger_mfe_pipelines.ps1 new file mode 100644 index 0000000..80b4e45 --- /dev/null +++ b/scripts/auto-organized/retrigger_mfe_pipelines.ps1 @@ -0,0 +1,60 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$mfe_repos = [ordered]@{ + 'mfe-shell' = '9f652079-76d7-4415-8c26-e40fdbcb6120' + 'mfe-auth' = '23a19757-99e8-41c1-8b2c-a4921fe3795c' + 'mfe-user' = '2eea9c4e-195e-4fb6-ae0b-2da1a560bcdc' + 'mfe-person' = '8580c8ba-57ab-40bd-9bc0-e967b40a4f39' + 'mfe-poc' = '2090316d-09cc-4379-b821-85c874006e0a' +} + +foreach ($name in $mfe_repos.Keys) { + $id = $mfe_repos[$name] + Write-Host "=== $name ===" -ForegroundColor Cyan + + $ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h + $oldSha = $ref.value[0].objectId + + # Faz um commit no .trigger para re-disparar a pipeline + $body = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "ci: re-trigger pipeline apos correcao do template" + changes = @(@{ + changeType = 'add' + item = @{ path = '/.trigger' } + newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + + try { + $result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop + Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green + } catch { + # Arquivo .trigger pode ja existir — tentar com edit + $body2 = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "ci: re-trigger pipeline apos correcao do template" + changes = @(@{ + changeType = 'edit' + item = @{ path = '/.trigger' } + newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + try { + $result2 = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body2 -ErrorAction Stop + Write-Host " OK (edit) - commit: $($result2.commits[0].commitId)" -ForegroundColor Green + } catch { + Write-Host " ERRO: $_" -ForegroundColor Red + } + } +} + +Write-Host "" +Write-Host "Pipelines re-disparadas. Monitorando aprovacoes por 3 min..." -ForegroundColor Cyan diff --git a/scripts/auto-organized/retrigger_mfe_pipelines2.ps1 b/scripts/auto-organized/retrigger_mfe_pipelines2.ps1 new file mode 100644 index 0000000..61f4089 --- /dev/null +++ b/scripts/auto-organized/retrigger_mfe_pipelines2.ps1 @@ -0,0 +1,60 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$mfe_repos = [ordered]@{ + 'mfe-shell' = '9f652079-76d7-4415-8c26-e40fdbcb6120' + 'mfe-auth' = '23a19757-99e8-41c1-8b2c-a4921fe3795c' + 'mfe-user' = '2eea9c4e-195e-4fb6-ae0b-2da1a560bcdc' + 'mfe-person' = '8580c8ba-57ab-40bd-9bc0-e967b40a4f39' + 'mfe-poc' = '2090316d-09cc-4379-b821-85c874006e0a' +} + +foreach ($name in $mfe_repos.Keys) { + $id = $mfe_repos[$name] + Write-Host "=== $name ===" -ForegroundColor Cyan + + $ref = Invoke-RestMethod -Uri "$base/git/repositories/$id/refs?filter=heads/devops&api-version=7.0" -Headers $h + $oldSha = $ref.value[0].objectId + + # Faz um commit no .trigger para re-disparar a pipeline + $body = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "ci: re-trigger pipeline apos correcao do template" + changes = @(@{ + changeType = 'add' + item = @{ path = '/.trigger' } + newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + + try { + $result = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body -ErrorAction Stop + Write-Host " OK - commit: $($result.commits[0].commitId)" -ForegroundColor Green + } catch { + # Arquivo .trigger pode ja existir — tentar com edit + $body2 = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $oldSha }) + commits = @(@{ + comment = "ci: re-trigger pipeline apos correcao do template" + changes = @(@{ + changeType = 'edit' + item = @{ path = '/.trigger' } + newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' } + }) + }) + } | ConvertTo-Json -Depth 10 + try { + $result2 = Invoke-RestMethod -Uri "$base/git/repositories/$id/pushes?api-version=7.0" -Method POST -Headers $h -Body $body2 -ErrorAction Stop + Write-Host " OK (edit) - commit: $($result2.commits[0].commitId)" -ForegroundColor Green + } catch { + Write-Host " ERRO: $_" -ForegroundColor Red + } + } +} + +Write-Host "" +Write-Host "Pipelines re-disparadas. Monitorando aprovacoes por 3 min..." -ForegroundColor Cyan diff --git a/scripts/auto-organized/retrigger_mfe_shell.ps1 b/scripts/auto-organized/retrigger_mfe_shell.ps1 new file mode 100644 index 0000000..7466bed --- /dev/null +++ b/scripts/auto-organized/retrigger_mfe_shell.ps1 @@ -0,0 +1,42 @@ +$auth = Get-Content "$env:USERPROFILE\.ssh\azure_devops_auth.json" -Raw | ConvertFrom-Json +$PAT = $auth.pat +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$PAT")) +$h = @{ Authorization = "Basic $t"; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Buscar repo mfe-shell +$repos = Invoke-RestMethod "$base/git/repositories?api-version=7.0" -Headers $h +$repo = $repos.value | Where-Object { $_.name -eq 'mfe-shell' } | Select-Object -First 1 +if (-not $repo) { Write-Host "ERRO: repo mfe-shell nao encontrado"; exit 1 } + +$repoId = $repo.id +Write-Host "Repo: $($repo.name) id=$repoId" + +# Buscar branch devops +$branch = Invoke-RestMethod "$base/git/repositories/$repoId/refs?filter=heads/devops&api-version=7.0" -Headers $h +$sha = $branch.value[0].objectId +Write-Host "Branch devops: $sha" + +# Verificar se .trigger-dns existe para usar edit ou add +$items = Invoke-RestMethod "$base/git/repositories/$repoId/items?path=/.trigger-dns&versionDescriptor.versionType=branch&versionDescriptor.version=devops&api-version=7.0" -Headers $h -ErrorAction SilentlyContinue +$changeType = if ($items -and $items.value) { 'edit' } else { 'add' } +Write-Host "Usando changeType: $changeType" + +# Push trigger commit +$body = @{ + refUpdates = @(@{ name = 'refs/heads/devops'; oldObjectId = $sha }) + commits = @(@{ + comment = 'chore: retrigger mfe-shell pipeline (dns oci subdomain)' + changes = @(@{ + changeType = 'edit' + item = @{ path = '/.trigger-dns' } + newContent = @{ content = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'); contentType = 'rawtext' } + }) + }) +} | ConvertTo-Json -Depth 6 + +$push = Invoke-RestMethod "$base/git/repositories/$repoId/pushes?api-version=7.0" ` + -Method POST -Headers $h -Body $body + +Write-Host "Push ID: $($push.pushId) commit: $($push.commits[0].commitId)" +Write-Host "Pipeline sera triggerada automaticamente." diff --git a/scripts/auto-organized/revert_cf_mfe_shell_dev.ps1 b/scripts/auto-organized/revert_cf_mfe_shell_dev.ps1 new file mode 100644 index 0000000..0edb899 --- /dev/null +++ b/scripts/auto-organized/revert_cf_mfe_shell_dev.ps1 @@ -0,0 +1,24 @@ +$email = 'tiago.ribeiro@inventcloud.com.br' +$key = '7ae5565ab2dcdfdfdd66efb1105e27d18d186' +$h = @{ 'X-Auth-Email' = $email; 'X-Auth-Key' = $key; 'Content-Type' = 'application/json' } + +$zoneId = '62cb52dc520cf3be1a685099c1e3887d' +$recordName = 'mfe-shell-dev.invista.com.br' + +# Buscar records existentes +$existing = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records?name=$recordName" -Headers $h +Write-Host "Records para $recordName`: $($existing.result.Count)" +$existing.result | ForEach-Object { Write-Host " $($_.id) $($_.type) -> $($_.content)" } + +# Deletar o A record que criamos (136.248.66.216 = FortiGate) +foreach ($rec in $existing.result) { + if ($rec.content -eq '136.248.66.216') { + Write-Host "Deletando A record -> 136.248.66.216..." + $del = Invoke-RestMethod "https://api.cloudflare.com/client/v4/zones/$zoneId/dns_records/$($rec.id)" ` + -Method DELETE -Headers $h + Write-Host "Deleted: $($del.success)" + } else { + Write-Host "Mantendo record: $($_.type) -> $($rec.content)" + } +} +Write-Host "Concluido. mfe-shell-dev.invista.com.br revertido." diff --git a/scripts/auto-organized/rsa_base64.txt b/scripts/auto-organized/rsa_base64.txt new file mode 100644 index 0000000..5bb0e10 --- /dev/null +++ b/scripts/auto-organized/rsa_base64.txt @@ -0,0 +1 @@ +LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktjd2dnU2pBZ0VBQW9JQkFRQ2M5c3VEb2J3SndDR0oKVkZ2Z2ExQnhLa21tR094b0Y4ek5pYnY2bDMzL1NDRkVCYjVmRmFlbnh2WW90RUdXVXcwZmVkNHpJY1gzczZoQQpxMnlMcjNuSXlncExwY09menB6UHhhczQ5UDE3TkEzQ2h2bzNrLzBlR2tCRDZQSE0xczYycVBQK2ZLRVp0d2xTCnExV2FGeGZjOTQ5aXFKQVF2VzZ3LzdXZ01aRGluZXEzSXpoVlZVQUZkdzNpY1pydTk3aENqUERVL3YzZUZUUzcKa3ZHckRZR0FIWlh6eWx1M0VyOWlmS1lIZEt4T3JXRm1HYVNzUHNZTWRLTnhXRmsrWjM4TlZVbndTSDNURWlWLwpTNGUzM3RUa2RNbU5wWSs2ZTlDaWdiMDlSbk9hbGo1bFBqRkdBOW5USE1KeHBzSHZTS3U4dk1CcitPWjRDTTNVClJIN01VWDAxQWdNQkFBRUNnZ0VBTUt4ZEZvLzRNZVBZNG05ODRCNFcvMGlZTnYvaWl6TGFLT0J0b0xzS2NMZUsKelQra3RYS1BIemxVeXZGK3B5RlEzL0pZQTI0VktBY1hoUnBEV2h1TGZjYWRJN0VlOVBiS2JLbUV1M0JKREVQcgpnbWQ5dnU5T25kK1JEeDMwb1VyNUplNUZYeVNCaG1wYVl6N0xHREhTRGd6Y2MwRUhENUhXZWQrSmtFZmVnRTd3Ck12dDlLSzQxbUdkYVF3aVBIUzQzdXpaaFFKRXF5YlAzaS82U1VuVjJDbnRPaHV0eExsUGsycnBIbm5zMHAvU3QKRHZsY3Y2MXZkdUlhZWo0SUZCcnBTd1RFNDVwdklma3ZOWngwcEphcE0xalpoZThGLzJUN0d0WERrb0ZRdmVvMQozWUIxYWFkcEN4N3UyOEl6UVR3QlpWd3FoQ3BpMmE1K3FWWVVUMEFVM3dLQmdRRFlZVXhRVUJpVW42YlhvQXN4CkpUb3pvWDBLNTBjWDJkOExWWTFPVXVocFJYYnp0UzJYWHR5ZmVvQVF0RVdvVDNVTzd2akVlZFdzd2ZvMmorTjMKWklYaWc3VnlqL0xONWxaeUN3V1luNFM0aW5FU2pLbHppNFB2OEQ0RitGa2dnMFdzVmd6YlRhNFA3ZmFIbkRObgplRUhkeUovWlE4K1hZeEJwU0FFOGVjV1Fsd0tCZ1FDNXRHYmZ6aDc3UkVzdjFoNmI4N3Z1bHJHSGMrT0JJVFRVCllGdTFZZlhwdmJYeDlnZVJmTkxEdFVoVWlzNnZnZmNRVjZzeFpWZjc4VWRscWlUQmViUkxwY3ZvQmxIVi9NUFoKVDNUc1pIMXZYd2lpdE9zQklGektrbjh4ZGp1TjZtTjVsTGpJNktrWWVWb1VMWWlVTmJpWitXaTdQWEJQbmM1SQpqQk81RWF5T0V3S0JnUURVMnBuc28yNGF2aGF0SktYOTJXWXdwaHBRb0lTQ0JQUHh2VjM4LzNmYkh0ZE9GQnRlClBaWUFWOHdsSW9FbmVjcG9QMUorVEcrU3UxcjlVM3hxMVhzVEFZZDd3L2tRN1JaNnB6Y0JGV0xFK29NU3dVWnMKQUlGd2hiOHR0a2xPdjNQSmZQaTJ2dXFNaHdVdUQ4MU5hckk0andRWUFTbnovU0tHdnF0Z3AxVmV6d0tCZ0RvTApET3grL0dnRTNJdERIYVlZOUhDS1lVcTVDaTdlTmlqN1JTN1lRNGlmWnpNTmR5Z2VIN0pVQXh1Smx6aDhJc0RVCjVnazJaOTJ6ZUdGcVlMcW9VNVloYUM1SmEySzY4bXdGemNIbFZ0OXNrTUpxVWRtMFI4eDVKWkJNS0NrZlRhQSsKdjlMc0JZNUV2OGIyeEcydXJOaFRnRXlsMDJqUEpoNit5WnRhenRoSkFvR0FIUklYL1cwSWx5YUxubzdXekF3TQpsU3NOZkpwVHZabWtyaTBVT0dYTTJZYUt1UVo2NTJ0NkVCRHRmTTdPMTZlVjNLTkJibHQxTGpJdHovUzhraUZpClE4dEdsdU8yN0huNS9hdWl4SmpsY1puem9VWHJFakFyYThsbWdBbzQxRG0waWNEcExVemhpeFowcVM4ZDZZZnAKUklUMUlvV1N1dTJmdk9PdnFlenE2Ymc9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K \ No newline at end of file diff --git a/scripts/auto-organized/start.sh b/scripts/auto-organized/start.sh new file mode 100644 index 0000000..30b1b92 --- /dev/null +++ b/scripts/auto-organized/start.sh @@ -0,0 +1,341 @@ +#!/bin/bash + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Function to kill background processes on exit +cleanup() { + echo -e "\n${YELLOW}🛑 Stopping services...${NC}" + kill $(jobs -p) 2>/dev/null + exit +} + +trap cleanup SIGINT SIGTERM + +# Header +clear +echo -e "${CYAN}" +echo "╔══════════════════════════════════════════════╗" +echo "║ 🐴 GoHorse Jobs - Dev Server ║" +echo "╚══════════════════════════════════════════════╝" +echo -e "${NC}" + +# Interactive menu +echo -e "${GREEN}Select an option:${NC}\n" +echo -e " ${CYAN}── Services ──${NC}" +echo -e " ${YELLOW}1)${NC} 🚀 Start (Frontend + Backend)" +echo -e " ${YELLOW}2)${NC} 🌱 Start with Seed (Reset DB + Seed + Start)" +echo -e " ${YELLOW}3)${NC} 📦 Start All (Frontend + Backend + Backoffice)" +echo -e "" +echo -e " ${CYAN}── Database ──${NC}" +echo -e " ${YELLOW}4)${NC} 🗄️ Run Migrations" +echo -e " ${YELLOW}5)${NC} 🌿 Seed Only (append data)" +echo -e " ${YELLOW}6)${NC} 🔄 Seed Reset (drop all + seed fresh)" +echo -e "" +echo -e " ${CYAN}── Testing ──${NC}" +echo -e " ${YELLOW}7)${NC} 🧪 Run Tests (Backend E2E)" +echo -e " ${YELLOW}0)${NC} ❌ Exit" +echo -e "" +echo -e " ${CYAN}── Fast Options ──${NC}" +echo -e " ${YELLOW}8)${NC} ⚡ Seed Reset LITE (skip 153k cities)" +echo -e " ${YELLOW}9)${NC} 🔬 Run All Tests (Backend + Frontend)" +echo -e "" +echo -e " ${CYAN}── Docker/Deploy ──${NC}" +echo -e " ${YELLOW}a)${NC} 🐳 Build Docker Images" +echo -e " ${YELLOW}b)${NC} 🚀 Build & Push to Forgejo" +echo "" +read -p "Enter option [0-9,a,b]: " choice + +case $choice in + 1) + echo -e "\n${GREEN}🚀 Starting Development Environment...${NC}\n" + + # Backend + echo -e "${BLUE}🔹 Checking Backend...${NC}" + cd backend && go mod tidy + if command -v swag &> /dev/null; then + echo -e "${BLUE}🔹 Generating Swagger Docs...${NC}" + swag init -g cmd/api/main.go --parseDependency --parseInternal 2>/dev/null + fi + cd .. + + # Frontend deps + if [ ! -d "frontend/node_modules" ]; then + echo -e "${BLUE}🔹 Installing Frontend Dependencies...${NC}" + cd frontend && npm install && cd .. + fi + + # Start services + echo -e "${BLUE}🔹 Starting Backend on port 8521...${NC}" + (cd backend && go run cmd/api/main.go) & + BACKEND_PID=$! + sleep 2 + + echo -e "${BLUE}🔹 Starting Frontend on port 8963...${NC}" + (cd frontend && npm run dev -- -p 8963) & + FRONTEND_PID=$! + + echo -e "\n${GREEN}✅ Services running:${NC}" + echo -e " ${CYAN}Backend:${NC} http://localhost:8521" + echo -e " ${CYAN}Frontend:${NC} http://localhost:8963" + echo -e " ${CYAN}Swagger:${NC} http://localhost:8521/swagger/index.html" + echo "" + + wait $BACKEND_PID $FRONTEND_PID + ;; + + 2) + echo -e "\n${GREEN}🌱 Starting with Database Reset & Seed...${NC}\n" + + # Backend prep + echo -e "${BLUE}🔹 Checking Backend...${NC}" + cd backend && go mod tidy + if command -v swag &> /dev/null; then + swag init -g cmd/api/main.go --parseDependency --parseInternal 2>/dev/null + fi + cd .. + + # Seeder deps + cd seeder-api + if [ ! -d "node_modules" ]; then + echo -e "${BLUE}🔹 Installing Seeder Dependencies...${NC}" + npm install + fi + + echo -e "${YELLOW}🔹 Resetting Database...${NC}" + npm run seed:reset + cd .. + + # Start backend + echo -e "${BLUE}🔹 Starting Backend...${NC}" + (cd backend && go run cmd/api/main.go) & + BACKEND_PID=$! + + echo -e "${YELLOW}⏳ Waiting for Backend...${NC}" + sleep 5 + + # Seed + echo -e "${BLUE}🔹 Seeding Database (30 companies, 990 jobs)...${NC}" + cd seeder-api && npm run seed && cd .. + + # Frontend + if [ ! -d "frontend/node_modules" ]; then + cd frontend && npm install && cd .. + fi + + echo -e "${BLUE}🔹 Starting Frontend...${NC}" + (cd frontend && npm run dev -- -p 8963) & + FRONTEND_PID=$! + + echo -e "\n${GREEN}✅ Services running with fresh data!${NC}" + echo -e " ${CYAN}Backend:${NC} http://localhost:8521" + echo -e " ${CYAN}Frontend:${NC} http://localhost:8963" + echo "" + + wait $BACKEND_PID $FRONTEND_PID + ;; + + 3) + echo -e "\n${GREEN}📦 Starting All Services (Including Backoffice)...${NC}\n" + + # Backend + cd backend && go mod tidy && cd .. + + # Dependencies + [ ! -d "frontend/node_modules" ] && (cd frontend && npm install && cd ..) + [ ! -d "backoffice/node_modules" ] && (cd backoffice && npm install && cd ..) + + echo -e "${BLUE}🔹 Starting Backend on port 8521...${NC}" + (cd backend && go run cmd/api/main.go) & + sleep 2 + + echo -e "${BLUE}🔹 Starting Frontend on port 8963...${NC}" + (cd frontend && npm run dev -- -p 8963) & + + echo -e "${BLUE}🔹 Starting Backoffice on port 3001...${NC}" + (cd backoffice && npm run start:dev) & + + echo -e "\n${GREEN}✅ All services running:${NC}" + echo -e " ${CYAN}Backend:${NC} http://localhost:8521" + echo -e " ${CYAN}Frontend:${NC} http://localhost:8963" + echo -e " ${CYAN}Backoffice:${NC} http://localhost:3001" + echo -e " ${CYAN}Swagger:${NC} http://localhost:3001/api/docs" + echo "" + + wait + ;; + + 4) + echo -e "\n${GREEN}🗄️ Running Migrations...${NC}\n" + cd seeder-api + [ ! -d "node_modules" ] && npm install + npm run migrate + ;; + + 5) + echo -e "\n${GREEN}🌿 Seeding Database Only...${NC}\n" + cd seeder-api + [ ! -d "node_modules" ] && npm install + npm run seed + echo -e "\n${GREEN}✅ Seeding completed!${NC}" + ;; + + 6) + echo -e "\n${GREEN}🔄 Resetting Database & Seeding Fresh...${NC}\n" + cd seeder-api + [ ! -d "node_modules" ] && npm install + + echo -e "${YELLOW}⚠️ This will DROP all tables and recreate!${NC}" + read -p "Are you sure? [y/N]: " confirm + + if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then + echo -e "\n${BLUE}🔹 Step 1/3: Dropping all tables...${NC}" + npm run seed:reset + + echo -e "\n${BLUE}🔹 Step 2/3: Running migrations...${NC}" + npm run migrate + + echo -e "\n${BLUE}🔹 Step 3/3: Seeding data...${NC}" + npm run seed + + echo -e "\n${GREEN}✅ Database fully reset and seeded!${NC}" + else + echo -e "${YELLOW}Cancelled.${NC}" + fi + ;; + + 7) + echo -e "\n${GREEN}🧪 Running Backend E2E Tests...${NC}\n" + cd backend && go test -tags=e2e -v ./tests/e2e/... 2>&1 + echo -e "\n${GREEN}✅ Tests completed!${NC}" + ;; + + 8) + echo -e "\n${GREEN}⚡ Fast Reset - Seed LITE (no cities)...${NC}\n" + cd seeder-api + [ ! -d "node_modules" ] && npm install + + echo -e "${YELLOW}⚠️ This will DROP all tables and recreate (WITHOUT 153k cities)${NC}" + read -p "Are you sure? [y/N]: " confirm + + if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then + echo -e "\n${BLUE}🔹 Step 1/3: Dropping all tables...${NC}" + npm run seed:reset + + echo -e "\n${BLUE}🔹 Step 2/3: Running migrations...${NC}" + npm run migrate + + echo -e "\n${BLUE}🔹 Step 3/3: Seeding data (LITE - no cities)...${NC}" + npm run seed:lite + + echo -e "\n${GREEN}✅ Database reset (LITE) completed! Cities skipped for speed.${NC}" + else + echo -e "${YELLOW}Cancelled.${NC}" + fi + ;; + + 9) + echo -e "\n${GREEN}🔬 Running All Tests...${NC}\n" + + echo -e "${BLUE}🔹 Backend Unit Tests...${NC}" + cd backend && go test -v ./... -count=1 2>&1 | tail -20 + BACKEND_RESULT=$? + cd .. + + echo -e "\n${BLUE}🔹 Backend E2E Tests...${NC}" + cd backend && go test -tags=e2e -v ./tests/e2e/... 2>&1 + E2E_RESULT=$? + cd .. + + if [ -d "frontend/node_modules" ]; then + echo -e "\n${BLUE}🔹 Frontend Tests...${NC}" + cd frontend && npm test -- --passWithNoTests 2>&1 + FRONTEND_RESULT=$? + cd .. + else + echo -e "${YELLOW}⚠️ Frontend node_modules not found, skipping frontend tests${NC}" + FRONTEND_RESULT=0 + fi + + echo -e "\n${GREEN}═══════════════════════════════════════${NC}" + if [ $BACKEND_RESULT -eq 0 ] && [ $E2E_RESULT -eq 0 ] && [ $FRONTEND_RESULT -eq 0 ]; then + echo -e "${GREEN}✅ All tests passed!${NC}" + else + echo -e "${RED}❌ Some tests failed${NC}" + fi + ;; + + 0) + echo -e "${YELLOW}Bye! 👋${NC}" + exit 0 + ;; + + *) + echo -e "${RED}Invalid option. Exiting.${NC}" + exit 1 + ;; + + a) + echo -e "\n${GREEN}🐳 Building Docker Images...${NC}\n" + + REGISTRY="forgejo-gru.rede5.com.br/rede5" + + echo -e "${BLUE}🔹 Building Backend...${NC}" + podman build -t $REGISTRY/gohorsejobs-backend:latest -f backend/Dockerfile backend/ + + echo -e "\n${BLUE}🔹 Building Frontend...${NC}" + podman build -t $REGISTRY/gohorsejobs-frontend:latest -f frontend/Dockerfile frontend/ + + echo -e "\n${BLUE}🔹 Building Seeder...${NC}" + podman build -t $REGISTRY/gohorsejobs-seeder:latest -f seeder-api/Dockerfile seeder-api/ + + echo -e "\n${GREEN}✅ All images built successfully!${NC}" + echo -e " ${CYAN}Backend:${NC} $REGISTRY/gohorsejobs-backend:latest" + echo -e " ${CYAN}Frontend:${NC} $REGISTRY/gohorsejobs-frontend:latest" + echo -e " ${CYAN}Seeder:${NC} $REGISTRY/gohorsejobs-seeder:latest" + ;; + + b) + echo -e "\n${GREEN}🚀 Building & Pushing to Forgejo Registry...${NC}\n" + + REGISTRY="forgejo-gru.rede5.com.br/rede5" + + # Check if logged in + echo -e "${BLUE}🔹 Checking registry login...${NC}" + if ! podman login --get-login $REGISTRY 2>/dev/null; then + echo -e "${YELLOW}⚠️ Not logged in. Please enter your credentials:${NC}" + read -p "Username: " REGISTRY_USER + read -s -p "Password/Token: " REGISTRY_PASS + echo "" + podman login forgejo-gru.rede5.com.br -u "$REGISTRY_USER" -p "$REGISTRY_PASS" + fi + + echo -e "\n${BLUE}🔹 Building Backend...${NC}" + podman build -t $REGISTRY/gohorsejobs-backend:latest -f backend/Dockerfile backend/ + + echo -e "\n${BLUE}🔹 Building Frontend...${NC}" + podman build -t $REGISTRY/gohorsejobs-frontend:latest -f frontend/Dockerfile frontend/ + + echo -e "\n${BLUE}🔹 Building Seeder...${NC}" + podman build -t $REGISTRY/gohorsejobs-seeder:latest -f seeder-api/Dockerfile seeder-api/ + + echo -e "\n${BLUE}🔹 Pushing Backend...${NC}" + podman push $REGISTRY/gohorsejobs-backend:latest + + echo -e "\n${BLUE}🔹 Pushing Frontend...${NC}" + podman push $REGISTRY/gohorsejobs-frontend:latest + + echo -e "\n${BLUE}🔹 Pushing Seeder...${NC}" + podman push $REGISTRY/gohorsejobs-seeder:latest + + echo -e "\n${GREEN}✅ All images built and pushed!${NC}" + echo -e " ${CYAN}Registry:${NC} $REGISTRY" + echo -e " ${CYAN}Images:${NC} gohorsejobs-backend, gohorsejobs-frontend, gohorsejobs-seeder" + ;; +esac + diff --git a/scripts/auto-organized/verify_vg.ps1 b/scripts/auto-organized/verify_vg.ps1 new file mode 100644 index 0000000..967f0a0 --- /dev/null +++ b/scripts/auto-organized/verify_vg.ps1 @@ -0,0 +1,20 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +# Verificar oci-terraform +$vg = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/34?api-version=7.0" -Headers $h +Write-Host "=== oci-terraform ===" -ForegroundColor Cyan +$vg.variables.PSObject.Properties | ForEach-Object { + $val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value } + Write-Host " $($_.Name) = $val" +} + +# Verificar ms-parameters-dev +$vg40 = Invoke-RestMethod -Uri "$base/distributedtask/variablegroups/40?api-version=7.0" -Headers $h +Write-Host "`n=== ms-parameters-dev (ID: 40) ===" -ForegroundColor Cyan +$vg40.variables.PSObject.Properties | ForEach-Object { + $val = if ($_.Value.isSecret) { '(secret)' } else { $_.Value.value } + Write-Host " $($_.Name) = $val" +} diff --git a/scripts/auto-organized/vw_full.json b/scripts/auto-organized/vw_full.json new file mode 100644 index 0000000..9416529 --- /dev/null +++ b/scripts/auto-organized/vw_full.json @@ -0,0 +1,135 @@ +{ + "uuid": "h8wg0gogw44swosgk8wgc8cs", + "description": "Cofre de senhas", + "name": "Vaultwarden", + "applications": [ + { + "id": 2, + "uuid": "xokg0wk40og0kgg4088o084o", + "name": "vaultwarden", + "human_name": null, + "description": null, + "fqdn": "https://vault.rede5.com.br", + "ports": "", + "exposes": null, + "status": "running:healthy", + "service_id": 2, + "created_at": "2026-02-16T17:53:04.000000Z", + "updated_at": "2026-02-23T14:12:07.000000Z", + "exclude_from_status": false, + "required_fqdn": false, + "image": "vaultwarden/server:latest", + "is_log_drain_enabled": false, + "is_include_timestamps": false, + "deleted_at": null, + "is_gzip_enabled": true, + "is_stripprefix_enabled": true, + "last_online_at": "2026-02-23 14:12:07", + "is_migrated": false + } + ], + "compose_parsing_version": "5", + "config_hash": "3035632fa8e7d4156c09f4bb8d048033", + "connect_to_docker_network": false, + "databases": [ + + ], + "deleted_at": null, + "destination_id": 0, + "destination_type": "App\\Models\\StandaloneDocker", + "docker_compose": "services:\n vaultwarden:\n image: \u0027vaultwarden/server:latest\u0027\n environment:\n DOMAIN: \u0027${SERVICE_URL_VAULTWARDEN}\u0027\n DATABASE_URL: \u0027${VAULTWARDEN_DB_URL:-data/db.sqlite3}\u0027\n SIGNUPS_ALLOWED: \u0027${SIGNUP_ALLOWED:-true}\u0027\n ADMIN_TOKEN: \u0027${SERVICE_PASSWORD_64_ADMIN}\u0027\n IP_HEADER: X-Forwarded-For\n PUSH_ENABLED: \u0027${PUSH_ENABLED:-false}\u0027\n PUSH_INSTALLATION_ID: \u0027${PUSH_SERVICE_ID}\u0027\n PUSH_INSTALLATION_KEY: \u0027${PUSH_SERVICE_KEY}\u0027\n PUSH_SERVICE_ID: \u0027${PUSH_SERVICE_ID}\u0027\n PUSH_SERVICE_KEY: \u0027${PUSH_SERVICE_KEY}\u0027\n COOLIFY_RESOURCE_UUID: h8wg0gogw44swosgk8wgc8cs\n COOLIFY_CONTAINER_NAME: vaultwarden-h8wg0gogw44swosgk8wgc8cs\n COOLIFY_FQDN: vault.rede5.com.br\n COOLIFY_URL: \u0027https://vault.rede5.com.br\u0027\n SERVICE_NAME_VAULTWARDEN: vaultwarden\n volumes:\n - \u0027h8wg0gogw44swosgk8wgc8cs_vaultwarden-data:/data\u0027\n healthcheck:\n test:\n - CMD\n - curl\n - \u0027-f\u0027\n - \u0027http://127.0.0.1:80\u0027\n interval: 2s\n timeout: 10s\n retries: 15\n container_name: vaultwarden-h8wg0gogw44swosgk8wgc8cs\n restart: unless-stopped\n labels:\n - coolify.managed=true\n - coolify.version=4.0.0-beta.463\n - coolify.serviceId=2\n - coolify.type=service\n - coolify.name=vaultwarden-h8wg0gogw44swosgk8wgc8cs\n - coolify.resourceName=vaultwarden\n - coolify.projectName=infraestrutura\n - coolify.serviceName=vaultwarden\n - coolify.environmentName=production\n - coolify.pullRequestId=0\n - coolify.service.subId=2\n - coolify.service.subType=application\n - coolify.service.subName=vaultwarden\n - traefik.enable=true\n - traefik.http.middlewares.gzip.compress=true\n - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https\n - traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.entryPoints=http\n - traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.middlewares=redirect-to-https\n - \u0027traefik.http.routers.http-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.rule=Host(`vault.rede5.com.br`) \u0026\u0026 PathPrefix(`/`)\u0027\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.entryPoints=https\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.middlewares=gzip\n - \u0027traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.rule=Host(`vault.rede5.com.br`) \u0026\u0026 PathPrefix(`/`)\u0027\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.tls.certresolver=letsencrypt\n - traefik.http.routers.https-0-h8wg0gogw44swosgk8wgc8cs-vaultwarden.tls=true\n - \u0027caddy_0.encode=zstd gzip\u0027\n - \u0027caddy_0.handle_path.0_reverse_proxy={{upstreams 80}}\u0027\n - \u0027caddy_0.handle_path=/*\u0027\n - caddy_0.header=-Server\n - \u0027caddy_0.try_files={path} /index.html /index.php\u0027\n - \u0027caddy_0=https://vault.rede5.com.br\u0027\n - caddy_ingress_network=h8wg0gogw44swosgk8wgc8cs\n networks:\n h8wg0gogw44swosgk8wgc8cs: null\n env_file:\n - .env\nvolumes:\n h8wg0gogw44swosgk8wgc8cs_vaultwarden-data:\n name: h8wg0gogw44swosgk8wgc8cs_vaultwarden-data\nnetworks:\n h8wg0gogw44swosgk8wgc8cs:\n name: h8wg0gogw44swosgk8wgc8cs\n external: true\n", + "docker_compose_raw": "services:\n vaultwarden:\n image: \u0027vaultwarden/server:latest\u0027\n environment:\n - \u0027SERVICE_FQDN_VAULTWARDEN_HTTPS=https://vault.rede5.com.br\u0027\n - \u0027SERVICE_FQDN_VAULTWARDEN=https://vault.rede5.com.br\u0027\n - \u0027DOMAIN=${SERVICE_URL_VAULTWARDEN}\u0027\n - \u0027DATABASE_URL=${VAULTWARDEN_DB_URL:-data/db.sqlite3}\u0027\n - \u0027SIGNUPS_ALLOWED=${SIGNUP_ALLOWED:-true}\u0027\n - \u0027ADMIN_TOKEN=${SERVICE_PASSWORD_64_ADMIN}\u0027\n - IP_HEADER=X-Forwarded-For\n - \u0027PUSH_ENABLED=${PUSH_ENABLED:-false}\u0027\n - \u0027PUSH_INSTALLATION_ID=${PUSH_SERVICE_ID}\u0027\n - \u0027PUSH_INSTALLATION_KEY=${PUSH_SERVICE_KEY}\u0027\n volumes:\n - \u0027vaultwarden-data:/data\u0027\n healthcheck:\n test:\n - CMD\n - curl\n - \u0027-f\u0027\n - \u0027http://127.0.0.1:80\u0027\n interval: 2s\n timeout: 10s\n retries: 15\n", + "environment_id": 1, + "is_container_label_escape_enabled": true, + "server": { + "id": 0, + "uuid": "m844o4gkwkwcc0k48swgs8c8", + "name": "localhost", + "description": "This is the server where Coolify is running on. Don\u0027t delete this!", + "ip": "host.docker.internal", + "port": 22, + "user": "root", + "team_id": 0, + "private_key_id": 0, + "proxy": { + "type": "TRAEFIK", + "status": "running", + "last_saved_settings": null, + "last_applied_settings": null, + "redirect_enabled": true, + "force_stop": false + }, + "created_at": "2026-02-16T12:39:11.000000Z", + "updated_at": "2026-02-23T15:04:09.000000Z", + "unreachable_notification_sent": false, + "unreachable_count": 0, + "high_disk_usage_notification_sent": false, + "log_drain_notification_sent": false, + "swarm_cluster": null, + "validation_logs": null, + "sentinel_updated_at": "2026-02-23 15:04:09", + "deleted_at": null, + "ip_previous": null, + "hetzner_server_id": null, + "cloud_provider_token_id": null, + "hetzner_server_status": null, + "is_validating": false, + "detected_traefik_version": "3.6.8", + "traefik_outdated_info": null, + "is_coolify_host": true, + "settings": { + "id": 1, + "is_swarm_manager": false, + "is_jump_server": false, + "is_build_server": false, + "is_reachable": true, + "is_usable": true, + "server_id": 0, + "created_at": "2026-02-16T12:39:11.000000Z", + "updated_at": "2026-02-16T12:47:49.000000Z", + "wildcard_domain": null, + "is_cloudflare_tunnel": false, + "is_logdrain_newrelic_enabled": false, + "logdrain_newrelic_license_key": null, + "logdrain_newrelic_base_uri": null, + "is_logdrain_highlight_enabled": false, + "logdrain_highlight_project_id": null, + "is_logdrain_axiom_enabled": false, + "logdrain_axiom_dataset_name": null, + "logdrain_axiom_api_key": null, + "is_swarm_worker": false, + "is_logdrain_custom_enabled": false, + "logdrain_custom_config": null, + "logdrain_custom_config_parser": null, + "concurrent_builds": 2, + "dynamic_timeout": 3600, + "force_disabled": false, + "is_metrics_enabled": false, + "generate_exact_labels": false, + "force_docker_cleanup": true, + "docker_cleanup_frequency": "0 0 * * *", + "docker_cleanup_threshold": 80, + "server_timezone": "UTC", + "delete_unused_volumes": false, + "delete_unused_networks": false, + "is_sentinel_enabled": true, + "sentinel_token": "eyJpdiI6IlpzSVdrV0p2UktKY1N3VGpDUm4yQXc9PSIsInZhbHVlIjoiTC9KS3ppK3FYeWJCa1dzYXZOWDFFWHErdkhXWkVFT1ZRNHdNTVVacHVHS3M0UkJHS2JzZUtZbHFtNW16ZGlzV3plRlUzVWQ5WFRVQm1IdW1ETWdSTnc9PSIsIm1hYyI6IjRkNjgzMzU2MWE1YWExYjE2MTkyNDM3ZDg2MTNmODYxNWY1Mzk5YjEwM2EwNWY5YjIyNTk5MDJkNGY2NGU2NjkiLCJ0YWciOiIifQ==", + "sentinel_metrics_refresh_rate_seconds": 10, + "sentinel_metrics_history_days": 7, + "sentinel_push_interval_seconds": 60, + "sentinel_custom_url": "http://host.docker.internal:8000", + "server_disk_usage_notification_threshold": 80, + "is_sentinel_debug_enabled": false, + "server_disk_usage_check_frequency": "0 23 * * *", + "is_terminal_enabled": true, + "deployment_queue_limit": 25, + "disable_application_image_retention": false + } + }, + "server_id": 0, + "server_status": true, + "service_type": null, + "status": "running:healthy", + "created_at": "2026-02-16T17:53:04.000000Z", + "updated_at": "2026-02-17T21:39:21.000000Z" +} diff --git a/scripts/auto-organized/wait_builds.ps1 b/scripts/auto-organized/wait_builds.ps1 new file mode 100644 index 0000000..cd9b1da --- /dev/null +++ b/scripts/auto-organized/wait_builds.ps1 @@ -0,0 +1,48 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$buildIds = @(6181, 6182, 6183, 6185, 6186) # mfe-shell, mfe-auth, mfe-shell-oci, mfe-person, mfe-poc +# mfe-user nao apareceu, buscar separado +$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=mfe-user&api-version=7.0" -Headers $h +if ($defs.count -gt 0) { + $defId = $defs.value[0].id + $ub = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h + if ($ub.count -gt 0) { $buildIds += $ub.value[0].id } +} + +Write-Host "Aguardando builds: $($buildIds -join ', ')" -ForegroundColor Cyan + +for ($i = 0; $i -lt 30; $i++) { + Start-Sleep -Seconds 15 + $ts = Get-Date -Format 'HH:mm:ss' + $pending = 0 + $status = @() + + foreach ($bid in $buildIds) { + $b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h + $result = if ($b.result) { $b.result } else { '...' } + $status += "$($b.definition.name)=$result" + if ($b.status -ne 'completed') { $pending++ } + } + + Write-Host "$ts $($status -join ' ')" + if ($pending -eq 0) { break } +} + +Write-Host "" +Write-Host "Resumo final:" -ForegroundColor Cyan +foreach ($bid in $buildIds) { + $b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h + $result = if ($b.result) { $b.result } else { $b.status } + $icon = if ($result -eq 'succeeded') { 'OK' } else { 'FALHOU' } + Write-Host " [$icon] $($b.definition.name) (build $bid): $result" + + if ($result -eq 'failed') { + $vr = $b.validationResults + if ($vr) { + $vr | Select-Object -First 2 | ForEach-Object { Write-Host " erro: $($_.message)" } + } + } +} diff --git a/scripts/auto-organized/wait_builds2.ps1 b/scripts/auto-organized/wait_builds2.ps1 new file mode 100644 index 0000000..d3380ac --- /dev/null +++ b/scripts/auto-organized/wait_builds2.ps1 @@ -0,0 +1,48 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +$buildIds = @(6181, 6182, 6183, 6185, 6186) # mfe-shell, mfe-auth, mfe-shell-oci, mfe-person, mfe-poc +# mfe-user nao apareceu, buscar separado +$defs = Invoke-RestMethod -Uri "$base/build/definitions?name=mfe-user&api-version=7.0" -Headers $h +if ($defs.count -gt 0) { + $defId = $defs.value[0].id + $ub = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h + if ($ub.count -gt 0) { $buildIds += $ub.value[0].id } +} + +Write-Host "Aguardando builds: $($buildIds -join ', ')" -ForegroundColor Cyan + +for ($i = 0; $i -lt 30; $i++) { + Start-Sleep -Seconds 15 + $ts = Get-Date -Format 'HH:mm:ss' + $pending = 0 + $status = @() + + foreach ($bid in $buildIds) { + $b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h + $result = if ($b.result) { $b.result } else { '...' } + $status += "$($b.definition.name)=$result" + if ($b.status -ne 'completed') { $pending++ } + } + + Write-Host "$ts $($status -join ' ')" + if ($pending -eq 0) { break } +} + +Write-Host "" +Write-Host "Resumo final:" -ForegroundColor Cyan +foreach ($bid in $buildIds) { + $b = Invoke-RestMethod -Uri "$base/build/builds/$bid`?api-version=7.0" -Headers $h + $result = if ($b.result) { $b.result } else { $b.status } + $icon = if ($result -eq 'succeeded') { 'OK' } else { 'FALHOU' } + Write-Host " [$icon] $($b.definition.name) (build $bid): $result" + + if ($result -eq 'failed') { + $vr = $b.validationResults + if ($vr) { + $vr | Select-Object -First 2 | ForEach-Object { Write-Host " erro: $($_.message)" } + } + } +} diff --git a/scripts/auto-organized/watch_approvals.ps1 b/scripts/auto-organized/watch_approvals.ps1 new file mode 100644 index 0000000..30319f7 --- /dev/null +++ b/scripts/auto-organized/watch_approvals.ps1 @@ -0,0 +1,35 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +Write-Host "Monitorando aprovacoes por 3 minutos (polling 10s)..." -ForegroundColor Cyan + +for ($i = 0; $i -lt 18; $i++) { + Start-Sleep -Seconds 10 + + $a = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h + $ts = Get-Date -Format 'HH:mm:ss' + + if ($a.count -eq 0) { + Write-Host "$ts sem aprovacoes pendentes" -ForegroundColor Gray + continue + } + + Write-Host "$ts $($a.count) aprovacao(oes) pendente(s) — aprovando..." -ForegroundColor Yellow + + $items = @($a.value | ForEach-Object { + @{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' } + }) + $body = ConvertTo-Json -InputObject $items -Depth 5 + + $result = Invoke-RestMethod ` + -Uri "$base/pipelines/approvals?api-version=7.1-preview.1" ` + -Method PATCH -Headers $h -Body $body + + $result.value | ForEach-Object { + Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green + } +} + +Write-Host "Monitoramento encerrado." -ForegroundColor Cyan diff --git a/scripts/auto-organized/watch_approvals2.ps1 b/scripts/auto-organized/watch_approvals2.ps1 new file mode 100644 index 0000000..d795779 --- /dev/null +++ b/scripts/auto-organized/watch_approvals2.ps1 @@ -0,0 +1,35 @@ +$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp' +$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p)) +$h = @{ Authorization = 'Basic ' + $t; 'Content-Type' = 'application/json' } +$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis' + +Write-Host "Monitorando aprovacoes por 3 minutos (polling 10s)..." -ForegroundColor Cyan + +for ($i = 0; $i -lt 18; $i++) { + Start-Sleep -Seconds 10 + + $a = Invoke-RestMethod -Uri "$base/pipelines/approvals?state=pending&api-version=7.1-preview.1" -Headers $h + $ts = Get-Date -Format 'HH:mm:ss' + + if ($a.count -eq 0) { + Write-Host "$ts sem aprovacoes pendentes" -ForegroundColor Gray + continue + } + + Write-Host "$ts $($a.count) aprovacao(oes) pendente(s) — aprovando..." -ForegroundColor Yellow + + $items = @($a.value | ForEach-Object { + @{ approvalId = $_.id; status = 'approved'; comment = 'Aprovado automaticamente via API' } + }) + $body = ConvertTo-Json -InputObject $items -Depth 5 + + $result = Invoke-RestMethod ` + -Uri "$base/pipelines/approvals?api-version=7.1-preview.1" ` + -Method PATCH -Headers $h -Body $body + + $result.value | ForEach-Object { + Write-Host " $($_.id) -> $($_.status)" -ForegroundColor Green + } +} + +Write-Host "Monitoramento encerrado." -ForegroundColor Cyan