From 653bde7f7157662bd2cc3aae067232a9b5c51fa0 Mon Sep 17 00:00:00 2001 From: ivinokur Date: Mon, 21 Oct 2024 12:50:17 +0300 Subject: [PATCH] Fix Start ssh-agent post start event Signed-off-by: ivinokur --- pkg/constants/constants.go | 2 +- pkg/library/ssh/event.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index d50079c2c..e5e021200 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -45,7 +45,7 @@ const ( HomeInitEventId = "init-persistent-home" - SshAgentStartEventId = "init-ssh-agent" + SshAgentStartEventId = "init-ssh-agent-command" ServiceAccount = "devworkspace" diff --git a/pkg/library/ssh/event.go b/pkg/library/ssh/event.go index 309506e97..7ebdca1e4 100644 --- a/pkg/library/ssh/event.go +++ b/pkg/library/ssh/event.go @@ -14,6 +14,8 @@ package ssh import ( + "fmt" + "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" "github.com/devfile/devworkspace-operator/pkg/constants" "github.com/devfile/devworkspace-operator/pkg/library/lifecycle" @@ -38,12 +40,13 @@ func AddSshAgentPostStartEvent(spec *v1alpha2.DevWorkspaceTemplateSpec) error { } _, mainComponents, err := lifecycle.GetInitContainers(spec.DevWorkspaceTemplateSpecContent) - for _, component := range mainComponents { + for id, component := range mainComponents { if component.Container == nil { continue } + commandId := fmt.Sprintf("%s-%d", constants.SshAgentStartEventId, id) spec.Commands = append(spec.Commands, v1alpha2.Command{ - Id: constants.SshAgentStartEventId, + Id: commandId, CommandUnion: v1alpha2.CommandUnion{ Exec: &v1alpha2.ExecCommand{ CommandLine: commandLine, @@ -51,7 +54,7 @@ func AddSshAgentPostStartEvent(spec *v1alpha2.DevWorkspaceTemplateSpec) error { }, }, }) + spec.Events.PostStart = append(spec.Events.PostStart, commandId) } - spec.Events.PostStart = append(spec.Events.PostStart, constants.SshAgentStartEventId) return err }