-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 78-enhancement-suspen…
…d-resume-buttons
- Loading branch information
Showing
24 changed files
with
414 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package controllers | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"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" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
var helmChartResource = schema.GroupVersionResource{ | ||
Group: "source.toolkit.fluxcd.io", | ||
Version: "v1beta2", | ||
Resource: "helmcharts", | ||
} | ||
|
||
func HelmChartController( | ||
client *kubernetes.Clientset, | ||
dynamicClient *dynamic.DynamicClient, | ||
clientHub *streaming.ClientHub, | ||
) (*Controller, error) { | ||
return NewDynamicController( | ||
"helmcharts.source.toolkit.fluxcd.io", | ||
dynamicClient, | ||
helmChartResource, | ||
func(informerEvent Event, objectMeta metav1.ObjectMeta, obj interface{}) error { | ||
switch informerEvent.eventType { | ||
case "create": | ||
fallthrough | ||
case "update": | ||
fallthrough | ||
case "delete": | ||
fluxState, err := flux.State(client, dynamicClient) | ||
if err != nil { | ||
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 { | ||
logrus.Warnf("could not marshal event: %s", err) | ||
return nil | ||
} | ||
clientHub.Broadcast <- fluxStateBytes | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package controllers | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"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" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
var helmRepositoryResource = schema.GroupVersionResource{ | ||
Group: "source.toolkit.fluxcd.io", | ||
Version: "v1beta2", | ||
Resource: "helmrepositories", | ||
} | ||
|
||
func HelmRepositoryController( | ||
client *kubernetes.Clientset, | ||
dynamicClient *dynamic.DynamicClient, | ||
clientHub *streaming.ClientHub, | ||
) (*Controller, error) { | ||
return NewDynamicController( | ||
"helmrepositories.source.toolkit.fluxcd.io", | ||
dynamicClient, | ||
helmRepositoryResource, | ||
func(informerEvent Event, objectMeta metav1.ObjectMeta, obj interface{}) error { | ||
switch informerEvent.eventType { | ||
case "create": | ||
fallthrough | ||
case "update": | ||
fallthrough | ||
case "delete": | ||
fluxState, err := flux.State(client, dynamicClient) | ||
if err != nil { | ||
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 { | ||
logrus.Warnf("could not marshal event: %s", err) | ||
return nil | ||
} | ||
clientHub.Broadcast <- fluxStateBytes | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.