Skip to content

Commit

Permalink
[operator] Simply Optimize Content
Browse files Browse the repository at this point in the history
  • Loading branch information
mfordjody committed Jan 2, 2025
1 parent ce61a2f commit fee016e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 84 deletions.
4 changes: 2 additions & 2 deletions manifests/charts/admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ jaeger:

zookeeper:
## Whether to enable the zookeeper.
enabled: true
enabled: false
## Override the namespace where the resource is deployed.
namespaceOverride: ~
## Labels to attach to the resource.
Expand Down Expand Up @@ -638,7 +638,7 @@ zookeeper:

nacos:
## Whether to enable the nacos.
enabled: false
enabled: true
## Specifies the mode in which nacos is running (standalone, cluster, etc.).
mode: standalone
## Override the namespace where the resource is deployed.
Expand Down
3 changes: 3 additions & 0 deletions manifests/profiles/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: DubboOperator
metadata:
namespace: dubbo-system
spec:
profile: default
components:
base:
enabled: true
Expand All @@ -13,3 +14,5 @@ spec:
global:
dubboNamespace: dubbo-system



11 changes: 6 additions & 5 deletions operator/cmd/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type installArgs struct {
files []string
sets []string
manifestPath string
skipConfirmation bool
waitTimeout time.Duration
skipConfirmation bool
}

func (i *installArgs) String() string {
Expand All @@ -37,9 +37,10 @@ func (i *installArgs) String() string {
}

func addInstallFlags(cmd *cobra.Command, args *installArgs) {
cmd.PersistentFlags().StringSliceVarP(&args.files, "files", "f", nil, `Path to the file containing the dubboOperator's custom resources`)
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, `Override dubboOperator values, such as selecting profiles, etc`)
cmd.PersistentFlags().DurationVar(&args.waitTimeout, "wait-timeout", 300*time.Second, "Maximum time to wait for Dubbo resources in each component to be ready")
cmd.PersistentFlags().StringSliceVarP(&args.files, "files", "f", nil, `Path to the file containing the dubboOperator's custom resources.`)
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, `Override dubboOperator values, such as selecting profiles, etc.`)
cmd.PersistentFlags().BoolVarP(&args.skipConfirmation, "skip-confirmation", "y", false, `The skipConfirmation determines whether the user is prompted for confirmation.`)
cmd.PersistentFlags().DurationVar(&args.waitTimeout, "wait-timeout", 300*time.Second, "Maximum time to wait for Dubbo resources in each component to be ready.")
}

