Last active
September 9, 2019 12:17
-
-
Save leandrosilva/22b2b34fda07932ac1dbf8fde8423911 to your computer and use it in GitHub Desktop.
Two small samples on how to use mod_s3.psm1 and mod_eslog.psm1
This file contains hidden or 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
################################# | |
# SENDING LOG TO ELASTIC SEARCH # | |
################################# | |
Import-Module ($PSScriptRoot + "\mod_eslog.psm1") -Force | |
Send-InstallationLog -Version $remoteVersion | |
"Current version has been installed." | |
#################### | |
# HELPER FUNCTIONS # | |
#################### | |
function Send-InstallationLog ($Version) { | |
$esVersionsIndexUri = Get-ESIndexUri -IndexSuffix "versions" | |
$body = @" | |
{ | |
"Version": "${Version}", | |
"Message": "Hey you there! I am your DUMMY app rocking version ${Version}." | |
} | |
"@ | |
Send-ESLog -IndexUri $esVersionsIndexUri -Body $body | |
} |
This file contains hidden or 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
################################ | |
# GETTING METADATA FROM AWS S3 # | |
################################ | |
Import-Module ($PSScriptRoot + "\mod_s3.psm1") -Force | |
$remoteLastModified = (Get-RemoteVersionCatalogMetadata).LastModified | |
"Remote file: $remoteLastModified." | |
$localLastModified = (Get-Item $LocalVersionCatalogPath).LastWriteTime | |
"Local file: $localLastModified." | |
$remoteWasModified = ($remoteLastModified -gt $localFileMetadata) | |
"Remote file was modified: $remoteWasModified." | |
if ($remoteWasModified) { | |
Read-RemoteVersionCatalog -LocalFilePath $RemoteVersionCatalogPath | |
$remoteVersionCatalogJson = Get-Content $RemoteVersionCatalogPath | Out-String | ConvertFrom-Json | |
$remoteVersion = $remoteVersionCatalogJson | ForEach-Object {$_.$DummyCluster} | ForEach-Object {$_.current} | |
"Remote version: $remoteVersion." | |
$localVersionCatalogJson = Get-Content $LocalVersionCatalogPath | Out-String | ConvertFrom-Json | |
$localVersion = $localVersionCatalogJson | ForEach-Object {$_.$DummyCluster} | ForEach-Object {$_.current} | |
"Local version: $localVersion." | |
$versionHasChanged = (-not ($localVersion -eq $remoteVersion)) | |
"Current version has changed: $versionHasChanged." | |
# this and that... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment