Skip to content

Commit

Permalink
Merge branch 'main' into vsukhin/feature/trigger-regex-run-parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Jan 31, 2025
2 parents 64cb7b8 + 28fa54a commit a2f43e4
Show file tree
Hide file tree
Showing 15 changed files with 1,707 additions and 1,330 deletions.
48 changes: 42 additions & 6 deletions cmd/api-server/commons/commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"google.golang.org/protobuf/types/known/emptypb"
corev1 "k8s.io/api/core/v1"

"github.com/kubeshop/testkube/internal/common"
"github.com/kubeshop/testkube/internal/config"
dbmigrations "github.com/kubeshop/testkube/internal/db-migrations"
parser "github.com/kubeshop/testkube/internal/template"
Expand Down Expand Up @@ -289,9 +290,12 @@ func ReadProContext(ctx context.Context, cfg *config.Config, grpcClient cloud.Te
URL: cfg.ControlPlaneConfig.TestkubeProURL,
TLSInsecure: cfg.ControlPlaneConfig.TestkubeProTLSInsecure,
SkipVerify: cfg.ControlPlaneConfig.TestkubeProSkipVerify,
AgentID: cfg.ControlPlaneConfig.TestkubeProAgentID,
EnvID: cfg.ControlPlaneConfig.TestkubeProEnvID,
EnvSlug: cfg.ControlPlaneConfig.TestkubeProEnvID,
EnvName: cfg.ControlPlaneConfig.TestkubeProEnvID,
OrgID: cfg.ControlPlaneConfig.TestkubeProOrgID,
OrgSlug: cfg.ControlPlaneConfig.TestkubeProOrgID,
OrgName: cfg.ControlPlaneConfig.TestkubeProOrgID,
ConnectionTimeout: cfg.ControlPlaneConfig.TestkubeProConnectionTimeout,
WorkerCount: cfg.TestkubeProWorkerCount,
LogStreamWorkerCount: cfg.TestkubeProLogStreamWorkerCount,
Expand All @@ -301,16 +305,18 @@ func ReadProContext(ctx context.Context, cfg *config.Config, grpcClient cloud.Te
CloudStorage: grpcClient == nil,
CloudStorageSupportedInControlPlane: grpcClient == nil,
}
proContext.Agent.ID = cfg.ControlPlaneConfig.TestkubeProAgentID
proContext.Agent.Name = cfg.ControlPlaneConfig.TestkubeProAgentID

if cfg.TestkubeProAPIKey == "" || grpcClient == nil {
return proContext
}

ctx, cancel := context.WithTimeout(ctx, time.Second*3)
ctx = metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{
"api-key": cfg.TestkubeProAPIKey,
"organization-id": cfg.TestkubeProOrgID,
"agent-id": cfg.TestkubeProAgentID,
"api-key": proContext.APIKey,
"organization-id": proContext.OrgID,
"agent-id": proContext.Agent.ID,
}))
defer cancel()
foundProContext, err := grpcClient.GetProContext(ctx, &emptypb.Empty{})
Expand All @@ -323,14 +329,44 @@ func ReadProContext(ctx context.Context, cfg *config.Config, grpcClient cloud.Te
proContext.EnvID = foundProContext.EnvId
}

