Skip to content

Commit

Permalink
Merge branch 'master' into feature/persist-apiversions
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek authored Jul 6, 2021
2 parents 5a7a84d + d4b0803 commit 74e3f6f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 1 deletion.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '31 1 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion controllers/mysql_combined_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestMySQLHappyPath(t *testing.T) {
ctx := context.Background()

// Add any setup steps that needs to be executed before each test
rgLocation := "eastus2"
rgLocation := "westus2"
rgName := tc.resourceGroupName
mySQLServerName := GenerateTestResourceNameWithRandom("mysql-srv", 10)
mySQLReplicaName := GenerateTestResourceNameWithRandom("mysql-rep", 10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (s *AzureSqlActionManager) UpdateUserPassword(
if err != nil {
return err
}
defer db.Close()

instance := &azurev1alpha1.AzureSQLUser{
TypeMeta: metav1.TypeMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (s *AzureSqlManagedUserManager) Ensure(ctx context.Context, obj runtime.Obj
instance.Status.SetFailedProvisioning(instance.Status.Message)
return false, nil
}
defer db.Close()

userExists, err := s.UserExists(ctx, db, requestedUsername)
if err != nil {
Expand Down Expand Up @@ -189,6 +190,7 @@ func (s *AzureSqlManagedUserManager) Delete(ctx context.Context, obj runtime.Obj

return true, nil
}
defer db.Close()

userExists, err := s.UserExists(ctx, db, requestedUsername)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (s *AzureSqlUserManager) Ensure(ctx context.Context, obj runtime.Object, op

return false, err
}
defer db.Close()

userSecretKey := MakeSecretKey(userSecretClient, instance)

Expand Down Expand Up @@ -352,6 +353,7 @@ func (s *AzureSqlUserManager) Delete(ctx context.Context, obj runtime.Object, op
}
return false, err
}
defer db.Close()

var sqlUserSecretClient secrets.SecretClient
if options.SecretClient != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcemanager/mysql/mysqlaaduser/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (m *MySQLAADUserManager) Ensure(ctx context.Context, obj runtime.Object, op

return false, mysql.IgnoreDatabaseBusy(err)
}
defer db.Close()

instance.Status.SetProvisioning("")

Expand Down Expand Up @@ -179,6 +180,7 @@ func (m *MySQLAADUserManager) Delete(ctx context.Context, obj runtime.Object, op
}
return false, err
}
defer db.Close()

err = mysql.DropUser(ctx, db, instance.Username())
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcemanager/mysql/mysqluser/mysqluser_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (s *MySqlUserManager) Ensure(ctx context.Context, obj runtime.Object, opts

return false, err
}
defer db.Close()

secretKey := secrets.SecretKey{Name: instance.Name, Namespace: instance.Namespace, Kind: instance.TypeMeta.Kind}
// create or get new user secret
Expand Down Expand Up @@ -228,6 +229,7 @@ func (s *MySqlUserManager) Delete(ctx context.Context, obj runtime.Object, opts
}
return false, err
}
defer db.Close()

var userSecretClient secrets.SecretClient
if options.SecretClient != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/resourcemanager/psql/psqluser/psqluser_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (m *PostgreSqlUserManager) Ensure(ctx context.Context, obj runtime.Object,

return false, err
}
defer db.Close()

secretKey := secrets.SecretKey{Name: instance.Name, Namespace: instance.Namespace, Kind: instance.TypeMeta.Kind}

Expand Down Expand Up @@ -250,6 +251,7 @@ func (m *PostgreSqlUserManager) Delete(ctx context.Context, obj runtime.Object,
//stop the reconcile with unkown error
return false, err
}
defer db.Close()

var psqlUserSecretClient secrets.SecretClient
if options.SecretClient != nil {
Expand Down

0 comments on commit 74e3f6f

Please sign in to comment.