Comments (1)
Hi @karl-johan-grahn
I'd like to work on this enhancement. I have gone through the relevant code and my analysis is as follows.
Cause of this panic
In
Forecastle/pkg/kube/wrappers/ingress.go
Line 103 in 53888ad
Hosts
slice is empty and therefore attempting to access Hosts[0]
causes the runtime panic.
What can be done to make this access safe
Add a new method getTLSHosts
on the IngressWrapper
:
func (iw *IngressWrapper) getTLSHosts() []string {
if iw.supportsTLS() {
return iw.ingress.Spec.TLS[0].Hosts
}
return []string{}
}
Similarly change the method tryGetTLSHost
to:
func (iw *IngressWrapper) tryGetTLSHost() (string, bool) {
if iw.supportsTLS() && len(iw.getTLSHosts()) > 0 {
return "https://" + iw.ingress.Spec.TLS[0].Hosts[0], true
}
return "", false
}
Test cases
In https://github.com/stakater/Forecastle/blob/master/pkg/testutil/kube.go add the following function to simulate a case where TLS hosts is empty:
func CreateIngressWithHostAndEmptyTLSHost(name string, host string) *v1.Ingress {
ingress := CreateIngressWithHost(name, host)
ingress.Spec.TLS = []v1.IngressTLS{
{
Hosts: []string{},
},
}
return ingress
}
Add the following test case in
Forecastle/pkg/kube/wrappers/ingress_test.go
Line 251 in 53888ad
{
name: "IngressWithTLSAndNoHosts",
fields: fields{
ingress: testutil.CreateIngressWithHostAndEmptyTLSHost("someIngress", "google.com"),
},
want: "",
want1: false,
},
Let me know what do you think about this.
from forecastle.
Related Issues (20)
- Add support for changing the page title HOT 4
- Migrating from ingress networking.k8s.io/v1beta1 to /v1 HOT 10
- Feature request - change forcastle root path
- Add link to group
- Results couldn't be loaded due to an error HOT 11
- Feature Request : Traefik IngressRoute / IngressRouteTCP
- broken pipe when many apps HOT 1
- Support searching from anywhere
- no matches for kind "Route" in version "route.openshift.io/v1" HOT 5
- Deploy and remove from the launchpad HOT 2
- Regression in helm chart rbac for ForecastleApp HOT 2
- Feature request: Add a description field / external URL's
- Dependency Dashboard
- 1.0.130 does not work anymore. (empty page) HOT 4
- [ENHANCE]: Add helm repo to documentation HOT 1
- [BUG] Forecastle fails on empty TLS field in ingress HOT 1
- [BUG] Icons don't get displayed HOT 4
- [BUG] the chart creates a duplicate security context under certain conditions HOT 2
- [ENHANCE] forecastle should read the ingress host from the status instead of the spec HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forecastle.