From bbd4f1dea129757f9404082b2ec50e57e72b127d Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 29 Sep 2025 21:23:17 -0400 Subject: [PATCH] engine: Add a utility function to copy the Init struct --- engine/resources.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/engine/resources.go b/engine/resources.go index 0eb04a11..1a23574b 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -208,6 +208,27 @@ type Init struct { Logf func(format string, v ...interface{}) } +// Copy makes a copy of this Init struct, with all of the same elements inside. +func (obj *Init) Copy() *Init { + return &Init{ + Program: obj.Program, + Version: obj.Version, + Hostname: obj.Hostname, + Running: obj.Running, + Event: obj.Event, + Refresh: obj.Refresh, + Send: obj.Send, + Recv: obj.Recv, + //Graph: obj.Graph, // TODO: not implemented, use FilteredGraph + FilteredGraph: obj.FilteredGraph, + Local: obj.Local, + World: obj.World, + VarDir: obj.VarDir, + Debug: obj.Debug, + Logf: obj.Logf, + } +} + // KindedRes is an interface that is required for a resource to have a kind. type KindedRes interface { // Kind returns a string representing the kind of resource this is.