Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Mar 6, 2024
1 parent 856f0f8 commit 57f3fd9
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 23 deletions.
7 changes: 5 additions & 2 deletions pkg/controllers/bucketController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -35,14 +36,16 @@ func BucketController(
case "delete":
fluxState, err := flux.State(client, dynamicClient)
if err != nil {
panic(err.Error())
logrus.Warnf("could not get flux state: %s", err)
return nil
}
fluxStateBytes, err := json.Marshal(streaming.Envelope{
Type: streaming.FLUX_STATE_RECEIVED,
Payload: fluxState,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- fluxStateBytes
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/controllers/deploymentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"

"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
apps_v1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -32,7 +33,8 @@ func DeploymentController(
Payload: createdDeployment,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- deploymentBytes
case "update":
Expand All @@ -42,7 +44,8 @@ func DeploymentController(
Payload: deployment,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- deploymentBytes
case "delete":
Expand All @@ -51,7 +54,8 @@ func DeploymentController(
Payload: informerEvent.key,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- deploymentBytes
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/controllers/eventController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -42,7 +43,8 @@ func EventController(
Payload: events,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- eventBytes
return nil
Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/gitrepositoryController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -35,14 +36,16 @@ func GitRepositoryController(
case "delete":
fluxState, err := flux.State(client, dynamicClient)
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
fluxStateBytes, err := json.Marshal(streaming.Envelope{
Type: streaming.FLUX_STATE_RECEIVED,
Payload: fluxState,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- fluxStateBytes
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/helmreleaseController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -35,14 +36,16 @@ func HelmReleaseController(
case "delete":
fluxState, err := flux.State(client, dynamicClient)
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
fluxStateBytes, err := json.Marshal(streaming.Envelope{
Type: streaming.FLUX_STATE_RECEIVED,
Payload: fluxState,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- fluxStateBytes
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/controllers/ingressController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"

"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
networking_v1 "k8s.io/api/networking/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -32,7 +33,8 @@ func IngressController(
Payload: createdIngress,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- ingressBytes
case "update":
Expand All @@ -42,7 +44,8 @@ func IngressController(
Payload: ingress,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- ingressBytes
case "delete":
Expand All @@ -51,7 +54,8 @@ func IngressController(
Payload: informerEvent.key,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- ingressBytes
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/kustomizationController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -35,14 +36,16 @@ func KustomizeController(
case "delete":
fluxState, err := flux.State(client, dynamicClient)
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
fluxStateBytes, err := json.Marshal(streaming.Envelope{
Type: streaming.FLUX_STATE_RECEIVED,
Payload: fluxState,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- fluxStateBytes
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/controllers/ocirepositoryController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gimlet-io/capacitor/pkg/flux"
"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -35,14 +36,16 @@ func OciRepositoryController(
case "delete":
fluxState, err := flux.State(client, dynamicClient)
if err != nil {
panic(err.Error())
logrus.Warnf("could not get flux state: %s", err)
return nil
}
fluxStateBytes, err := json.Marshal(streaming.Envelope{
Type: streaming.FLUX_STATE_RECEIVED,
Payload: fluxState,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- fluxStateBytes
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/controllers/podController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"

"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -31,7 +32,8 @@ func PodController(
Payload: createdPod,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- podBytes
case "update":
Expand All @@ -41,7 +43,8 @@ func PodController(
Payload: pod,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- podBytes
case "delete":
Expand All @@ -50,7 +53,8 @@ func PodController(
Payload: informerEvent.key,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- podBytes
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/controllers/serviceController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"

"github.com/gimlet-io/capacitor/pkg/streaming"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -31,7 +32,8 @@ func ServiceController(
Payload: createdService,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- serviceBytes
case "update":
Expand All @@ -41,7 +43,8 @@ func ServiceController(
Payload: service,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- serviceBytes
case "delete":
Expand All @@ -50,7 +53,8 @@ func ServiceController(
Payload: informerEvent.key,
})
if err != nil {
panic(err.Error())
logrus.Warnf("could not marshal event: %s", err)
return nil
}
clientHub.Broadcast <- serviceBytes
}
Expand Down
1 change: 1 addition & 0 deletions web/src/Service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export function Pod(props) {
color = 'bg-blue-300';
pulsar = 'animate-pulse';
break;
case 'Succeeded':
case 'Terminating':
color = 'bg-neutral-500';
pulsar = 'animate-pulse';
Expand Down
3 changes: 3 additions & 0 deletions web/src/redux.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export function rootReducer(state = initialState, action) {
case ACTION_SERVICE_DELETED:
return serviceEventHandlers.serviceDeleted(state, action.payload)
default:
if (action.type && action.type.startsWith('@@redux/INIT')) { // Ignoring Redux ActionTypes.INIT action
return state
}
console.log('Could not process redux event: ' + JSON.stringify(action));
return state;
}
Expand Down

0 comments on commit 57f3fd9

Please sign in to comment.