Add a search string to envs
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/joho/godotenv"
|
||||
@ -213,7 +214,7 @@ func (env *Environemnt) Delete(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (env *Environemnt) ListEnvs(ctx context.Context) ([]*Environemnt, error) {
|
||||
func (env *Environemnt) ListEnvs(ctx context.Context, searchString string) ([]*Environemnt, error) {
|
||||
env.Controller.GetClient()
|
||||
conf := &rest.Config{
|
||||
Host: "https://kubernetes.default.svc.cluster.local:443",
|
||||
@ -244,7 +245,16 @@ func (env *Environemnt) ListEnvs(ctx context.Context) ([]*Environemnt, error) {
|
||||
if err := i.Get(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, i)
|
||||
if len(searchString) > 0 {
|
||||
if strings.Contains(i.Data.Name, searchString) {
|
||||
result = append(result, i)
|
||||
}
|
||||
if strings.Contains(i.Data.Description, searchString) {
|
||||
result = append(result, i)
|
||||
}
|
||||
} else {
|
||||
result = append(result, i)
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user