Skip to content

Commit

Permalink
Feat crd autodiscovery (#57)
Browse files Browse the repository at this point in the history
* feat: crds creates both actions and blueprints

* chore: fixing modules and hiearchy of the code

* chore: support CRD instead of both CRD and XRD

* fix: schema improvements

* fix: added support for namespaced scoped and fixed multiple bugs

* fix: remove debug file

* chore: added debug file to gitignore

* config: change the configuration naming

* chore: downgrade back to go 1.21

* fix: go mod

* chore: upgrade ci to go 1.22

* fix: update go toolchain

* chore: removed updating the list length

* chore: make functions in  private besides autodiscoverCRDsToAction

* chore: extract to more functions

* tests: added tests for the CRD logic

* tests: improved

* tests: added deletion of resources to defaults first test

* tests: checking resources exsists

* fix: added the kind config to the resources

* fix: added the kind config to the resources at the start of the loop

* fix: links to docs

* fix: links to docs

* fix: grammer

* fix: docs link

* tests: unite the CheckResources function to a single one

* tests: add a test to check the jq pattern with a false

* tests: reverted one tests

* tests: fix CI to use staging
  • Loading branch information
danielsinai authored May 9, 2024
1 parent 62df5c3 commit 1b08c0f
Show file tree
Hide file tree
Showing 23 changed files with 942 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: 1.22
cache: true

- name: Build
Expand All @@ -27,4 +27,4 @@ jobs:
env:
PORT_CLIENT_ID: ${{ secrets.PORT_CLIENT_ID }}
PORT_CLIENT_SECRET: ${{ secrets.PORT_CLIENT_SECRET }}

PORT_BASE_URL: https://api.stg-01.getport.io
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ config.yaml

deployments/k8s

.env
.env

.vscode

# debug file
__debug_bin*
49 changes: 26 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@
module github.com/port-labs/port-k8s-exporter

go 1.21
go 1.22.0

toolchain go1.22.2

require (
github.com/confluentinc/confluent-kafka-go/v2 v2.2.0
github.com/go-resty/resty/v2 v2.7.0
github.com/google/uuid v1.3.0
github.com/itchyny/gojq v0.12.9
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.2
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.25.2
k8s.io/apimachinery v0.25.2
k8s.io/client-go v0.25.2
k8s.io/klog/v2 v2.80.1
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
k8s.io/api v0.30.0
k8s.io/apiextensions-apiserver v0.30.0
k8s.io/apimachinery v0.30.0
k8s.io/client-go v0.30.0
k8s.io/klog/v2 v2.120.1
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/itchyny/timefmt-go v0.1.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
109 changes: 66 additions & 43 deletions go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"errors"
"fmt"

"github.com/port-labs/port-k8s-exporter/pkg/config"
"github.com/port-labs/port-k8s-exporter/pkg/defaults"
"github.com/port-labs/port-k8s-exporter/pkg/event_handler"
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package config
import (
"flag"
"fmt"
"os"
"strings"

"github.com/joho/godotenv"
"github.com/port-labs/port-k8s-exporter/pkg/port"
"gopkg.in/yaml.v2"
"k8s.io/klog/v2"
"os"
"strings"
)

var KafkaConfig = &KafkaConfiguration{}
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package config

import (
"flag"
"strings"

"github.com/port-labs/port-k8s-exporter/pkg/goutils"
"k8s.io/utils/strings/slices"
"strings"
)

var keys []string
Expand Down
Loading

0 comments on commit 1b08c0f

Please sign in to comment.