Skip to content

Commit

Permalink
Fix required execute option for reset-password command (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier authored Oct 31, 2024
1 parent 59dd3ce commit b9bfb3d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/hotfix_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Hotfix Branch

on:
workflow_dispatch:
inputs:
tag_version:
description: 'Tag version'
required: true

jobs:
create-branch:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
token: ${{ secrets.CI_CD_TOKEN }}

- name: Create hotfix branch
run: |
START_TAG=v${{ github.event.inputs.tag_version }}
echo "Start from tag $START_TAG"
MAJOR_MINOR_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 1-2)
PATCH_DIGIT=$(echo "$START_TAG" | cut -d '.' -f 3)
NEW_PATCH_DIGIT=$((PATCH_DIGIT + 1))
HOTFIX_VERSION="${MAJOR_MINOR_DIGIT}.${NEW_PATCH_DIGIT}"
HOTFIX_BRANCH_NAME="hotfix/$HOTFIX_VERSION"
echo "Create hotfix branch $HOTFIX_BRANCH_NAME"
git fetch --all
git checkout tags/$START_TAG -b $HOTFIX_BRANCH_NAME
git push origin $HOTFIX_BRANCH_NAME
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Pull request

on:
pull_request:
branches: [ main ]
branches: [ main, hotfix/* ]

jobs:
build-jar:
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/on_push_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ jobs:
report_paths: '**/build/test-results/test/TEST-*.xml'

- name: Docker
run: ./gradlew dockerBuild dockerPush -PreleaseLatest
run: |
LATEST_VERSION=$(git tag -l --sort=-version:refname | head -1 | cut -d 'v' -f 2)
if [ "$LATEST_VERSION" == "${{ steps.build_jar.outputs.current_version }}" ]; then
echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Pushing latest tag."
./gradlew dockerBuild dockerPush -PreleaseLatest
else
echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Not pushing latest tag."
./gradlew dockerBuild dockerPush
fi
- name: Generate release changelog
uses: mikepenz/release-changelog-builder-action@v5
Expand Down Expand Up @@ -100,7 +108,15 @@ jobs:
echo current_version=$(echo $(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')) >> $GITHUB_OUTPUT
- name: Docker
run: ./gradlew dockerBuildNative dockerPushNative -PreleaseLatest
run: |
LATEST_VERSION=$(git tag -l --sort=-version:refname | head -1 | cut -d 'v' -f 2)
if [ "$LATEST_VERSION" == "${{ steps.build_jar.outputs.current_version }}" ]; then
echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Pushing latest tag."
./gradlew dockerBuildNative dockerPushNative -PreleaseLatest
else
echo "Latest version is $LATEST_VERSION. Current version is ${{ steps.build_jar.outputs.current_version }}. Not pushing latest tag."
./gradlew dockerBuildNative dockerPushNative
fi
- name: Generate release changelog
uses: mikepenz/release-changelog-builder-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
tag:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/hotfix/v')
steps:
- name: Checkout project
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public Integer onAuthSuccess() throws IOException {
+ "for the namespace " + namespace + ".\n"
+ "Active connections will be killed instantly.\n\n"
+ "To execute this operation, rerun the command with option --execute.");
return 0;
}

return resourceService.resetPassword(namespace, user, output, commandSpec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -104,6 +105,7 @@ void shouldNotUpdateUserWhenNotConfirmed() {
assertTrue(sw.toString().contains("You are about to change your Kafka password for the namespace namespace."));
assertTrue(sw.toString().contains("Active connections will be killed instantly."));
assertTrue(sw.toString().contains("To execute this operation, rerun the command with option --execute."));
verify(resourceService, never()).resetPassword(any(), any(), any(), any());
}

@Test
Expand Down

0 comments on commit b9bfb3d

Please sign in to comment.