Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions api/operator/v1/vlagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
// VLAgentSpec defines the desired state of VLAgent
// +k8s:openapi-gen=true
type VLAgentSpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
Expand Down Expand Up @@ -188,16 +186,6 @@ func (cr *VLAgent) UseProxyProtocol() bool {
return vmv1beta1.UseProxyProtocol(cr.Spec.ExtraArgs)
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLAgentSpec) UnmarshalJSON(src []byte) error {
type pcr VLAgentSpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vlagent spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

// VLAgentRemoteWriteSettings - defines global settings for all remoteWrite urls.
type VLAgentRemoteWriteSettings struct {
// The maximum size of unpacked request to send to remote storage
Expand Down Expand Up @@ -276,6 +264,8 @@ type VLAgentStatus struct {
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VLAgentSpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -354,6 +344,25 @@ func (cr *VLAgent) DefaultStatusFields(vs *VLAgentStatus) {
vs.Replicas = replicaCount
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLAgent) UnmarshalJSON(src []byte) error {
type pcr VLAgent
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VLAgentSpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// FinalAnnotations implements build.builderOpts interface
func (cr *VLAgent) FinalAnnotations() map[string]string {
var v map[string]string
Expand Down
33 changes: 21 additions & 12 deletions api/operator/v1/vlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (

// VLClusterSpec defines the desired state of VLCluster
type VLClusterSpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// ServiceAccountName is the name of the ServiceAccount to use to run the
// VLSelect, VLInsert and VLStorage Pods.
Expand Down Expand Up @@ -195,22 +193,14 @@ func (cr *VLCluster) FinalLabels(kind vmv1beta1.ClusterComponent) map[string]str
return v
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLClusterSpec) UnmarshalJSON(src []byte) error {
type pcr VLClusterSpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vlcluster spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

// VLClusterStatus defines the observed state of VLCluster
type VLClusterStatus struct {
vmv1beta1.StatusMetadata `json:",inline"`
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VLClusterSpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -676,6 +666,25 @@ func (cr *VLCluster) GetStatus() *VLClusterStatus {
func (cr *VLCluster) DefaultStatusFields(vs *VLClusterStatus) {
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLCluster) UnmarshalJSON(src []byte) error {
type pcr VLCluster
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VLClusterSpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// AsOwner returns owner references with current object as owner
func (cr *VLCluster) AsOwner() metav1.OwnerReference {
return metav1.OwnerReference{
Expand Down
34 changes: 21 additions & 13 deletions api/operator/v1/vlsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
// VLSingleSpec defines the desired state of VLSingle
// +k8s:openapi-gen=true
type VLSingleSpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// PodMetadata configures Labels and Annotations which are propagated to the VLSingle pods.
// +optional
Expand Down Expand Up @@ -116,6 +114,8 @@ type VLSingleStatus struct {
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VLSingleSpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -156,7 +156,25 @@ func (cr *VLSingle) UseProxyProtocol() bool {
}

// DefaultStatusFields implements reconcile.ObjectWithDeepCopyAndStatus interface
func (cr *VLSingle) DefaultStatusFields(vs *VLSingleStatus) {
func (cr *VLSingle) DefaultStatusFields(vs *VLSingleStatus) {}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLSingle) UnmarshalJSON(src []byte) error {
type pcr VLSingle
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VLSingleSpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// +kubebuilder:object:root=true
Expand Down Expand Up @@ -190,16 +208,6 @@ func (r *VLSingle) AsOwner() metav1.OwnerReference {
}
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VLSingleSpec) UnmarshalJSON(src []byte) error {
type pcr VLSingleSpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vlsingle spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

func (cr *VLSingle) ProbePath() string {
return vmv1beta1.BuildPathWithPrefixFlag(cr.Spec.ExtraArgs, healthPath)
}
Expand Down
33 changes: 21 additions & 12 deletions api/operator/v1/vmanomaly_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import (
// VMAnomalySpec defines the desired state of VMAnomaly.
// +k8s:openapi-gen=true
type VMAnomalySpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// ComponentVersion defines default images tag for all components.
// it can be overwritten with component specific image.tag value.
Expand Down Expand Up @@ -198,6 +196,8 @@ type VMAnomalyStatus struct {
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VMAnomalySpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -323,6 +323,25 @@ func (cr *VMAnomaly) DefaultStatusFields(vs *VMAnomalyStatus) {
vs.Shards = shardCnt
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VMAnomaly) UnmarshalJSON(src []byte) error {
type pcr VMAnomaly
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VMAnomalySpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// SelectorLabels returns selector labels for vmanomaly
func (cr *VMAnomaly) SelectorLabels() map[string]string {
return map[string]string{
Expand Down Expand Up @@ -490,16 +509,6 @@ func (cr *VMAnomaly) UseProxyProtocol() bool {
return false
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VMAnomalySpec) UnmarshalJSON(src []byte) error {
type pcr VMAnomalySpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vmanomaly spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

// IsUnmanaged checks if object should manage any config objects
func (cr *VMAnomaly) IsUnmanaged() bool {
if cr == nil {
Expand Down
33 changes: 21 additions & 12 deletions api/operator/v1/vtcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (

// VTClusterSpec defines the desired state of VTCluster
type VTClusterSpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// ServiceAccountName is the name of the ServiceAccount to use to run the
// VTSelect, VTInsert and VTStorage Pods.
Expand Down Expand Up @@ -190,22 +188,14 @@ func (cr *VTCluster) FinalLabels(kind vmv1beta1.ClusterComponent) map[string]str
return v
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VTClusterSpec) UnmarshalJSON(src []byte) error {
type pcr VTClusterSpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vtcluster spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

// VTClusterStatus defines the observed state of VTCluster
type VTClusterStatus struct {
vmv1beta1.StatusMetadata `json:",inline"`
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VTClusterSpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -586,6 +576,25 @@ func (cr *VTCluster) GetStatus() *VTClusterStatus {
func (cr *VTCluster) DefaultStatusFields(vs *VTClusterStatus) {
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VTCluster) UnmarshalJSON(src []byte) error {
type pcr VTCluster
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VTClusterSpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// AsOwner returns owner references with current object as owner
func (cr *VTCluster) AsOwner() metav1.OwnerReference {
return metav1.OwnerReference{
Expand Down
33 changes: 21 additions & 12 deletions api/operator/v1/vtsingle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
// VTSingleSpec defines the desired state of VTSingle
// +k8s:openapi-gen=true
type VTSingleSpec struct {
// ParsingError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingError string `json:"-" yaml:"-"`

// PodMetadata configures Labels and Annotations which are propagated to the VTSingle pods.
// +optional
Expand Down Expand Up @@ -110,6 +108,8 @@ type VTSingleStatus struct {
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
LastAppliedSpec *VTSingleSpec `json:"lastAppliedSpec,omitempty"`
// ParsingSpecError contents error with context if operator was failed to parse json object from kubernetes api server
ParsingSpecError string `json:"-" yaml:"-"`
}

// GetStatusMetadata returns metadata for object status
Expand Down Expand Up @@ -148,6 +148,25 @@ func (cr *VTSingle) GetStatus() *VTSingleStatus {
func (cr *VTSingle) DefaultStatusFields(vs *VTSingleStatus) {
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VTSingle) UnmarshalJSON(src []byte) error {
type pcr VTSingle
type shadow struct {
*pcr
Spec json.RawMessage `json:"spec"`
}
s := shadow{pcr: (*pcr)(cr)}
if err := json.Unmarshal(src, &s); err != nil {
return err
}
if len(s.Spec) > 0 {
if err := json.Unmarshal(s.Spec, &cr.Spec); err != nil {
cr.Status.ParsingSpecError = fmt.Sprintf("cannot parse VTSingleSpec: %s, err: %s", string(s.Spec), err)
}
}
return nil
}

// +kubebuilder:object:root=true

// VTSingleList contains a list of VTSingle
Expand Down Expand Up @@ -179,16 +198,6 @@ func (r *VTSingle) AsOwner() metav1.OwnerReference {
}
}

// UnmarshalJSON implements json.Unmarshaler interface
func (cr *VTSingleSpec) UnmarshalJSON(src []byte) error {
type pcr VTSingleSpec
if err := json.Unmarshal(src, (*pcr)(cr)); err != nil {
cr.ParsingError = fmt.Sprintf("cannot parse vtsingle spec: %s, err: %s", string(src), err)
return nil
}
return nil
}

// ProbePath implements build.probeCRD interface
func (cr *VTSingle) ProbePath() string {
return vmv1beta1.BuildPathWithPrefixFlag(cr.Spec.ExtraArgs, healthPath)
Expand Down
Loading
Loading