if proContext.AgentID == "" && strings.HasPrefix(proContext.APIKey, "tkcagnt_") {
proContext.AgentID = strings.Replace(foundProContext.EnvId, "tkcenv_", "tkcroot_", 1)
if proContext.Agent.ID == "" && strings.HasPrefix(proContext.APIKey, "tkcagnt_") {
proContext.Agent.ID = strings.Replace(foundProContext.EnvId, "tkcenv_", "tkcroot_", 1)
}

if proContext.OrgID == "" {
proContext.OrgID = foundProContext.OrgId
}

if foundProContext.OrgName != "" {
proContext.OrgName = foundProContext.OrgName
}

if foundProContext.OrgSlug != "" {
proContext.OrgSlug = foundProContext.OrgSlug
}

if foundProContext.Agent != nil && foundProContext.Agent.Id != "" {
proContext.Agent.ID = foundProContext.Agent.Id
proContext.Agent.Name = foundProContext.Agent.Name
proContext.Agent.Type = foundProContext.Agent.Type
proContext.Agent.Labels = foundProContext.Agent.Labels
proContext.Agent.Disabled = foundProContext.Agent.Disabled
proContext.Agent.Environments = common.MapSlice(foundProContext.Agent.Environments, func(env *cloud.ProContextEnvironment) config.ProContextAgentEnvironment {
return config.ProContextAgentEnvironment{
ID: env.Id,
Slug: env.Slug,
Name: env.Name,
}
})

for _, env := range foundProContext.Agent.Environments {
if env.Id == proContext.EnvID {
proContext.EnvName = env.Name
proContext.EnvSlug = env.Slug
}
}
}

if cfg.FeatureNewArchitecture && capabilities.Enabled(foundProContext.Capabilities, capabilities.CapabilityNewArchitecture) {
proContext.NewArchitecture = true
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func main() {
cfg.TestkubeDashboardURI,
proContext.OrgID,
proContext.EnvID,
proContext.AgentID,
proContext.Agent.ID,
proContext.NewArchitecture,
)

Expand Down
12 changes: 11 additions & 1 deletion cmd/testworkflow-init/data/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,19 @@ func CloudClient() controlplaneclient.Client {
URL: conn.Url,
TLSInsecure: conn.TlsInsecure,
SkipVerify: conn.SkipVerify,
AgentID: cfg.Worker.Connection.ApiKey,
EnvID: cfg.Execution.EnvironmentId,
OrgID: cfg.Execution.OrganizationId,
Agent: config.ProContextAgent{
ID: cfg.Worker.Connection.AgentID,
Name: cfg.Worker.Connection.AgentID,
Environments: []config.ProContextAgentEnvironment{
{
ID: cfg.Execution.EnvironmentId,
Slug: cfg.Execution.EnvironmentId,
Name: cfg.Execution.EnvironmentId,
},
},
},
}, controlplaneclient.ClientOptions{
StorageSkipVerify: true,
ExecutionID: cfg.Execution.Id,
Expand Down
16 changes: 15 additions & 1 deletion cmd/testworkflow-toolkit/env/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,26 @@ func loadDefaultProContext() {
URL: cfg.Worker.Connection.Url,
TLSInsecure: cfg.Worker.Connection.TlsInsecure,
SkipVerify: cfg.Worker.Connection.SkipVerify,
AgentID: cfg.Worker.Connection.AgentID,
EnvID: cfg.Execution.EnvironmentId,
EnvName: cfg.Execution.EnvironmentId,
EnvSlug: cfg.Execution.EnvironmentId,
OrgID: cfg.Execution.OrganizationId,
OrgName: cfg.Execution.OrganizationId,
OrgSlug: cfg.Execution.OrganizationId,
DashboardURI: cfg.ControlPlane.DashboardUrl,
NewArchitecture: false,
CloudStorage: false,
Agent: config3.ProContextAgent{
ID: cfg.Worker.Connection.AgentID,
Name: cfg.Worker.Connection.AgentID,
Environments: []config3.ProContextAgentEnvironment{
{
ID: cfg.Execution.EnvironmentId,
Slug: cfg.Execution.EnvironmentId,
Name: cfg.Execution.EnvironmentId,
},
},
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/executor/cypress/build/agent/Dockerfile.cypress13
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM cypress/included:13.6.1
FROM cypress/included:13.17.0
COPY cypress /bin/runner

RUN apt-get update && \
Expand Down
21 changes: 20 additions & 1 deletion internal/config/procontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ type ProContext struct {
WorkerCount int
LogStreamWorkerCount int
SkipVerify bool
AgentID string
EnvID string
EnvSlug string
EnvName string
OrgID string
OrgSlug string
OrgName string
Migrate string
ConnectionTimeout int
DashboardURI string
Expand All @@ -46,4 +49,20 @@ type ProContext struct {
IsTrial bool
Mode ProContextMode
Status ProContextStatus
Agent ProContextAgent
}

type ProContextAgentEnvironment struct {
ID string
Slug string
Name string
}

type ProContextAgent struct {
ID string
Name string
Type string
Disabled bool
Labels map[string]string
Environments []ProContextAgentEnvironment
}
Loading

0 comments on commit a2f43e4

Please sign in to comment.