Skip to content

Commit 4305df7

Browse files
Add workflow, use http util functions
1 parent b703b7b commit 4305df7

2 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/contract-testing.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
flex-cluster: ${{ steps.filter.outputs.flex-cluster }}
2323
online-archive: ${{ steps.filter.outputs.online-archive }}
2424
organization: ${{ steps.filter.outputs.organization }}
25+
org-service-account: ${{ steps.filter.outputs.org-service-account }}
2526
private-endpoint-aws: ${{ steps.filter.outputs.private-endpoint-aws }}
2627
private-endpoint-service: ${{ steps.filter.outputs.private-endpoint-service }}
2728
privatelink-endpoint-service-data-federation-online-archive: ${{ steps.filter.outputs.privatelink-endpoint-service-data-federation-online-archive }}
@@ -60,6 +61,8 @@ jobs:
6061
- 'cfn-resources/online-archive/**'
6162
organization:
6263
- 'cfn-resources/organization/**'
64+
org-service-account:
65+
- 'cfn-resources/org-service-account/**'
6366
private-endpoint-aws:
6467
- 'cfn-resources/private-endpoint-aws/**'
6568
private-endpoint-service:
@@ -522,7 +525,48 @@ jobs:
522525
run: |
523526
pushd cfn-resources/organization
524527
make create-test-resources
525-
528+
529+
cat inputs/inputs_1_create.json
530+
cat inputs/inputs_1_update.json
531+
532+
make run-contract-testing
533+
make delete-test-resources
534+
org-service-account:
535+
needs: change-detection
536+
if: ${{ needs.change-detection.outputs.org-service-account == 'true' }}
537+
runs-on: ubuntu-latest
538+
steps:
539+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
540+
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
541+
with:
542+
go-version-file: 'cfn-resources/go.mod'
543+
- name: setup Atlas CLI
544+
uses: mongodb/atlas-github-action@e3c9e0204659bafbb3b65e1eb1ee745cca0e9f3b
545+
- uses: aws-actions/setup-sam@c2a20b1822cc4a6bc594ff7f1dbb658758e383c3
546+
with:
547+
use-installer: true
548+
- uses: aws-actions/configure-aws-credentials@61815dcd50bd041e203e49132bacad1fd04d2708
549+
with:
550+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
551+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
552+
aws-region: eu-west-1
553+
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
554+
with:
555+
python-version: '3.9'
556+
cache: 'pip' # caching pip dependencies
557+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
558+
- name: Run the Contract test
559+
shell: bash
560+
env:
561+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
562+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
563+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
564+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
565+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
566+
run: |
567+
cd cfn-resources/org-service-account
568+
make create-test-resources
569+
526570
cat inputs/inputs_1_create.json
527571
cat inputs/inputs_1_update.json
528572

cfn-resources/org-service-account/cmd/resource/share.go renamed to cfn-resources/org-service-account/cmd/resource/handlers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func handleUpdate(client *util.MongoDBClient, model *Model) handler.ProgressEven
7676

7777
_, apiResp, err := client.AtlasSDK.ServiceAccountsApi.GetOrgServiceAccount(ctx, *orgID, *clientID).Execute()
7878
if err != nil {
79-
if apiResp != nil && apiResp.StatusCode == http.StatusNotFound {
79+
if util.StatusNotFound(apiResp) {
8080
return handler.ProgressEvent{
8181
OperationStatus: handler.Failed,
8282
Message: "Resource not found",
@@ -113,7 +113,7 @@ func handleDelete(client *util.MongoDBClient, model *Model) handler.ProgressEven
113113

114114
_, resp, err := client.AtlasSDK.ServiceAccountsApi.GetOrgServiceAccount(ctx, *orgID, *clientID).Execute()
115115
if err != nil {
116-
if resp != nil && resp.StatusCode == http.StatusNotFound {
116+
if util.StatusNotFound(resp) {
117117
return handler.ProgressEvent{
118118
OperationStatus: handler.Failed,
119119
Message: "Resource not found",

0 commit comments

Comments
 (0)