Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect encoding of health endpoint #618

Merged
merged 16 commits into from
Dec 17, 2024
40 changes: 20 additions & 20 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,26 @@ 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: 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
Expand Down
6 changes: 3 additions & 3 deletions pkg/kube/wrappers/routeWrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@
}

if len(healthEndpoint) != 0 {
u.Path = healthEndpoint
u.EscapedPath = healthEndpoint

Check failure on line 119 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)

Check failure on line 119 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)
} else {
// Append subpath
u.Path = path.Join(u.Path, rw.getRouteSubPath())
u.EscapedPath = path.Join(u.EscapedPath, rw.getRouteSubPath())

Check failure on line 122 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)

Check failure on line 122 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot use u.EscapedPath (value of type func() string) as string value in argument to path.Join

Check failure on line 122 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)

Check failure on line 122 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot use u.EscapedPath (value of type func() string) as string value in argument to path.Join

// Find pod by backtracking route -> service -> pod
healthEndpoint, exists := rw.tryGetHealthEndpointFromRoute()

// Health endpoint from pod successful
if exists {
u.Path = path.Join(u.Path, healthEndpoint)
u.EscapedPath = path.Join(u.EscapedPath, healthEndpoint)

Check failure on line 129 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)

Check failure on line 129 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot use u.EscapedPath (value of type func() string) as string value in argument to path.Join) (typecheck)

Check failure on line 129 in pkg/kube/wrappers/routeWrapper.go

View workflow job for this annotation

GitHub Actions / Pull Request

cannot assign to u.EscapedPath (neither addressable nor a map index expression)
}
}
return u.String()
Expand Down
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
Loading