Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MeNsaaH committed Jan 9, 2024
1 parent 042e771 commit 7d5cc21
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 145 deletions.
6 changes: 0 additions & 6 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,8 @@ dlv:
SAVE ARTIFACT /go/bin/dlv

docker-debug:
<<<<<<< HEAD
ARG GOARCH="amd64"
ARG CI_REGISTRY_IMAGE="kubechecks"
FROM +docker --GIT_TAG=debug --GIT_COMMIT=abcdef --CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE --GOARCH=$GOARCH
=======
ARG IMAGE_NAME="kubechecks:debug"
FROM +docker --GIT_TAG=debug --GIT_COMMIT=abcdef
>>>>>>> origin/main

COPY (+dlv/dlv --GOARCH=$GOARCH --VARIANT=$TARGETVARIANT) /usr/local/bin/dlv
COPY (+build-debug-binary/kubechecks --GOARCH=$GOARCH --VARIANT=$TARGETVARIANT) .
Expand Down
16 changes: 9 additions & 7 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,15 @@ k8s_yaml(helm(
namespace='kubechecks',
name='kubechecks',
values='./localdev/kubechecks/values.yaml',
set=['deployment.env.KUBECHECKS_WEBHOOK_URL_BASE=' + get_ngrok_url(cfg), 'deployment.env.NGROK_URL=' + get_ngrok_url(cfg),
'deployment.env.KUBECHECKS_ARGOCD_WEBHOOK_URL='+ get_ngrok_url(cfg) +'/argocd/api/webhook',
'deployment.env.KUBECHECKS_ENABLE_CONFTEST=true',
'deployment.env.KUBECHECKS_VCS_TYPE=' + cfg.get('vcs-type', 'gitlab'),
'secrets.env.KUBECHECKS_VCS_TOKEN=' + (os.getenv('GITLAB_TOKEN') if 'gitlab' in cfg.get('vcs-type', 'gitlab') else os.getenv('GITHUB_TOKEN')),
'secrets.env.KUBECHECKS_WEBHOOK_SECRET=' + (os.getenv('KUBECHECKS_WEBHOOK_SECRET') if os.getenv('KUBECHECKS_WEBHOOK_SECRET') != None else ""),
'secrets.env.KUBECHECKS_OPENAI_API_TOKEN=' + (os.getenv('OPENAI_API_TOKEN') if os.getenv('OPENAI_API_TOKEN') != None else ""),],
set=[
'deployment.env[0].name=KUBECHECKS_WEBHOOK_URL_BASE', 'deployment.env[0].value=' + get_ngrok_url(cfg),
'deployment.env[1].name=NGROK_URL', 'deployment.env[1].value=' + get_ngrok_url(cfg),
'deployment.env[2].name=KUBECHECKS_ARGOCD_WEBHOOK_URL', 'deployment.env[2].value=' + get_ngrok_url(cfg) +'/argocd/api/webhook',
'deployment.env[3].name=KUBECHECKS_VCS_TYPE', 'deployment.env[3].value=' + cfg.get('vcs-type', 'gitlab'),
'secrets.env.KUBECHECKS_VCS_TOKEN=' + (os.getenv('GITLAB_TOKEN') if 'gitlab' in cfg.get('vcs-type', 'gitlab') else os.getenv('GITHUB_TOKEN')),
'secrets.env.KUBECHECKS_WEBHOOK_SECRET=' + (os.getenv('KUBECHECKS_WEBHOOK_SECRET') if os.getenv('KUBECHECKS_WEBHOOK_SECRET') != None else ""),
'secrets.env.KUBECHECKS_OPENAI_API_TOKEN=' + (os.getenv('OPENAI_API_TOKEN') if os.getenv('OPENAI_API_TOKEN') != None else ""),
],
))

