Add a search string to envs
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@@ -148,7 +148,7 @@ require (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require (
 | 
					require (
 | 
				
			||||||
	git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.10
 | 
						git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11
 | 
				
			||||||
	github.com/golang/protobuf v1.5.4
 | 
						github.com/golang/protobuf v1.5.4
 | 
				
			||||||
	golang.org/x/net v0.24.0 // indirect
 | 
						golang.org/x/net v0.24.0 // indirect
 | 
				
			||||||
	golang.org/x/sys v0.19.0 // indirect
 | 
						golang.org/x/sys v0.19.0 // indirect
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
				
			|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 | 
					cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
 | 
				
			||||||
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.10 h1:vyI425BM85gyUi23HXJQtMw/pC81wYhWgBKgmG3Lc2w=
 | 
					git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11 h1:Kjdz7HUOhg5f8wktvf+QG6SNv0sN3OXfz9yErwrfl38=
 | 
				
			||||||
git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.10/go.mod h1:OU+833cHwvecr+gsnPEKQYlAJbpL8bqSJVLobdw63qI=
 | 
					git.badhouseplants.net/softplayer/softplayer-go-proto v0.1.11/go.mod h1:OU+833cHwvecr+gsnPEKQYlAJbpL8bqSJVLobdw63qI=
 | 
				
			||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
 | 
					github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
 | 
				
			||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
 | 
					github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
 | 
				
			||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
 | 
					github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ import (
 | 
				
			|||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/google/uuid"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
	"github.com/joho/godotenv"
 | 
						"github.com/joho/godotenv"
 | 
				
			||||||
@@ -213,7 +214,7 @@ func (env *Environemnt) Delete(ctx context.Context) error {
 | 
				
			|||||||
	return nil
 | 
						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()
 | 
						env.Controller.GetClient()
 | 
				
			||||||
	conf := &rest.Config{
 | 
						conf := &rest.Config{
 | 
				
			||||||
		Host:        "https://kubernetes.default.svc.cluster.local:443",
 | 
							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 {
 | 
							if err := i.Get(ctx); err != nil {
 | 
				
			||||||
			return nil, err
 | 
								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
 | 
						return result, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user