Skip to content

Commit

Permalink
update rds/dbinstance to update tags if modified
Browse files Browse the repository at this point in the history
  • Loading branch information
ssuman2-infoblox committed Oct 28, 2023
1 parent 782d864 commit 7139a9f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
22 changes: 8 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ env:
# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
CONTRIB_DOCKER_USR: ${{ secrets.CONTRIB_DOCKER_USR }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
AWS_USR: ${{ secrets.AWS_USR }}

jobs:
detect-noop:
Expand Down Expand Up @@ -319,10 +318,10 @@ jobs:

- name: Login to Docker
uses: docker/login-action@v1
if: env.CONTRIB_DOCKER_USR != ''
if: env.DOCKERHUB_USERNAME != ''
with:
username: ${{ secrets.CONTRIB_DOCKER_USR }}
password: ${{ secrets.CONTRIB_DOCKER_PSW }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Login to Upbound
uses: docker/login-action@v1
Expand All @@ -332,20 +331,15 @@ jobs:
username: ${{ secrets.XPKG_ACCESS_ID }}
password: ${{ secrets.XPKG_TOKEN }}

- name: Publish Artifacts to S3 and Docker Hub
- name: Publish Artifacts to Docker Hub
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
if: env.DOCKERHUB_USERNAME != ''
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Promote Artifacts in S3 and Docker Hub
if: github.ref == 'refs/heads/master' && env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
- name: Promote Artifacts in Docker Hub
if: github.ref == 'refs/heads/master' && env.DOCKERHUB_USERNAME != ''
run: make -j2 promote
env:
BRANCH_NAME: master
CHANNEL: master
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_USR }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PSW }}

10 changes: 5 additions & 5 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
# a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether
# credentials have been provided before trying to run steps that need them.
CONTRIB_DOCKER_USR: ${{ secrets.CONTRIB_DOCKER_USR }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
AWS_USR: ${{ secrets.AWS_USR }}

jobs:
Expand All @@ -41,13 +41,13 @@ jobs:

- name: Login to Docker
uses: docker/login-action@v1
if: env.CONTRIB_DOCKER_USR != ''
if: env.DOCKERHUB_USERNAME != ''
with:
username: ${{ secrets.CONTRIB_DOCKER_USR }}
password: ${{ secrets.CONTRIB_DOCKER_PSW }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Promote Artifacts in S3 and Docker Hub
if: env.AWS_USR != '' && env.CONTRIB_DOCKER_USR != ''
if: env.AWS_USR != '' && env.DOCKERHUB_USERNAME != ''
run: make -j2 promote BRANCH_NAME=${GITHUB_REF##*/}
env:
VERSION: ${{ github.event.inputs.version }}
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

PROJECT_NAME := provider-aws
PROJECT_REPO := github.com/crossplane-contrib/$(PROJECT_NAME)
DOCKER_REGISTRY := infoblox

PLATFORMS ?= linux_amd64 linux_arm64

Expand Down Expand Up @@ -61,10 +62,7 @@ IMAGES = provider-aws
# ====================================================================================
# Setup XPKG

XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane-contrib index.docker.io/crossplanecontrib
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane-contrib
XPKG_REG_ORGS ?= index.docker.io/infoblox
XPKGS = provider-aws
-include build/makelib/xpkg.mk

Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/rds/dbinstance/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/crossplane-contrib/provider-aws/apis/v1alpha1"
aws "github.com/crossplane-contrib/provider-aws/pkg/clients"
dbinstance "github.com/crossplane-contrib/provider-aws/pkg/clients/rds"
svcutils "github.com/crossplane-contrib/provider-aws/pkg/controller/rds"
"github.com/crossplane-contrib/provider-aws/pkg/controller/rds/utils"
"github.com/crossplane-contrib/provider-aws/pkg/features"
)
Expand Down Expand Up @@ -450,6 +451,15 @@ func (e *custom) isUpToDate(cr *svcapitypes.DBInstance, out *svcsdk.DescribeDBIn
cmpopts.IgnoreFields(svcapitypes.CustomDBInstanceParameters{}, "DeleteAutomatedBackups"),
)

// for tagging: at least one option must be added, modified, or removed.
tagsUpToDate, _ := svcutils.AreTagsUpToDate(e.client, cr.Spec.ForProvider.Tags, cr.Status.AtProvider.DBInstanceARN)
if !tagsUpToDate {
err := svcutils.UpdateTagsForResource(e.client, cr.Spec.ForProvider.Tags, cr.Status.AtProvider.DBInstanceARN)
if err != nil {
return true, aws.Wrap(err, errDescribe)
}
}

if diff == "" && !maintenanceWindowChanged && !backupWindowChanged && !versionChanged && !vpcSGsChanged && !dbParameterGroupChanged && !optionGroupChanged {
return true, nil
}
Expand Down

0 comments on commit 7139a9f

Please sign in to comment.