Skip to content

Commit

Permalink
Fix incorrect encoding of health endpoint (#618)
Browse files Browse the repository at this point in the history
* Fix incorrect encoding of health endpoint
  • Loading branch information
karl-johan-grahn authored Dec 17, 2024
1 parent 94c1bbb commit de25bb8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 24 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ env:
DOCKER_FILE_PATH: Dockerfile
GOLANG_VERSION: 1.21
HELM_VERSION: v3.8.2
KIND_VERSION: "v0.17.0"
REGISTRY: ghcr.io

jobs:
Expand Down Expand Up @@ -50,27 +49,6 @@ jobs:
run: |
helm lint charts/ingressmonitorcontroller
# - name: Install kind
# uses: engineerd/setup-kind@v0.5.0
# with:
# version: ${{ env.KIND_VERSION }}

# - name: Check cluster info
# run: |
# kubectl version --client
# kind version
# kind version | grep -q ${KIND_VERSION}

# - name: Set up Cluster
# run: |
# kubectl cluster-info
# make install
# mkdir -p .local
# echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml

# - name: Test
# run: make test

- name: Generate Tag
id: generate_tag
run: |
Expand Down Expand Up @@ -107,5 +85,4 @@ jobs:
${{ env.GHCR_IMAGE_REPOSITORY }}:${{ steps.generate_tag.outputs.GIT_TAG }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
61 changes: 61 additions & 0 deletions .github/workflows/pull_request_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Run Tests on PR Label

on:
pull_request:
branches:
- 'master'
paths-ignore:
- '*.md'
- 'docs/'
- 'examples/'
- 'hack/'
- 'config/'
types: [ labeled ]

env:
KIND_VERSION: "v0.25.0"
GOLANG_VERSION: 1.21

jobs:

test:
runs-on: ubuntu-latest
name: Test
if: ${{ github.event.label.name == 'ok-to-test' }}
steps:

- name: Remove the test label
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: ok-to-test

- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GOLANG_VERSION }}

- name: Install kind
uses: engineerd/setup-kind@v0.5.0
with:
version: ${{ env.KIND_VERSION }}

- name: Check cluster info
run: |
kubectl version --client
kind version
kind version | grep -q ${KIND_VERSION}
- name: Set up Cluster
run: |
kubectl cluster-info
make install
mkdir -p .local
echo "${{ secrets.IMC_GITHUB_PIPELINE_CONFIG_ENCODED }}" | base64 --decode > .local/test-config.yaml
- name: Test
run: make test
7 changes: 6 additions & 1 deletion pkg/kube/wrappers/routeWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,10 @@ func (rw *RouteWrapper) GetURL(forceHttps bool, healthEndpoint string) string {
u.Path = path.Join(u.Path, healthEndpoint)
}
}
return u.String()
path, err := url.PathUnescape(u.String())
if err != nil {
log.Info(fmt.Sprintf("Error in unescaping path :%v", err))
return ""
}
return path
}
8 changes: 8 additions & 0 deletions pkg/kube/wrappers/routeWrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func TestRouteWrapper_getURL(t *testing.T) {
},
want: "http://testurl.stackator.com/hello",
},
{
name: "TestGetUrlWithParams",
fields: fields{
route: createRouteObjectWithPath("testRoute", "test", routeTestUrl, "/health?standbyok=true&sealedcode=204&uninitcode=204"),
Client: fakekubeclient.NewClientBuilder().Build(),
},
want: "http://testurl.stackator.com/health?standbyok=true&sealedcode=204&uninitcode=204",
},
{
name: "TestGetUrlWithNoPath",
fields: fields{
Expand Down

0 comments on commit de25bb8

Please sign in to comment.