k8s_resource(
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Click the Detailed view button at the top, and click the refresh button next to

#### Minikube

If you're using minikube with Tilt we recommend following this [guide](https://github.com/tilt-dev/minikube-local) to setup a local registry that Tilt can push to automatically. Without this Tilt will attempt to push up to Docker Hub by default.
If you're using minikube with Tilt we recommend following this [guide](https://github.com/tilt-dev/ctlptl) to setup a local registry that Tilt can push to automatically. Without this Tilt will attempt to push up to Docker Hub by default.

### Code Changes

Expand Down
45 changes: 30 additions & 15 deletions localdev/kubechecks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,43 @@ deployment:
annotations:
reloader.stakater.com/auto: "true"
env:
KUBECHECKS_LOG_LEVEL: debug
KUBECHECKS_ENABLE_WEBHOOK_CONTROLLER: false
KUBECHECKS_ARGOCD_API_INSECURE: true
KUBECHECKS_ARGOCD_API_PATH_PREFIX : '/argocd'
KUBECHECKS_ARGOCD_NAMESPACE: 'kubechecks'
KUBECHECKS_WEBHOOK_URL_PREFIX: 'kubechecks'
KUBECHECKS_NAMESPACE: 'kubechecks'
KUBECHECKS_FALLBACK_K8S_VERSION: "1.25.0"
KUBECHECKS_SHOW_DEBUG_INFO: "true"
- name: KUBECHECKS_LOG_LEVEL
value: debug
- name: KUBECHECKS_ENABLE_WEBHOOK_CONTROLLER
value: "false"
- name: KUBECHECKS_ARGOCD_API_INSECURE
value: "true"
- name: KUBECHECKS_ARGOCD_API_PATH_PREFIX
value : '/argocd'
- name: KUBECHECKS_ARGOCD_NAMESPACE
value: 'kubechecks'
- name: KUBECHECKS_WEBHOOK_URL_PREFIX
value: 'kubechecks'
- name: KUBECHECKS_NAMESPACE
value: 'kubechecks'
- name: KUBECHECKS_FALLBACK_K8S_VERSION
value: "1.25.0"
- name: KUBECHECKS_SHOW_DEBUG_INFO
value: "true"
# OTEL
KUBECHECKS_OTEL_COLLECTOR_PORT: "4317"
KUBECHECKS_OTEL_ENABLED: "false"
- name: KUBECHECKS_OTEL_COLLECTOR_PORT
value: "4317"
- name: KUBECHECKS_OTEL_ENABLED
value: "false"
# Webhook Management
KUBECHECKS_ENSURE_WEBHOOKS: "true"
KUBECHECKS_MONITOR_ALL_APPLICATIONS: "true"
- name: KUBECHECKS_ENSURE_WEBHOOKS
value: "true"
- name: KUBECHECKS_MONITOR_ALL_APPLICATIONS
value: "true"
#
# KUBECHECKS_LABEL_FILTER: "test" # On your PR/MR, prefix this with "kubechecks:"
# KUBECHECKS_SCHEMAS_LOCATION: https://github.com/zapier/kubecheck-schemas.git
KUBECHECKS_TIDY_OUTDATED_COMMENTS_MODE: "delete"
- name: KUBECHECKS_TIDY_OUTDATED_COMMENTS_MODE
value: "delete"
- name: KUBECHECKS_ENABLE_CONFTEST
value: "true"

image:
repository: ""
pullPolicy: Always
name: "kubechecks"
tag: ""
Expand Down
6 changes: 3 additions & 3 deletions pkg/app_watcher/appwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (ctrl *ApplicationWatcher) onApplicationAdded(obj interface{}) {
log.Error().Err(err).Msg("appwatcher: could not get key for added application")
}
log.Trace().Str("key", key).Msg("appwatcher: onApplicationAdded")
ctrl.cfg.VcsToArgoMap.AddApp(obj.(*appv1alpha1.Application))
ctrl.cfg.VcsToArgoMap.AddApp(obj.(appv1alpha1.Application))
}

func (ctrl *ApplicationWatcher) onApplicationUpdated(old, new interface{}) {
Expand Down Expand Up @@ -114,10 +114,10 @@ func (ctrl *ApplicationWatcher) newApplicationInformerAndLister() (cache.SharedI
informer := cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (apiruntime.Object, error) {
return ctrl.applicationClientset.ArgoprojV1alpha1().Applications(ctrl.cfg.ArgoCdNamespace).List(context.TODO(), options)
return ctrl.applicationClientset.ArgoprojV1alpha1().Applications("").List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return ctrl.applicationClientset.ArgoprojV1alpha1().Applications(ctrl.cfg.ArgoCdNamespace).Watch(context.TODO(), options)
return ctrl.applicationClientset.ArgoprojV1alpha1().Applications("").Watch(context.TODO(), options)
},
},
&appv1alpha1.Application{},
Expand Down
12 changes: 6 additions & 6 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import (
"github.com/zapier/kubechecks/pkg/vcs"
)

type repoURL struct {
type RepoURL struct {
Host, Path string
}

func (r repoURL) CloneURL() string {
func (r RepoURL) CloneURL() string {
return fmt.Sprintf("git@%s:%s", r.Host, r.Path)
}

func buildNormalizedRepoUrl(host, path string) repoURL {
func buildNormalizedRepoUrl(host, path string) RepoURL {
path = strings.TrimPrefix(path, "/")
path = strings.TrimSuffix(path, ".git")
return repoURL{host, path}
return RepoURL{host, path}
}

func normalizeRepoUrl(s string) (repoURL, error) {
func NormalizeRepoUrl(s string) (RepoURL, error) {
var parser func(string) (*url.URL, error)

if strings.HasPrefix(s, "http") {
Expand All @@ -37,7 +37,7 @@ func normalizeRepoUrl(s string) (repoURL, error) {

r, err := parser(s)
if err != nil {
return repoURL{}, err
return RepoURL{}, err
}

return buildNormalizedRepoUrl(r.Host, r.Path), nil
Expand Down
55 changes: 0 additions & 55 deletions pkg/config/server_config.go

This file was deleted.

49 changes: 0 additions & 49 deletions pkg/config/vcs_argo_app_map.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/config/vcstoargomap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
)

type VcsToArgoMap struct {
appDirByRepo map[repoURL]*AppDirectory
appDirByRepo map[RepoURL]*AppDirectory
}

func NewVcsToArgoMap() VcsToArgoMap {
return VcsToArgoMap{
appDirByRepo: make(map[repoURL]*AppDirectory),
appDirByRepo: make(map[RepoURL]*AppDirectory),
}
}

Expand All @@ -37,7 +37,7 @@ func BuildAppsMap(ctx context.Context) (VcsToArgoMap, error) {
}

func (v2a *VcsToArgoMap) GetAppsInRepo(repoCloneUrl string) *AppDirectory {
repoUrl, err := normalizeRepoUrl(repoCloneUrl)
repoUrl, err := NormalizeRepoUrl(repoCloneUrl)
if err != nil {
log.Warn().Err(err).Msgf("failed to parse %s", repoCloneUrl)
}
Expand Down

0 comments on commit 7d5cc21

Please sign in to comment.