func InstallCmd(ctx cli.Context) *cobra.Command {
Expand Down Expand Up @@ -86,7 +87,7 @@ func Install(kubeClient kube.CLIClient, rootArgs *RootArgs, iArgs *installArgs,
}
profile := pointer.NonEmptyOrDefault(vals.GetPathString("spec.profile"), "default")
if !rootArgs.DryRun && !iArgs.skipConfirmation {
prompt := fmt.Sprintf("You are currently selecting the %q profile to install into the cluster. Do you want to proceed? (y/N)", profile)
prompt := fmt.Sprintf("The %q profile will be installed into the cluster. \nDo you want to proceed? (y/N)", profile)
if !OptionDeterminate(prompt, stdOut) {
p.Println("Canceled Completed.")
os.Exit(1)
Expand Down
8 changes: 4 additions & 4 deletions operator/cmd/cluster/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func (a *ManifestGenerateArgs) String() string {
}

func addManifestGenerateFlags(cmd *cobra.Command, args *ManifestGenerateArgs) {
cmd.PersistentFlags().StringSliceVarP(&args.files, "filename", "f", nil, "")
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, "")
cmd.PersistentFlags().StringVarP(&args.manifestPath, "manifests", "d", "", "")
cmd.PersistentFlags().StringSliceVarP(&args.files, "filename", "f", nil, ``)
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, ``)
cmd.PersistentFlags().StringVarP(&args.manifestPath, "manifests", "d", "", ``)
}

func ManifestCmd(ctx cli.Context) *cobra.Command {
Expand Down Expand Up @@ -59,7 +59,7 @@ func ManifestGenerateCmd(ctx cli.Context, _ *RootArgs, mgArgs *ManifestGenerateA
Long: "The generate subcommand generates an Dubbo install manifest and outputs to the console by default.",
Example: ` # Generate a default Istio installation
istioctl manifest generate
# Generate the demo profile
istioctl manifest generate --set profile=demo
`,
Expand Down
18 changes: 7 additions & 11 deletions operator/cmd/cluster/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import (
"os"
)

const (
AllResourcesRemovedWarning = "All Dubbo resources will be pruned from the cluster\n"
PurgeWithRevisionOrOperatorSpecifiedWarning = "Purge uninstall will remove all Dubbo resources, ignoring the specified revision or operator file"
)
const ()

type uninstallArgs struct {
files string
Expand All @@ -26,8 +23,7 @@ type uninstallArgs struct {
}

func addUninstallFlags(cmd *cobra.Command, args *uninstallArgs) {
cmd.PersistentFlags().StringVarP(&args.files, "filename", "f", "",
"The filename of the DubboOperator CR.")
cmd.PersistentFlags().StringVarP(&args.files, "filename", "f", "", "The filename of the DubboOperator CR.")
cmd.PersistentFlags().StringArrayVarP(&args.sets, "set", "s", nil, `Override dubboOperator values, such as selecting profiles, etc.`)
cmd.PersistentFlags().BoolVar(&args.purge, "purge", false, `Remove all dubbo related source code.`)
cmd.PersistentFlags().BoolVarP(&args.skipConfirmation, "skip-confirmation", "y", false, `The skipConfirmation determines whether the user is prompted for confirmation.`)
Expand Down Expand Up @@ -74,7 +70,7 @@ func Uninstall(cmd *cobra.Command, ctx cli.Context, rootArgs *RootArgs, uiArgs *

pl := progress.NewInfo()
if uiArgs.purge && uiArgs.files != "" {
cl.LogAndPrint(PurgeWithRevisionOrOperatorSpecifiedWarning)
cl.LogAndPrint("Purge uninstall will remove all Dubbo resources, ignoring the specified revision or operator file")
}

setFlags := applyFlagAliases(uiArgs.sets, uiArgs.manifestPath)
Expand Down Expand Up @@ -102,24 +98,24 @@ func Uninstall(cmd *cobra.Command, ctx cli.Context, rootArgs *RootArgs, uiArgs *
preCheck(cmd, uiArgs, cl, rootArgs.DryRun)

if err := uninstall.DeleteObjectsList(kubeClient, rootArgs.DryRun, cl, objectsList); err != nil {
return fmt.Errorf("failed to delete control plane resources by revision: %v", err)
return err
}

pl.SetState(progress.StateUninstallComplete)

return nil
}

func preCheck(cmd *cobra.Command, uiArgs *uninstallArgs, cl *clog.ConsoleLogger, dryRun bool) {
func preCheck(cmd *cobra.Command, uiArgs *uninstallArgs, _ *clog.ConsoleLogger, dryRun bool) {
needConfirmation, message := false, ""
if uiArgs.purge {
needConfirmation = true
message += AllResourcesRemovedWarning
message += "All Dubbo resources will be pruned from the cluster.\n"
}
if dryRun || uiArgs.skipConfirmation {
return
}
message += "Proceed? (y/N)"
message += "Do you want to proceed? (y/N)"
if needConfirmation && !OptionDeterminate(message, cmd.OutOrStdout()) {
cmd.Print("Canceled Completed.\n")
os.Exit(1)
Expand Down
41 changes: 0 additions & 41 deletions operator/dubbod/pkg/resource/crd/crd.go

This file was deleted.

19 changes: 2 additions & 17 deletions operator/pkg/apis/types.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
// Copyright Dubbo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by kubetype-gen. DO NOT EDIT.

package apis

import (
Expand Down Expand Up @@ -40,8 +25,8 @@ type DubboOperatorSpec struct {
}

type DubboComponentSpec struct {
Base *BaseComponentSpec `json:"base,omitempty"`
Admin *ComponentSpec `json:"admin,omitempty"`
Base *BaseComponentSpec `json:"base,omitempty"`
Admin *ComponentSpec `json:"admin,omitempty"`
}

type BaseComponentSpec struct {
Expand Down
10 changes: 6 additions & 4 deletions operator/pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var AllComponents = []Component{
SpecName: "admin",
Default: true,
HelmSubDir: "admin",
HelmTreeRoot: "admin.global",
HelmTreeRoot: "",
},
}

Expand All @@ -42,12 +42,13 @@ type Component struct {
var (
userFacingCompNames = map[Name]string{
BaseComponentName: "Dubbo Core",
AdminComponentName: "Dubbo Dashboard or Control Plane",
AdminComponentName: "Dubbo Dashboard",
}

Icons = map[Name]string{
BaseComponentName: "🛸",
AdminComponentName: "🛰✗📡",
AdminComponentName: "🛰",
// 📡
}
)

Expand Down Expand Up @@ -78,7 +79,8 @@ func (c Component) Get(merged values.Map) ([]apis.MetadataCompSpec, error) {

if spec.Namespace == "" {
spec.Namespace = defaultNamespace
} else {
}
if spec.Namespace == "" {
spec.Namespace = "dubbo-system"
}
spec.Raw = m
Expand Down

0 comments on commit fee016e

Please sign in to comment.