This commit is contained in:
@@ -73,15 +73,18 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
notificationSecret, err := readCommitSecretFile("NOTIFICATION_WRITE_TOKEN_FILE")
|
||||
candidateContext, err := candidateReleaseContextFromRuntime()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
notificationSecretRef := os.Getenv("NOTIFICATION_WRITE_SECRET_REF")
|
||||
if notificationSecretRef == "" {
|
||||
log.Fatal("NOTIFICATION_WRITE_SECRET_REF is required")
|
||||
notificationSecretRef, notificationSecret, err := notificationCredentialsFromRuntime(candidateContext != nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
dispatcher := operationDispatcher{continuityExecutor: continuityExecutor, continuityReconciler: continuityExecutor, bindings: creatorCore, secretRef: notificationSecretRef, secret: notificationSecret, client: creatorHTTPClient}
|
||||
if candidateContext != nil {
|
||||
creatorCore.serviceCredential = delegatedControlPlaneCredential
|
||||
}
|
||||
dispatcher := operationDispatcher{continuityExecutor: continuityExecutor, continuityReconciler: continuityExecutor, bindings: creatorCore, secretRef: notificationSecretRef, secret: notificationSecret, client: creatorHTTPClient, candidateContext: candidateContext}
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/healthz", health.Handler{Runtime: "commit-runtime", SemanticGeneration: 1, ArchitectureGeneration: 1})
|
||||
readinessClient := &http.Client{Timeout: 2 * time.Second}
|
||||
@@ -162,6 +165,24 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// notificationCredentialsFromRuntime keeps candidate shadow execution
|
||||
// physically separate from the production notification credential mount.
|
||||
func notificationCredentialsFromRuntime(candidate bool) (string, string, error) {
|
||||
fileName, refName := "NOTIFICATION_WRITE_TOKEN_FILE", "NOTIFICATION_WRITE_SECRET_REF"
|
||||
if candidate {
|
||||
fileName, refName = "CANDIDATE_NOTIFICATION_WRITE_TOKEN_FILE", "CANDIDATE_NOTIFICATION_WRITE_SECRET_REF"
|
||||
}
|
||||
secret, err := readCommitSecretFile(fileName)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
ref := os.Getenv(refName)
|
||||
if ref == "" {
|
||||
return "", "", fmt.Errorf("%s is required", refName)
|
||||
}
|
||||
return ref, secret, nil
|
||||
}
|
||||
|
||||
func readCommitSecretFile(name string) (string, error) {
|
||||
path := os.Getenv(name)
|
||||
if path == "" {
|
||||
|
||||
Reference in New Issue
Block a user