package plugin

// IDShort returns the first 8 chars of a workload ID, used as the uniqueness
// suffix on the Docker resources (container, image, volume) a source plugin
// materializes. Workload names are not UNIQUE in the schema today; including
// the ID short prevents two workloads with the same name from clobbering each
// other's container, image, or storage volume.
//
// Shared by the source plugins (static, dockerfile). Each plugin still owns
// its own container/image NAME format (the human-readable prefix differs by
// source kind) — only the ID-short derivation is common.
func IDShort(w Workload) string {
	if len(w.ID) < 8 {
		return w.ID
	}
	return w.ID[:8]
}
