Skip to content

Commit

Permalink
Add watching mechanism to watch on caBundle for core interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
savitaashture authored and tekton-robot committed Jul 27, 2022
1 parent c8a0436 commit d460f02
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions cmd/interceptors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,24 @@ func main() {
if err != nil {
return
}

clusterInterceptorList, err := clusterinterceptorsinformer.Get(ctx).Lister().List(labels.NewSelector())
if err != nil {
return
}

if err := service.UpdateCRDWithCaCert(ctx, tc.TriggersV1alpha1(), clusterInterceptorList, caCert); err != nil {
if err := listAndUpdateClusterInterceptorCRD(ctx, tc, service, caCert); err != nil {
return
}
ticker := time.NewTicker(time.Minute)
quit := make(chan struct{})
go func() {
for {
select {
case <-ticker.C:
if err := listAndUpdateClusterInterceptorCRD(ctx, tc, service, caCert); err != nil {
return
}
case <-quit:
ticker.Stop()
return
}
}
}()

srv := &http.Server{
Addr: fmt.Sprintf(":%d", HTTPSPort),
Expand All @@ -121,3 +130,15 @@ func main() {
func handler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}

func listAndUpdateClusterInterceptorCRD(ctx context.Context, tc *triggersclientset.Clientset, service *server.Server, caCert []byte) error {
clusterInterceptorList, err := clusterinterceptorsinformer.Get(ctx).Lister().List(labels.NewSelector())
if err != nil {
return err
}

if err := service.UpdateCRDWithCaCert(ctx, tc.TriggersV1alpha1(), clusterInterceptorList, caCert); err != nil {
return err
}
return nil
}

0 comments on commit d460f02

Please sign in to comment.