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

SPIFFE_ENDPOINT_SOCKET env support for spire-agent #5776

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 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
19 changes: 17 additions & 2 deletions cmd/spire-agent/cli/common/defaults_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@

package common

import (
"os"
)

const (
// DefaultSocketPath is the SPIRE agent's default socket path
DefaultSocketPath = "/tmp/spire-agent/public/api.sock"
// DefaultRunSocketPath is the SPIRE agent's default socket path
DefaultRunSocketPath = "/tmp/spire-agent/public/api.sock"
// DefaultAdminSocketPath is the SPIRE agent's default admin socket path
DefaultAdminSocketPath = "/tmp/spire-agent/private/admin.sock"
)

// DefaultSocketPath is the SPIRE agent's default socket path
var DefaultSocketPath string
Comment on lines +20 to +21
Copy link
Collaborator

@MarcosDY MarcosDY Jan 21, 2025

Choose a reason for hiding this comment

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

This will be used for API calls and health checks, except for the run command, where we will continue using DefaultRunSocketPath.

Is it expected to affect health checks?
If not, should we update the code to modify the default within AddOSFlags instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We chatted about this. I believe the current plan is to do everything but run in one pr, and run in a future pr.


func init() {
DefaultSocketPath = DefaultRunSocketPath
ses := os.Getenv("SPIFFE_ENDPOINT_SOCKET")
if ses != "" {
DefaultSocketPath = ses
}
}
19 changes: 17 additions & 2 deletions cmd/spire-agent/cli/common/defaults_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@

package common

import (
"os"
)

const (
// DefaultNamedPipeName is the SPIRE agent's default named pipe name
DefaultNamedPipeName = "\\spire-agent\\public\\api"
// DefaultRunNamedPipeName is the SPIRE agent's default named pipe name
DefaultRunNamedPipeName = "\\spire-agent\\public\\api"
// DefaultAdminNamedPipeName is the SPIRE agent's default admin named pipe name
DefaultAdminNamedPipeName = "\\spire-agent\\private\\admin"
)

// DefaultNamedPipeName is the SPIRE agent's default named pipe name
var DefaultNamedPipeName string

func init() {
DefaultNamedPipeName = DefaultRunNamedPipeName
ses := os.Getenv("SPIFFE_ENDPOINT_SOCKET")
if ses != "" {
DefaultNamedPipeName = ses
}
}
2 changes: 1 addition & 1 deletion cmd/spire-agent/cli/run/run_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (c *agentConfig) addOSFlags(flags *flag.FlagSet) {
}

func (c *agentConfig) setPlatformDefaults() {
c.SocketPath = common.DefaultSocketPath
c.SocketPath = common.DefaultRunSocketPath
}

func (c *agentConfig) getAddr() (net.Addr, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-agent/cli/run/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (c *agentConfig) addOSFlags(flags *flag.FlagSet) {
}

func (c *agentConfig) setPlatformDefaults() {
c.Experimental.NamedPipeName = common.DefaultNamedPipeName
c.Experimental.NamedPipeName = common.DefaultRunNamedPipeName
}

func (c *agentConfig) getAddr() (net.Addr, error) {
Expand Down
Loading