-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement global search over instances, nodes and cluster names Co-authored-by: Julian Geywitz <[email protected]> Co-authored-by: Rudolph Bott <[email protected]> Co-authored-by: Paul Schwoerer <[email protected]>
- Loading branch information
1 parent
4df5a06
commit 5ac17af
Showing
30 changed files
with
1,119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type SearchController struct { | ||
SearchService searchService | ||
} | ||
|
||
// Search godoc | ||
// @Summary Search in all known resources | ||
// @Description ... | ||
// @Produce json | ||
// @Success 200 {object} model.SearchResultsResponse | ||
// @Failure 400 {object} model.ErrorResponse | ||
// @Failure 500 {object} model.ErrorResponse | ||
// @Router /search [get] | ||
//TODO: Add Tests | ||
func (controller *SearchController) Search(c *gin.Context) { | ||
query, exists := c.GetQuery("query") | ||
if !exists { | ||
c.AbortWithStatusJSON(400, createErrorBody("query parameter is required")) | ||
return | ||
} | ||
|
||
if len(query) == 0 { | ||
c.AbortWithStatusJSON(400, createErrorBody("query parameter must not be empty")) | ||
return | ||
} | ||
|
||
results := controller.SearchService.Search(query) | ||
|
||
c.JSON(200, results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package mocking | ||
|
||
import ( | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
type clusterRepository struct { | ||
mock.Mock | ||
} | ||
|
||
func NewClusterRepository() *clusterRepository { | ||
return &clusterRepository{} | ||
} | ||
|
||
func (mock *clusterRepository) GetAllNames() []string { | ||
args := mock.Called() | ||
|
||
return args.Get(0).([]string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package repository | ||
|
||
import "gnt-cc/config" | ||
|
||
type ClusterRepository struct { | ||
} | ||
|
||
func (*ClusterRepository) GetAllNames() []string { | ||
c := config.Get() | ||
clusters := make([]string, len(c.Clusters)) | ||
for i, cluster := range c.Clusters { | ||
clusters[i] = cluster.Name | ||
} | ||
return clusters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.