Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: krew plugin not assigning pool name #1612

Merged
merged 1 commit into from
May 23, 2023
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ plugin: regen-crd
GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean && \
GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ../.golangci.yml)

plugin-binary: plugin
@(cd $(PLUGIN_HOME) && CGO_ENABLED=0 go build -trimpath --ldflags $(LDFLAGS) -o kubectl-minio .)

generate-code:
@./k8s/update-codegen.sh
Expand Down
6 changes: 6 additions & 0 deletions kubectl-minio/cmd/resources/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package resources

import (
"fmt"
"io"
"io/fs"
"log"
Expand Down Expand Up @@ -99,6 +100,11 @@ func Pool(opts *TenantOptions, volumes int32, q resource.Quantity) miniov2.Pool
return p
}

// GeneratePoolName Pool Name Generator
func GeneratePoolName(poolNumber int) string {
return fmt.Sprintf("pool-%d", poolNumber)
}

// GetSchemeDecoder returns a decoder for the scheme's that we use
func GetSchemeDecoder() func(data []byte, defaults *schema.GroupVersionKind, into runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
sch := runtime.NewScheme()
Expand Down
5 changes: 5 additions & 0 deletions kubectl-minio/cmd/tenant-expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ func (v *expandCmd) run() error {
return err
}

// Tenant pool id is zero based, generating pool using the count of existing pools in the tenant
if v.tenantOpts.PoolName == "" {
v.tenantOpts.PoolName = resources.GeneratePoolName(len(t.Spec.Pools))
}

t.Spec.Pools = append(t.Spec.Pools, resources.Pool(&v.tenantOpts, volumesPerServer, *capacityPerVolume))
expandedCapacity := helpers.TotalCapacity(*t)
if !v.output {
Expand Down