Skip to content

Commit

Permalink
add perses config types
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Bernal <[email protected]>
  • Loading branch information
jgbernalp committed Jan 22, 2024
1 parent 655b841 commit f9bd2ac
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 178 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ checkunused:

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:ignoreUnexportedFields=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/perses_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v1alpha1

import (
"github.com/barkimedes/go-deepcopy"
"github.com/perses/perses/pkg/model/api/config"
)

type PersesConfig struct {
config.Config `json:",inline"`
}

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

if err != nil {
panic(err)
}

*out = *(temp.(*PersesConfig))
}
36 changes: 0 additions & 36 deletions api/v1alpha1/perses_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,9 @@ limitations under the License.
package v1alpha1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:validation:Enum=json;yaml
type FileExtension string

type File struct {
Folder string `json:"folder" yaml:"folder"`
Extension FileExtension `json:"extension" yaml:"extension"`
}

type Database struct {
File *File `json:"file,omitempty" yaml:"file,omitempty"`
}

type Schemas struct {
// +kubebuilder:validation:optional
PanelsPath string `json:"panels_path,omitempty" yaml:"panels_path,omitempty"`
// +kubebuilder:validation:optional
QueriesPath string `json:"queries_path,omitempty" yaml:"queries_path,omitempty"`
// +kubebuilder:validation:optional
DatasourcesPath string `json:"datasources_path,omitempty" yaml:"datasources_path,omitempty"`
// +kubebuilder:validation:optional
VariablesPath string `json:"variables_path,omitempty" yaml:"variables_path,omitempty"`
// +kubebuilder:validation:optional
Interval time.Duration `json:"interval,omitempty" yaml:"interval,omitempty"`
}

// TODO: import this from https://github.com/perses/perses/blob/main/internal/api/config/config.go#L51
type PersesConfig struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +kubebuilder:validation:optional
Readonly bool `json:"readonly" yaml:"readonly"`
Database Database `json:"database" yaml:"database"`
Schemas Schemas `json:"schemas" yaml:"schemas"`
}

// PersesSpec defines the desired state of Perses
type PersesSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
Expand Down
57 changes: 0 additions & 57 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f9bd2ac

Please sign in to comment.