Service Proposal Merger (proposal/merge.go)

agent-vault · internal/proposal/merge.go · go · MIT
infra, lang:go, tag:merge, tag:broker, tag:service-management, tag:validation

Merges proposed broker service changes into an existing service list, applying upserts and deletes keyed by Name, returning merged results and no-op warnings.

// Source: https://github.com/Infisical/agent-vault | License: MIT | Copyright 2022 Infisical Inc
// Provided via justclaw.it.com; keep this notice with the code.
package proposal

import (
	"fmt"

	"github.com/Infisical/agent-vault/internal/broker"
)

// MergeServices upserts and deletes by Name. Callers must normalize
// every input (existing + proposed) to have a non-empty Name first;
// MergeServices panics otherwise because the Name-keyed index would
// silently collapse empty-name entries onto the "" key and overwrite
// unrelated services — a data-loss class bug not worth papering over.
// Returns the merged slice and warnings for no-op operations.
func MergeServices(existing []broker.Service, proposed []Service) ([]broker.Service, []string) {
	for i, s := range existing {
		if s.Na

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key