Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Start ssh-agent post start event #1329

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 6 additions & 3 deletions pkg/library/ssh/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -38,20 +40,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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the command names are now unique, this unfortunately makes resolving eclipse-che/che#23144 a little bit harder (since we cannot use a hard-coded command id to be filtered out by CheCode) , but it's the only way to proceed here as the command ids must be unique.

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
}
Loading