forked from aws/amazon-cloudwatch-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate JSON File With Linux Test AMI X Tag (aws#440)
- Loading branch information
1 parent
abc8148
commit 6f87fad
Showing
9 changed files
with
226 additions
and
57 deletions.
There are no files selected for viewing
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 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,100 @@ | ||
[ | ||
{ | ||
"os": "ubuntu", | ||
"username": "ubuntu", | ||
"installAgentCommand": "sudo dpkg -i -E ./amazon-cloudwatch-agent.deb", | ||
"ami": "cloudwatch-agent-integration-test-ubuntu*", | ||
"caCertPath": "/etc/ssl/certs/ca-certificates.crt", | ||
"arc": "amd64", "binaryName": "amazon-cloudwatch-agent.deb" | ||
}, | ||
{ | ||
"os": "al2", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-al2*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "rhel8", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-rhel8-base*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "rhel8-1", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-rhel8-1*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "rhel8-2", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-rhel8-2*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "rhel8-3", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-rhel8-3*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "rhel8-4", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-rhel8-4*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "ol8-1", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-ol8-1*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "ol8-2", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-ol8-2*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "ol8-3", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-ol8-3*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
}, | ||
{ | ||
"os": "ol8-4", | ||
"username": "ec2-user", | ||
"installAgentCommand": "rpm -U ./amazon-cloudwatch-agent.rpm", | ||
"ami": "cloudwatch-agent-integration-test-ol8-4*", | ||
"caCertPath": "/etc/ssl/certs/ca-bundle.crt", | ||
"arc": "amd64", | ||
"binaryName": "amazon-cloudwatch-agent.rpm" | ||
} | ||
] |
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,5 @@ | ||
[ | ||
{ | ||
|
||
} | ||
] |
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,6 @@ | ||
[ | ||
{ | ||
"os": "win-2022", | ||
"ami": "cloudwatch-agent-integration-test-win-2022*" | ||
} | ||
] |
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,75 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
const ( | ||
linux = "linux" | ||
windows = "windows" | ||
mac = "mac" | ||
tag = "tag" | ||
) | ||
|
||
//you can't have a const map in golang | ||
var osToTagMap = map[string][]string{ | ||
linux: {"integration"}, | ||
windows: {}, | ||
mac: {}, | ||
} | ||
|
||
func main() { | ||
for osType, tags := range osToTagMap { | ||
testMatrix := genMatrix(osType, tags) | ||
writeTestMatrixFile(osType, testMatrix) | ||
} | ||
} | ||
|
||
func genMatrix(targetOS string, tags []string) []map[string]string { | ||
openTestMatrix, err := os.Open(fmt.Sprintf("integration/generator/resources/%v_test_matrix.json", targetOS)) | ||
if err != nil { | ||
panic(fmt.Sprintf("can't read file %v_test_matrix.json err %v", targetOS, err)) | ||
} | ||
byteValueTestMatrix, _ := ioutil.ReadAll(openTestMatrix) | ||
_ = openTestMatrix.Close() | ||
var testMatrix []map[string]string | ||
err = json.Unmarshal([]byte(byteValueTestMatrix), &testMatrix) | ||
if err != nil { | ||
panic(fmt.Sprintf("can't unmarshall file %v_test_matrix.json err %v", targetOS, err)) | ||
} | ||
|
||
var testMatrixComplete []map[string]string | ||
for _, test := range testMatrix { | ||
testLine := copyMap(test) | ||
for _, testTag := range tags { | ||
testLine[tag] = testTag | ||
} | ||
testMatrixComplete = append(testMatrixComplete, testLine) | ||
} | ||
return testMatrixComplete | ||
} | ||
|
||
func writeTestMatrixFile(targetOS string, testMatrix []map[string]string) { | ||
bytes, err := json.MarshalIndent(testMatrix, "", " ") | ||
if err != nil { | ||
panic(fmt.Sprintf("Can't marshal json for target os %v, err %v", targetOS, err)) | ||
} | ||
err = ioutil.WriteFile(fmt.Sprintf("integration/generator/resources/%v_complete_test_matrix.json", targetOS), bytes, os.ModePerm) | ||
if err != nil { | ||
panic(fmt.Sprintf("Can't write json to file for target os %v, err %v", targetOS, err)) | ||
} | ||
} | ||
|
||
func copyMap(mapToCopy map[string]string) map[string]string { | ||
testLine := make(map[string]string) | ||
for key, value := range mapToCopy { | ||
testLine[key] = value | ||
} | ||
return testLine | ||
} |
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