Skip to content

Commit

Permalink
Fix Start ssh-agent post start event
Browse files Browse the repository at this point in the history
  • Loading branch information
vinokurig committed Oct 21, 2024
1 parent 75c2a60 commit 2988be1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (

HomeInitEventId = "init-persistent-home"

SshAgentStartEventId = "init-ssh-agent"
SshAgentStartEventId = "init-ssh-agent-command"

ServiceAccount = "devworkspace"

Expand Down
8 changes: 5 additions & 3 deletions pkg/library/ssh/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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"
Expand All @@ -38,20 +39,21 @@ 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,
Component: component.Name,
},
},
})
spec.Events.PostStart = append(spec.Events.PostStart, commandId)
}
spec.Events.PostStart = append(spec.Events.PostStart, constants.SshAgentStartEventId)
return err
}

0 comments on commit 2988be1

Please sign in to comment.