-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'multitenancy_main' into feature/790_members_einladen
- Loading branch information
Showing
113 changed files
with
3,500 additions
and
1,501 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,42 +97,24 @@ jobs: | |
- name: Push | ||
run: docker push ${{ needs.extract-version.outputs.okr-docker-image}} | ||
|
||
- name: Trigger Deployment Workflow with latest Version | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ vars.TARGET_REPOSITORY }} | ||
ref: ${{ vars.TARGET_REFERENCE }} | ||
path: ccy-repo | ||
token: ${{secrets.VERSION_TOKEN}} | ||
|
||
- name: Change Yaml | ||
- name: Install yq | ||
shell: bash | ||
env: | ||
FILEPATH: ${{ vars.FILEPATH }} | ||
YAMLPATH: ${{ vars.YAML_PATH }} | ||
NEWVALUE: ${{ needs.extract-version.outputs.okr-docker-image}} | ||
VERSION: v4.25.2 | ||
BINARY: yq_linux_amd64 | ||
run: | | ||
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | ||
tar xz && mv ${BINARY} /usr/local/bin/yq | ||
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH} | ||
- name: Commit and Push Changes | ||
working-directory: ccy-repo | ||
- name: Update YAML file | ||
shell: bash | ||
env: | ||
COMMITPREFIX: '[CTS]' | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
git add ${{ vars.FILEPATH }} || { | ||
echo "No files were changed, so we did not commit anything" | ||
exit 1 | ||
} && \ | ||
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \ | ||
git push origin ${{ vars.TARGET_REFERENCE }} | ||
- run: rm -rf ccy-repo | ||
shell: bash | ||
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml | ||
yq -i "${{vars.YAML_PATH}} = \"${{needs.extract-version.outputs.okr-docker-image}}\"" response.yaml | ||
UPDATED_CONTENT=$(cat response.yaml) | ||
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}" | ||
generate-and-push-sbom: | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
|
@@ -179,44 +179,24 @@ jobs: | |
- name: Push | ||
run: docker push ${{ needs.update-version.outputs.okr-docker-image}} | ||
|
||
- name: Trigger Deployment Workflow with latest Version | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ vars.TARGET_REPOSITORY }} | ||
ref: ${{ vars.TARGET_REFERENCE }} | ||
path: ccy-repo | ||
token: ${{secrets.VERSION_TOKEN}} | ||
|
||
- name: Change Yaml | ||
- name: Install yq | ||
shell: bash | ||
env: | ||
FILEPATH: ${{ vars.FILEPATH }} | ||
YAMLPATH: ${{ vars.YAML_PATH }} | ||
NEWVALUE: ${{ needs.update-version.outputs.okr-docker-image}} | ||
VERSION: v4.25.2 | ||
BINARY: yq_linux_amd64 | ||
run: | | ||
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | ||
tar xz && mv ${BINARY} /usr/local/bin/yq | ||
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH} | ||
- name: Commit and Push Changes | ||
working-directory: ccy-repo | ||
- name: Update YAML file | ||
shell: bash | ||
env: | ||
COMMITPREFIX: '[CTS]' | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
git add ${{ vars.FILEPATH }} || { | ||
echo "No files were changed, so we did not commit anything" | ||
exit 1 | ||
} && \ | ||
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \ | ||
git push origin ${{ vars.TARGET_REFERENCE }} | ||
- run: rm -rf ccy-repo | ||
shell: bash | ||
curl -s --header "PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml | ||
yq -i "${{vars.YAML_PATH}} = \"${{needs.update-version.outputs.okr-docker-image}}\"" response.yaml | ||
UPDATED_CONTENT=$(cat response.yaml) | ||
curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}" | ||
generate-and-push-sbom: | ||
runs-on: ubuntu-latest | ||
|
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
22 changes: 22 additions & 0 deletions
22
backend/src/main/java/ch/puzzle/okr/FlywayMultitenantConfig.java
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,22 @@ | ||
package ch.puzzle.okr; | ||
|
||
import ch.puzzle.okr.multitenancy.FlywayMultitenantMigrationInitializer; | ||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; | ||
import org.springframework.cache.interceptor.KeyGenerator; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FlywayMultitenantConfig { | ||
|
||
@Bean | ||
public FlywayMigrationStrategy cleanMigrateStrategy(FlywayMultitenantMigrationInitializer flywayMigration) { | ||
return flyway -> flywayMigration.migrateFlyway(); | ||
} | ||
|
||
@Bean("customKeyGenerator") | ||
public KeyGenerator keyGenerator() { | ||
return new UserKeyGenerator(); | ||
} | ||
|
||
} |
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,16 @@ | ||
package ch.puzzle.okr; | ||
|
||
import ch.puzzle.okr.models.User; | ||
import ch.puzzle.okr.multitenancy.TenantContext; | ||
import org.springframework.cache.interceptor.KeyGenerator; | ||
|
||
import java.lang.reflect.Method; | ||
import java.text.MessageFormat; | ||
|
||
public class UserKeyGenerator implements KeyGenerator { | ||
@Override | ||
public Object generate(Object target, Method method, Object... params) { | ||
User user = (User) params[0]; | ||
return MessageFormat.format("{0}{1}{2}", TenantContext.getCurrentTenant(), user.getEmail(), user.getId()); | ||
} | ||
} |
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
Oops, something went wrong.