Skip to content

Commit

Permalink
ci fix
Browse files Browse the repository at this point in the history
1. lint fix
2. remove commented code from app_directory
3. app and appset watcher to check kubeCfg is not nil
4. add comment to the docs
  • Loading branch information
Greyeye committed Jul 15, 2024
1 parent 6bf6b35 commit 18cbf67
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion charts/kubechecks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ autoscaling:
# targetMemoryUtilizationPercentage: 80

clusterRoleBinding:
argocdApiNamespace: "argocd" # argocd's namespace, if not specified, uses kubecheck's full name
# Namespace for ArgoCD API. If not specified, uses kubecheck's full name.
argocdApiNamespace: "argocd"
2 changes: 2 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ The final piece of the puzzle is the `CheckEvent`; an internal structure that ta

![Event Flow Diagram](./img/eventflowdiagram.png){: style="height:350px;display:block;margin:0 auto;"}

This diagram illustrates the flow of events from the initial webhook trigger to the final report generation and comment update process.

2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The full list of supported environment variables is described below:
|`KUBECHECKS_KUBERNETES_CLUSTER_REGION`|Kubernetes Cluster Region, if the cluster is on a cloud provider, and running on a different region, this must be specified.||
|`KUBECHECKS_KUBERNETES_CLUSTERID`|Kubernetes Cluster ID, must be specified if kubernetes-type is eks.||
|`KUBECHECKS_KUBERNETES_CONFIG`|Path to your kubernetes config file, used to monitor applications.||
|`KUBECHECKS_KUBERNETES_TYPE`|Kubernetes Type One of eks, gks, aks, localhost or managed.|`localhost`|
|`KUBECHECKS_KUBERNETES_TYPE`|Kubernetes Type One of eks, or localhost.|`localhost`|
|`KUBECHECKS_LABEL_FILTER`|(Optional) If set, The label that must be set on an MR (as "kubechecks:<value>") for kubechecks to process the merge request webhook.||
|`KUBECHECKS_LOG_LEVEL`|Set the log output level. One of error, warn, info, debug, trace.|`info`|
|`KUBECHECKS_MAX_CONCURRENCT_CHECKS`|Number of concurrent checks to run.|`32`|
Expand Down
5 changes: 4 additions & 1 deletion pkg/app_watcher/app_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app_watcher

import (
"context"
"fmt"
"reflect"
"strings"
"time"
Expand Down Expand Up @@ -30,7 +31,9 @@ type ApplicationWatcher struct {

// NewApplicationWatcher creates new instance of ApplicationWatcher.
func NewApplicationWatcher(kubeCfg *rest.Config, vcsToArgoMap appdir.VcsToArgoMap, cfg config.ServerConfig) (*ApplicationWatcher, error) {

if kubeCfg == nil {
return nil, fmt.Errorf("kubeCfg cannot be nil")
}
ctrl := ApplicationWatcher{
applicationClientset: appclientset.NewForConfigOrDie(kubeCfg),
vcsToArgoMap: vcsToArgoMap,
Expand Down
4 changes: 4 additions & 0 deletions pkg/app_watcher/appset_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app_watcher

import (
"context"
"fmt"
"reflect"
"time"

Expand All @@ -28,6 +29,9 @@ type ApplicationSetWatcher struct {

// NewApplicationSetWatcher creates new instance of ApplicationWatcher.
func NewApplicationSetWatcher(kubeCfg *rest.Config, vcsToArgoMap appdir.VcsToArgoMap, cfg config.ServerConfig) (*ApplicationSetWatcher, error) {
if kubeCfg == nil {
return nil, fmt.Errorf("kubeCfg cannot be nil")
}
ctrl := ApplicationSetWatcher{
applicationClientset: appclientset.NewForConfigOrDie(kubeCfg),
vcsToArgoMap: vcsToArgoMap,
Expand Down
7 changes: 1 addition & 6 deletions pkg/appdir/app_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,12 @@ func (d *AppDirectory) ProcessApp(app v1alpha1.Application) {
// returns the list of applications that are affected by the changes.
//
// e.g. changeList = ["path/to/file1", "path/to/file2"]
func (d *AppDirectory) FindAppsBasedOnChangeList(changeList []string, targetBranch string, repo *git.Repo) []v1alpha1.Application {
func (d *AppDirectory) FindAppsBasedOnChangeList(changeList []string, targetBranch string, _ *git.Repo) []v1alpha1.Application {
log.Debug().Msgf("checking %d changes", len(changeList))

appsSet := make(map[string]struct{})
for _, changePath := range changeList {
log.Debug().Msgf("change: %s", changePath)
//absPath := filepath.Join(repo.Directory, changePath)
//if containsKindApplicationSet(absPath) {
// log.Debug().Msgf("skipping %s because it is an ApplicationSet", changePath)
// continue
//}
for dir, appNames := range d.appDirs {
if strings.HasPrefix(changePath, dir) {
log.Debug().Msg("dir match!")
Expand Down
5 changes: 3 additions & 2 deletions pkg/events/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"fmt"
"sync/atomic"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/rs/zerolog"
"github.com/zapier/kubechecks/pkg"
Expand All @@ -14,8 +17,6 @@ import (
"github.com/zapier/kubechecks/pkg/git"
"github.com/zapier/kubechecks/pkg/msg"
"github.com/zapier/kubechecks/telemetry"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

type worker struct {
Expand Down
9 changes: 2 additions & 7 deletions pkg/generator/interface.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package generator

import (
"fmt"
"time"

argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/pkg/errors"
)

// Generator defines the interface implemented by all ApplicationSet generators.
Expand All @@ -23,10 +23,5 @@ type Generator interface {
GetTemplate(appSetGenerator *argoprojiov1alpha1.ApplicationSetGenerator) *argoprojiov1alpha1.ApplicationSetTemplate
}

var EmptyAppSetGeneratorError = fmt.Errorf("ApplicationSet is empty")
var EmptyAppSetGeneratorError = errors.New("ApplicationSet is empty")
var NoRequeueAfter time.Duration

// DefaultRequeueAfterSeconds is used when GetRequeueAfter is not specified, it is the default time to wait before the next reconcile loop
const (
DefaultRequeueAfterSeconds = 3 * time.Minute
)

0 comments on commit 18cbf67

Please sign in to comment.