Skip to content

Commit

Permalink
fix: return execution namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Mar 22, 2024
1 parent ca1725c commit 86c98d7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5872,6 +5872,12 @@ components:
description: disable secret creation for tests and test sources
features:
$ref: "#/components/schemas/Features"
executionNamespaces:
type: array
descritpion: execution namespaces
items:
type: string
example: my-namespace

Repository:
description: repository representation for tests in git repositories
Expand Down
1 change: 1 addition & 0 deletions cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ func main() {
logGrpcClient,
cfg.DisableSecretCreation,
subscriptionChecker,
serviceAccountNames,
)

// Apply Pro server enhancements
Expand Down
11 changes: 11 additions & 0 deletions internal/app/api/v1/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func (s *TestkubeAPI) InfoHandler() fiber.Handler {
envID = s.proContext.EnvID
orgID = s.proContext.OrgID
}

var executionNamespaces []string
for namespace := range s.serviceAccountNames {
if namespace == s.Namespace {
continue
}

executionNamespaces = append(executionNamespaces, namespace)
}

return func(c *fiber.Ctx) error {
return c.JSON(testkube.ServerInfo{
Commit: version.Commit,
Expand All @@ -74,6 +84,7 @@ func (s *TestkubeAPI) InfoHandler() fiber.Handler {
Features: &testkube.Features{
LogsV2: s.featureFlags.LogsV2,
},
ExecutionNamespaces: executionNamespaces,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions internal/app/api/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func NewTestkubeAPI(
logGrpcClient logsclient.StreamGetter,
disableSecretCreation bool,
subscriptionChecker checktcl.SubscriptionChecker,
serviceAccountNames map[string]string,
) TestkubeAPI {

var httpConfig server.Config
Expand Down Expand Up @@ -147,6 +148,7 @@ func NewTestkubeAPI(
disableSecretCreation: disableSecretCreation,
SubscriptionChecker: subscriptionChecker,
LabelSources: common.Ptr(make([]LabelSource, 0)),
serviceAccountNames: serviceAccountNames,
}

// will be reused in websockets handler
Expand Down Expand Up @@ -210,6 +212,7 @@ type TestkubeAPI struct {
disableSecretCreation bool
SubscriptionChecker checktcl.SubscriptionChecker
LabelSources *[]LabelSource
serviceAccountNames map[string]string
}

type storageParams struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/v1/testkube/model_server_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ type ServerInfo struct {
// disable secret creation for tests and test sources
DisableSecretCreation bool `json:"disableSecretCreation,omitempty"`
Features *Features `json:"features,omitempty"`
ExecutionNamespaces []string `json:"executionNamespaces,omitempty"`
}

0 comments on commit 86c98d7

Please sign in to comment.