fix: 注入执行器 SPIFFE socket
This commit is contained in:
@@ -16,4 +16,4 @@ jobs:
|
|||||||
-audience ci-smoke \
|
-audience ci-smoke \
|
||||||
-socketPath /run/spire/agent-sockets/spire-agent.sock \
|
-socketPath /run/spire/agent-sockets/spire-agent.sock \
|
||||||
>/dev/null
|
>/dev/null
|
||||||
test "$(id -u)" = 0
|
test "$(id -u)" = 2000
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ func runController(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
bootstrap := runnerbootstrap.Bootstrap{
|
bootstrap := runnerbootstrap.Bootstrap{
|
||||||
Capabilities: capabilities, FacadeURL: config.FacadeURL, FacadeSPIFFEID: config.FacadeSPIFFEID,
|
Capabilities: capabilities, FacadeURL: config.FacadeURL, FacadeSPIFFEID: config.FacadeSPIFFEID,
|
||||||
|
WorkloadAPIAddr: config.WorkloadAPIAddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
labels := []string{"self-hosted"}
|
labels := []string{"self-hosted"}
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ type Bootstrap struct {
|
|||||||
Capabilities runnerfacade.Capabilities
|
Capabilities runnerfacade.Capabilities
|
||||||
FacadeURL string
|
FacadeURL string
|
||||||
FacadeSPIFFEID string
|
FacadeSPIFFEID string
|
||||||
|
WorkloadAPIAddr string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Bootstrap) Environment(assignment taskassignment.Assignment) (map[string]string, error) {
|
func (b Bootstrap) Environment(assignment taskassignment.Assignment) (map[string]string, error) {
|
||||||
if assignment.ID == "" || assignment.Identity.SPIFFEID == "" || b.FacadeSPIFFEID == "" {
|
if assignment.ID == "" || assignment.Identity.SPIFFEID == "" || b.FacadeSPIFFEID == "" || b.WorkloadAPIAddr == "" {
|
||||||
return nil, errors.New("assignment ID and SPIFFE ID are required")
|
return nil, errors.New("assignment ID and SPIFFE ID are required")
|
||||||
}
|
}
|
||||||
parsed, err := url.Parse(b.FacadeURL)
|
parsed, err := url.Parse(b.FacadeURL)
|
||||||
@@ -48,6 +49,7 @@ func (b Bootstrap) Environment(assignment taskassignment.Assignment) (map[string
|
|||||||
EnvFacadeID: b.FacadeSPIFFEID,
|
EnvFacadeID: b.FacadeSPIFFEID,
|
||||||
EnvSPIFFEID: assignment.Identity.SPIFFEID,
|
EnvSPIFFEID: assignment.Identity.SPIFFEID,
|
||||||
EnvBackend: string(assignment.Backend),
|
EnvBackend: string(assignment.Backend),
|
||||||
|
"SPIFFE_ENDPOINT_SOCKET": b.WorkloadAPIAddr,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ func testBootstrap(t *testing.T) Bootstrap {
|
|||||||
Capabilities: capabilities,
|
Capabilities: capabilities,
|
||||||
FacadeURL: "https://runner-facade.gitea-actions.svc:8443",
|
FacadeURL: "https://runner-facade.gitea-actions.svc:8443",
|
||||||
FacadeSPIFFEID: "spiffe://ddupan.top/ns/gitea-actions/sa/gitea-dynamic-runner",
|
FacadeSPIFFEID: "spiffe://ddupan.top/ns/gitea-actions/sa/gitea-dynamic-runner",
|
||||||
|
WorkloadAPIAddr: "unix:///run/spire/agent-sockets/spire-agent.sock",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +49,9 @@ func TestEnvironmentIsDeterministicAndAssignmentScoped(t *testing.T) {
|
|||||||
if first[EnvBackend] != "pod" || first[EnvFacadeID] == "" {
|
if first[EnvBackend] != "pod" || first[EnvFacadeID] == "" {
|
||||||
t.Fatalf("environment = %#v", first)
|
t.Fatalf("environment = %#v", first)
|
||||||
}
|
}
|
||||||
|
if first["SPIFFE_ENDPOINT_SOCKET"] != "unix:///run/spire/agent-sockets/spire-agent.sock" {
|
||||||
|
t.Fatalf("environment = %#v", first)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegistrationMatchesOfficialRunnerSchema(t *testing.T) {
|
func TestRegistrationMatchesOfficialRunnerSchema(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user