-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from xoap-io/dev
Added features set for synchronisation
- Loading branch information
Showing
12 changed files
with
197 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Commit linter | ||
on: | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
commitlint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: wagoid/commitlint-github-action@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
$brewPackages = @( | ||
"pre-commit", | ||
"gawk", | ||
"terraform-docs", | ||
"tflint", | ||
"tfsec", | ||
"coreutils", | ||
"checkov", | ||
"terrascan", | ||
"golang", | ||
"Checkmarx/tap/kics" | ||
|
||
) | ||
function ReplaceAllStringsInFile($SearchString, $ReplaceString, $FullPathToFile) { | ||
$content = [System.IO.File]::ReadAllText("$FullPathToFile").Replace("$SearchString", "$ReplaceString") | ||
[System.IO.File]::WriteAllText("$FullPathToFile", $content) | ||
} | ||
function SetupPreCommit { | ||
Write-host "Configuring pre-commit..." | ||
$dir = Join-Path $env:HOME ".git-template" | ||
if (Test-Path "$dir") { | ||
Remove-item -Recurse -Force -Path "$dir" -Verbose | ||
} | ||
$globalHooks = Join-path $dir "hooks" | ||
$localHooks = "$PSScriptRoot/../.git/hooks" | ||
if (Test-Path "$localHooks") { | ||
Remove-item -Recurse -Force -Path "$localHooks" -Verbose | ||
} | ||
|
||
New-Item -ItemType Directory -Path $dir | ||
git config --global init.templateDir $dir | ||
git config --global core.hooksPath $dir/hooks | ||
pre-commit init-templatedir -t pre-commit $dir | ||
pre-commit init-templatedir -t prepare-commit-msg $dir | ||
pre-commit init-templatedir -t commit-msg $dir | ||
|
||
Copy-Item $globalHooks -Destination $localHooks -Recurse -Verbose | ||
} | ||
function InstallMacDependencies { | ||
foreach ($package in $brewPackages) { | ||
Write-Host "Going to check for package $package" | ||
brew install $package | ||
} | ||
} | ||
function FixReadme { | ||
$file = "$PSScriptRoot/../README.md" | ||
$path = Get-Item "$PSScriptRoot/.." | ||
ReplaceAllStringsInFile -SearchString "TERRAFORM-MODULE-TEMPLATE" -ReplaceString $path.Name.ToUpper() -FullPathToFile $file | ||
} | ||
|
||
function PrintAdditionalNeededConfig { | ||
Write-Host "Please add following statements to your .bashrc or .zshrc" | ||
Write-host " | ||
Optional: | ||
export GOPATH=`$HOME/dev/go-workspace | ||
export GOROOT=/usr/local/opt/go/libexec | ||
export PATH=`$PATH:`$GOPATH/bin | ||
export PATH=`$PATH:`$GOROOT/bin | ||
Required: | ||
export TF_PLUGIN_CACHE_DIR=~/.terraform-cache | ||
export KICS_QUERIES_PATH=/usr/local/opt/kics/share/kics/assets/queries" | ||
} | ||
|
||
if ($IsWindows) { | ||
Write-Error "This script is currently not able to setup windows systems" | ||
exit 1 | ||
} | ||
if ($IsLinux) { | ||
Write-Error "This script is currently not able to setup linux systems" | ||
exit 1 | ||
} | ||
if ($IsMacOS) { | ||
InstallMacDependencies | ||
PrintAdditionalNeededConfig | ||
} | ||
|
||
SetupPreCommit | ||
FixReadme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
$protectedFiles = @( | ||
"main.tf", | ||
"outputs.tf" | ||
"variables.tf" | ||
) | ||
$ChangedFiles = $(git status --porcelain | Measure-Object | Select-Object -expand Count) | ||
if ($ChangedFiles -gt 0) | ||
{ | ||
Write-Error "Found $ChangedFiles changed files. Please commit or stash them before using this script." | ||
exit 0 | ||
} | ||
|
||
$tempPath = Join-Path $([system.io.path]::GetTempPath()) "xoap-template" | ||
|
||
if(Test-path "$tempPath"){ | ||
Write-Host "Removing old temporary files for xoap module template" | ||
Remove-Item "$tempPath" -Recurse -Force -Verbose | ||
} | ||
|
||
git clone https://github.com/xoap-io/terraform-module-template.git $tempPath | ||
|
||
$templateItems = Get-ChildItem $tempPath -File | Where-Object {$_.Name -notin $protectedFiles} | ||
|
||
foreach($item in $templateItems){ | ||
$targetPath = $item.FullName.Replace($tempPath, "${PSScriptRoot}/..") | ||
Copy-Item $item.FullName -Destination $targetPath -Force -Verbose | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
exclude-categories: | ||
exclude-paths: | ||
- ".terraform" | ||
- "*/.terraform" | ||
exclude-queries: | ||
- e592a0c5-5bdb-414c-9066-5dba7cdea370 #IAM Access Analyzer Undefined - always disable | ||
fail-on: | ||
- high | ||
- medium | ||
minimal-ui: false | ||
no-color: false | ||
no-progress: true | ||
preview-lines: 3 | ||
silent: false | ||
verbose: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +0,0 @@ | ||
output "context" { | ||
value = var.context | ||
description = "Exported context from input variable" | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
variable "context" { | ||
type = object({ | ||
organization = string | ||
environment = string | ||
account = string | ||
product = string | ||
tags = map(string) | ||
}) | ||
description = "Default context for naming and tagging purpose" | ||
variable "tags" { | ||
type = map(string) | ||
default = {} | ||
description = "A list of Variables" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters