Skip to content

MSSQL allow to define different databases for login an user#192

Merged
Duologic merged 3 commits into
crossplane-contrib:masterfrom
bakito:login-db
Nov 28, 2024
Merged

MSSQL allow to define different databases for login an user#192
Duologic merged 3 commits into
crossplane-contrib:masterfrom
bakito:login-db

Conversation

@bakito
Copy link
Copy Markdown
Contributor

@bakito bakito commented Sep 19, 2024

Description of your changes

When a MSSQL user is created in a database other than the master database. The USER needs to created in the dedicated database, but the LOGIN needs to be created in the master database.

This is also mentioned here: #158 (comment)

This pull request adds the possibility to define an additional database, where the login object is created in.
The already existing database fields are used for the user statements.

If the newly introduced loginDatabase is not set, the database field is used for both operations as before.

Fixes #158

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

The application was built and deployed in an existing cluster. Where the User rewource was configured to use the loginDatabase: master and databaseRef that is pointing to a Database resource.

apiVersion: mssql.sql.crossplane.io/v1alpha1
kind: User
metadata:
  name: sql-example-user
spec:
  forProvider:
    loginDatabase: master
    databaseRef:
      name: test-db
    passwordSecretRef:
      key: password
      name: sql-example-user-pw
      namespace: crossplane-system
  writeConnectionSecretToRef:
    name: sql-example-user-connection-secret
    namespace: crossplane-system

Signed-off-by: bakito <github@bakito.ch>
@bakito
Copy link
Copy Markdown
Contributor Author

bakito commented Nov 3, 2024

@turkenh sorry to bother you, but who can review this PR?

@bakito
Copy link
Copy Markdown
Contributor Author

bakito commented Nov 28, 2024

@Duologic thank you for approving the pipeline. I updated the branch to hopefully also get the publish-artifacts action become green.

Could you please re-approve the pipelines to run?

thx

