Skip to content

Commit

Permalink
[ENHANCEMENT] Update dependencies and improve docs (#21)
Browse files Browse the repository at this point in the history
* chore: improve docs

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* chore: update dependencies +  go version

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* chore: update makefile targets for generating YAML manifests and code

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] get the operator up to date

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] update perses crd

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] update makefile test targets

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] minor improvement

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] fix make test target

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT]  increment controller gen version to v0.16.0

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [BUGFIX] fix panic when fetching dashbaords

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] update perses dependency

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* update perses API dependency to fix duration types

Signed-off-by: Gabriel Bernal <[email protected]>

* [ENHANCEMENT] efficient deepcopy

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [IGNORE] fix linting issue

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [IGNORE] dependency update

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] review comment fix

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [ENHANCEMENT] Removed the unused client

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

* [IGNORE] minor fix

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>

---------

Signed-off-by: Akshay Iyyadurai Balasundaram <[email protected]>
Signed-off-by: Gabriel Bernal <[email protected]>
Co-authored-by: Gabriel Bernal <[email protected]>
  • Loading branch information
ibakshay and jgbernalp authored Nov 27, 2024
1 parent c04387e commit 720eb74
Show file tree
Hide file tree
Showing 14 changed files with 739 additions and 380 deletions.
33 changes: 26 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
BUNDLE_GEN_FLAGS += --use-image-digests
endif

## Versions

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
OPERATOR_SDK_VERSION ?= v1.32.0
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.31.0
# ENVTEST_VERSION refers to the version of the envtest binary.
ENVTEST_VERSION ?= release-0.19

# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -119,7 +123,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test $(shell go list ./...) -v -ginkgo.v -coverprofile cover.out

.PHONY: lint
lint: ## Run linting.
Expand Down Expand Up @@ -196,11 +200,11 @@ $(LOCALBIN):
## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CONTROLLER_TOOLS_VERSION ?= v0.16.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand All @@ -218,10 +222,11 @@ $(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)


.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))

.PHONY: operator-sdk
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
Expand Down Expand Up @@ -295,3 +300,17 @@ catalog-build: opm ## Build a catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
# $3 - specific version of package
define go-install-tool
@[ -f $(1) ] || { \
set -e; \
package=$(2)@$(3) ;\
echo "Downloading $${package}" ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\
}
endef
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ kubectl delete -f config/samples/v1alpha1_perses.yaml --namespace default
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:

```sh
make manifests
make manifests # Generate YAML manifests like CRDs, RBAC etc.
make generate # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
```

**NOTE:** Run `make --help` for more information on all potential `make` targets
Expand Down
14 changes: 9 additions & 5 deletions api/v1alpha1/perses_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package v1alpha1

import (
"github.com/barkimedes/go-deepcopy"
"fmt"

"github.com/brunoga/deep"
"github.com/perses/perses/pkg/model/api/config"
)

Expand All @@ -10,11 +12,13 @@ type PersesConfig struct {
}

func (in *PersesConfig) DeepCopyInto(out *PersesConfig) {
temp, err := deepcopy.Anything(in)
if in == nil {
return
}

copied, err := deep.Copy(in)
if err != nil {
panic(err)
panic(fmt.Errorf("failed to deep copy PersesConfig: %w", err))
}

*out = *(temp.(*PersesConfig))
*out = *copied
}
14 changes: 9 additions & 5 deletions api/v1alpha1/perses_dashboard.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package v1alpha1

import (
"github.com/barkimedes/go-deepcopy"
"fmt"

"github.com/brunoga/deep"
persesv1 "github.com/perses/perses/pkg/model/api/v1"
)

Expand All @@ -10,11 +12,13 @@ type Dashboard struct {
}

func (in *Dashboard) DeepCopyInto(out *Dashboard) {
temp, err := deepcopy.Anything(in)
if in == nil {
return
}

copied, err := deep.Copy(in)
if err != nil {
panic(err)
panic(fmt.Errorf("failed to deep copy Dashboard: %w", err))
}

*out = *(temp.(*Dashboard))
*out = *copied
}
14 changes: 9 additions & 5 deletions api/v1alpha1/perses_datasource.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package v1alpha1

import (
"github.com/barkimedes/go-deepcopy"
"fmt"

"github.com/brunoga/deep"
persesv1 "github.com/perses/perses/pkg/model/api/v1"
)

Expand All @@ -10,11 +12,13 @@ type Datasource struct {
}

func (in *Datasource) DeepCopyInto(out *Datasource) {
temp, err := deepcopy.Anything(in)
if in == nil {
return
}

copied, err := deep.Copy(in)
if err != nil {
panic(err)
panic(fmt.Errorf("failed to deep copy Datasource: %w", err))
}

*out = *(temp.(*Datasource))
*out = *copied
}
Loading

0 comments on commit 720eb74

Please sign in to comment.