Skip to content

Commit

Permalink
[operator] add admin charts logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mfordjody committed Dec 27, 2024
1 parent d6ccb9e commit 183c8bc
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 18 deletions.
9 changes: 7 additions & 2 deletions manifests/profiles/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ spec:
components:
base:
enabled: true
admin:
enabled: true
values:
global:
dubboNamespace: dubbo-system
base:
global:
dubboNamespace: dubbo-system
admin:
global: {}
22 changes: 12 additions & 10 deletions operator/pkg/apis/types.go

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

21 changes: 17 additions & 4 deletions operator/pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
type Name string

const (
BaseComponentName Name = "Base"
BaseComponentName Name = "Base"
AdminComponentName Name = "Admin"
)

type Component struct {
Expand All @@ -18,6 +19,7 @@ type Component struct {
Default bool
HelmSubDir string
HelmTreeRoot string
ResourceName string
FlattenValues bool
}

Expand All @@ -27,16 +29,27 @@ var AllComponents = []Component{
SpecName: "base",
Default: true,
HelmSubDir: "base",
HelmTreeRoot: "global",
HelmTreeRoot: "base.global",
},
{
UserFacingName: AdminComponentName,
SpecName: "admin",
Default: true,
ResourceName: "admin",
HelmSubDir: "admin",
HelmTreeRoot: "admin.global",
},
}

var (
userFacingCompNames = map[Name]string{
BaseComponentName: "Dubbo Core",
BaseComponentName: "Dubbo Core",
AdminComponentName: "Dubbo Dashboard or Control Plane",
}

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

Expand Down
3 changes: 3 additions & 0 deletions operator/pkg/install/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ func (i Installer) prune(manifests []manifest.ManifestSet) error {

var componentDependencies = map[component.Name][]component.Name{
component.BaseComponentName: {},
component.AdminComponentName: {
component.BaseComponentName,
},
}

func dependenciesChs() map[component.Name]chan struct{} {
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/render/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func readBuiltinProfile(path, profile string) (values.Map, error) {
return values.MapFromYAML(pb)
}

func GenerateManifest(files []string, setFlags []string, logger clog.Logger, client kube.Client) ([]manifest.ManifestSet, values.Map, error) {
func GenerateManifest(files []string, setFlags []string, logger clog.Logger, _ kube.Client) ([]manifest.ManifestSet, values.Map, error) {
merged, err := MergeInputs(files, setFlags)
if err != nil {
return nil, nil, fmt.Errorf("merge inputs: %v %v", err)

Check failure on line 117 in operator/pkg/render/manifest.go

View workflow job for this annotation

GitHub Actions / Go Test

fmt.Errorf format %v reads arg #2, but call has 1 arg
Expand Down
35 changes: 34 additions & 1 deletion operator/pkg/util/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/apache/dubbo-kubernetes/operator/pkg/component"
"github.com/cheggaaa/pb/v3"
"io"
"sort"
"strings"
"sync"
)

Expand Down Expand Up @@ -34,6 +36,30 @@ func NewInfo() *Info {
}
}

func (i *Info) createStatus(maxWidth int) string {
comps := make([]string, 0, len(i.components))
wait := make([]string, 0, len(i.components))
for c, l := range i.components {
comps = append(comps, component.UserFacingCompName(component.Name(c)))
wait = append(wait, l.waitingResources()...)
}
sort.Strings(comps)
sort.Strings(wait)
msg := fmt.Sprintf(`Processing resources for %s.`, strings.Join(comps, ", "))
if len(wait) > 0 {
msg += fmt.Sprintf(` Waiting for %s`, strings.Join(wait, ", "))
}
prefix := inProgress
if !i.bar.GetBool(pb.Terminal) {
prefix = `{{ yellow "-" }} `
}
maxWidth -= 2
if maxWidth > 0 && len(msg) > maxWidth {
return prefix + msg[:maxWidth-3] + "..."
}
return prefix + msg
}

func (i *Info) NewComponent(comp string) *ManifestInfo {
mi := &ManifestInfo{
report: i.reportProgress(comp),
Expand All @@ -54,7 +80,7 @@ func (i *Info) reportProgress(componentName string) func() {
finished := comp.finished
compErr := comp.err
comp.mu.Unlock()
successIcon := "🎉"
successIcon := ""
if icon, found := component.Icons[compName]; found {
successIcon = icon
}
Expand All @@ -68,6 +94,7 @@ func (i *Info) reportProgress(componentName string) func() {
i.bar = createBar()
return
}
i.SetMessage(i.createStatus(i.bar.Width()), false)
}
}

Expand Down Expand Up @@ -146,3 +173,9 @@ func (mi *ManifestInfo) ReportError(err string) {
mi.mu.Unlock()
mi.report()
}

func (p *ManifestInfo) waitingResources() []string {
p.mu.Lock()
defer p.mu.Unlock()
return p.waiting
}

0 comments on commit 183c8bc

Please sign in to comment.