@Duologic Duologic merged commit 414c206 into crossplane-contrib:master Nov 28, 2024
@bakito bakito deleted the login-db branch November 28, 2024 12:44
markphillips100 added a commit to markphillips100/provider-sql that referenced this pull request Jun 16, 2025
* Refresh build system - update to latest Go, Up, crossplane-runtime etc (crossplane-contrib#182)

* go get github.com/crossplane/crossplane-tools@master && go mod tidy && make generate

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Add latest crossplane-runtime (including managementPolicies)

go get github.com/crossplane/crossplane-runtime@latest && go mod tidy && make generate

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Update controller-runtime API after breaking changes upstream

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Bump build/ and up version to be compatible with newer docker

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Avoid deprecated k8s.io/utils/pointer

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Bump Go to 1.21, golangci-linter to 1.54 (match build/)

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Integration test: Set registry to xpkg.upbound.io/

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Integration test: OS for Kind is always Linux

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

---------

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* PostgreSQL CREATE SCHEMA support (crossplane-contrib#181)

* Schema controller for PostgreSQL

This adds support for CREATE SCHEMA (not any DDL like Schema hero).
This is needed to run third party solutions that require the schema
to exist, like grafana operator and temporal operator.

Co-authored-by: Lars Haugan <456305+larhauga@users.noreply.github.com>
Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Generate files for PostgreSQL Schema

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Expand PostgreSQL config example to include secret and ssl mode, docker info

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Avoid new(string) and use nicer ptr.To values in test

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

---------

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
Co-authored-by: Lars Haugan <456305+larhauga@users.noreply.github.com>

* chore: add provider install documentation (crossplane-contrib#174)

Signed-off-by: Bastien CERIANI <bastien.ceriani@gmail.com>

* Give MySQL sql_log_bin at DSN level to take parameter into account (crossplane-contrib#171)

Signed-off-by: Florian Gaillot <fgaillot@qosenergy.com>

* change the host with endpoint to make it worked

Signed-off-by: Batuhan Apaydin <batuhan.apaydin@chainguard.dev>

* ci: fix upload-artifact ref

* allow to define login db (crossplane-contrib#192)

Signed-off-by: bakito <github@bakito.ch>

* add support for mssql schema in grants (crossplane-contrib#193)

Signed-off-by: bakito <github@bakito.ch>

* optional binlog parameters in mysql connection string to allow the use of DB default setting (crossplane-contrib#201)

Signed-off-by: Marius Leahu <Marius.Leahu@swisscom.com>

* fix: remove unneeded flush privileges call for mysql (crossplane-contrib#202)

Signed-off-by: Marius Ziemke <marius@ziemke.net>
Co-authored-by: Marius Ziemke <marius@ziemke.net>

* feat: add custom tls config support to mysql (crossplane-contrib#184)

* feat: add custom tls config support

Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>

* use provider config name to make tls name unique

Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>

* refactor integration tests into modular functions

Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>

---------

Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>
Co-authored-by: Mathieu Frenette <silphid@users.noreply.github.com>

* refactor(mysql): consistent username/host parameters (crossplane-contrib#205)

Signed-off-by: Duologic <jeroen@simplistic.be>

* chore: update build/, Makefile and integration test script (crossplane-contrib#204)

Signed-off-by: Duologic <jeroen@simplistic.be>

* feat(postgresql): add revoke public logic to grant and schema resources (crossplane-contrib#207)

- added a field called revokePublicOnDb in grant resource; if true, it will revoke from public access to DB; This usually a DBA requirement.
- added a field called revokePublicOnSchema in schema resource; if true, it will revoke from public access to a schema; This usually a DBA requirement.

Signed-off-by: oliver.zokra <oliver.zokra@kyriba.com>

* test(postgresql): implement postgresdb integration tests (crossplane-contrib#208)

Signed-off-by: oliver.zokra <oliver.zokra@kyriba.com>

* update helm repo before intalling mariadb (crossplane-contrib#209)

Signed-off-by: oliver.zokra <oliver.zokra@kyriba.com>

* chore: add chlunde to maintainers list (crossplane-contrib#225)

Signed-off-by: Duologic <jeroen@simplistic.be>

* bump github actions upload-action to latest release due to deprecation

Signed-off-by: Lars Haugan <lars.haugan@sparebank1.no>

* chore: bump golangci version (crossplane-contrib#216)

* chore: bump golangci

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: bump golangci on github actions workflow

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: bump golangci up to v2, bump up all action dependencies

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: even more actions pinned

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

---------

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: Update Go to 1.23.9 (crossplane-contrib#230)

Go 1.23.9 is a security update, and we also need to update
Go to get dependabot security updates out (dependabot does not
run 'go mod tidy').

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* Bump golang.org/x/crypto from 0.21.0 to 0.35.0 (crossplane-contrib#229)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.21.0 to 0.35.0.
- [Commits](golang/crypto@v0.21.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.35.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump golang.org/x/net from 0.25.0 to 0.38.0 (crossplane-contrib#231)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.25.0 to 0.38.0.
- [Commits](golang/net@v0.25.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump google.golang.org/protobuf from 1.31.0 to 1.33.0 (crossplane-contrib#232)

Bumps google.golang.org/protobuf from 1.31.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-version: 1.33.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: enable management policies (crossplane-contrib#215)

* fix: enable management policies

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* fix: linter

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: offload lint changes to crossplane-contrib#216

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: revert changes as per peer review

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

---------

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* Move negz to emeritus status (crossplane-contrib#226)

As requested on slack

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* test: add coverage of managementPolicies to e2e (crossplane-contrib#233)

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>

* chore: remove duplicate entry of golangci version (crossplane-contrib#236)

* chore: remove duplicate entry of golangci version

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: bump up versions for crossplane 1.20

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* chore: restore changes

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

---------

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>

* Refactor

* Revert to previous usertype contants

---------

Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
Signed-off-by: Bastien CERIANI <bastien.ceriani@gmail.com>
Signed-off-by: Florian Gaillot <fgaillot@qosenergy.com>
Signed-off-by: Batuhan Apaydin <batuhan.apaydin@chainguard.dev>
Signed-off-by: bakito <github@bakito.ch>
Signed-off-by: Marius Leahu <Marius.Leahu@swisscom.com>
Signed-off-by: Marius Ziemke <marius@ziemke.net>
Signed-off-by: Mathieu Frenette <silphid@users.noreply.github.com>
Signed-off-by: Duologic <jeroen@simplistic.be>
Signed-off-by: oliver.zokra <oliver.zokra@kyriba.com>
Signed-off-by: Lars Haugan <lars.haugan@sparebank1.no>
Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
Co-authored-by: Lars Haugan <456305+larhauga@users.noreply.github.com>
Co-authored-by: Bastien Cer <bastien.ceriani@gmail.com>
Co-authored-by: fgaillot-qosenergy <67331418+fgaillot-qosenergy@users.noreply.github.com>
Co-authored-by: Batuhan Apaydin <batuhan.apaydin@chainguard.dev>
Co-authored-by: Hasan Turken <turkenh@gmail.com>
Co-authored-by: Duologic <jeroen@simplistic.be>
Co-authored-by: Marc Brugger <github@bakito.ch>
Co-authored-by: Marius Leahu <11443917+mleahu@users.noreply.github.com>
Co-authored-by: Marius Ziemke <marius@ziemke.net>
Co-authored-by: Mathieu Frenette <1917993+silphid@users.noreply.github.com>
Co-authored-by: Mathieu Frenette <silphid@users.noreply.github.com>
Co-authored-by: olikyr <oliver.zokra@kyriba.com>
Co-authored-by: Lars Haugan <lars.haugan@sparebank1.no>
Co-authored-by: J. Fernández <7312236+fernandezcuesta@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
xocasdashdash pushed a commit to xocasdashdash/provider-sql that referenced this pull request Feb 11, 2026
Signed-off-by: bakito <github@bakito.ch>
Signed-off-by: Joaquín Fernández Campo <xocasdashdash@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSSQL database user

2 participants