Skip to content

Commit

Permalink
[operator] Remove unnecessary logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mfordjody committed Dec 27, 2024
1 parent 01c4e9a commit 9d2d1e8
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 357 deletions.
53 changes: 6 additions & 47 deletions operator/pkg/apis/proto/values_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,26 @@ message GlobalConfig {
ArchConfig arch = 1 [deprecated = true];

// Controls whether the server-side validation is enabled.
google.protobuf.BoolValue configValidation = 3;
google.protobuf.BoolValue configValidation = 2;

// Specifies the default namespace for the dubbo control plane components.
string dubboNamespace = 14;

// Specifies the configution of dubbod
dubbodConfig dubbod = 54;

// Configures the revision this control plane is a part of
string revision = 59;
}

message dubbodConfig {
// If enabled, dubbod will perform config analysis
google.protobuf.BoolValue enableAnalysis = 2;
}

message BaseConfig {
// For Helm2 use, adds the CRDs to templates.
google.protobuf.BoolValue enableCRDTemplates = 1;
// CRDs to exclude. Requires `enableCRDTemplates`
repeated string excludedCRDs = 6;
// URL to use for validating webhook.
string validationURL = 2;

// For dubboctl usage to disable dubbo config crds in base
google.protobuf.BoolValue enabledubboConfigCRDs = 3;

google.protobuf.BoolValue validateGateway = 4;

// validation webhook CA bundle
string validationCABundle = 5;
google.protobuf.BoolValue enabledubboConfigCRDs = 1;
GlobalConfig global = 2; // Add this line if `global` is required in BaseConfig
}

message Values {
// Global configuration for dubbo components.
GlobalConfig global = 6;

// Identifies the revision this installation is associated with.
string revision = 21;

// Used internally to identify the owner of each resource.
string ownerName = 22;
GlobalConfig global = 1;

// Configuration for the base component.
BaseConfig base = 37;

// Specifies the aliases for the dubbo control plane revision. A MutatingWebhookConfiguration
// is created for each alias.
repeated string revisionTags = 39;

// The name of the default revision in the cluster.
string defaultRevision = 40;
BaseConfig base = 2;

// Specifies which installation configuration profile to apply.
string profile = 42;

// Specifies the compatibility version to use. When this is set, the control plane will
// be configured with the same defaults as the specified version.
string compatibilityVersion = 43;

string profile = 4;
}

// IntOrString is a type that can hold an int32 or a string. When used in
Expand Down
73 changes: 73 additions & 0 deletions operator/pkg/apis/value_types_json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package apis

import (
"bytes"
"encoding/json"

github_com_golang_protobuf_jsonpb "github.com/golang/protobuf/jsonpb" // nolint: depguard
"google.golang.org/protobuf/types/known/wrapperspb"
"k8s.io/apimachinery/pkg/util/intstr"
)

// nolint
var _ github_com_golang_protobuf_jsonpb.JSONPBUnmarshaler = &IntOrString{}

// UnmarshalJSON implements the json.Unmarshaller interface.
func (i *IntOrString) UnmarshalJSON(value []byte) error {
if value[0] == '"' {
i.Type = int64(intstr.String)
var s string
err := json.Unmarshal(value, &s)
if err != nil {
return err
}
i.StrVal = &wrapperspb.StringValue{Value: s}
return nil
}
i.Type = int64(intstr.Int)
var s int32
err := json.Unmarshal(value, &s)
if err != nil {
return err
}
i.IntVal = &wrapperspb.Int32Value{Value: s}
return nil
}

func (i *IntOrString) MarshalJSONPB(_ *github_com_golang_protobuf_jsonpb.Marshaler) ([]byte, error) {
return i.MarshalJSON()
}

func (i *IntOrString) MarshalJSON() ([]byte, error) {
if i.IntVal != nil {
return json.Marshal(i.IntVal.GetValue())
}
return json.Marshal(i.StrVal.GetValue())
}

func (i *IntOrString) UnmarshalJSONPB(_ *github_com_golang_protobuf_jsonpb.Unmarshaler, value []byte) error {
return i.UnmarshalJSON(value)
}

func (i *IntOrString) ToKubernetes() intstr.IntOrString {
if i.IntVal != nil {
return intstr.FromInt32(i.GetIntVal().GetValue())
}
return intstr.FromString(i.GetStrVal().GetValue())
}

// MarshalJSON is a custom marshaler for Values
func (in *Values) MarshalJSON() ([]byte, error) {
str, err := OperatorMarshaler.MarshalToString(in)
return []byte(str), err
}

// UnmarshalJSON is a custom unmarshaler for Values
func (in *Values) UnmarshalJSON(b []byte) error {
return OperatorUnmarshaler.Unmarshal(bytes.NewReader(b), in)
}

var (
OperatorMarshaler = &github_com_golang_protobuf_jsonpb.Marshaler{}
OperatorUnmarshaler = &github_com_golang_protobuf_jsonpb.Unmarshaler{}
)
Loading

0 comments on commit 9d2d1e8

Please sign in to comment.