Skip to content

Commit 7291eb9

Browse files
Merge pull request #302 from wttech/feature/replication-agent-default-props
Replication agent setup: Change the way default props are handled
2 parents 4e243b3 + 2bb9607 commit 7291eb9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pkg/repl_agent.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package pkg
22

33
import (
44
"fmt"
5-
"github.com/wttech/aemc/pkg/common"
6-
"golang.org/x/exp/maps"
75
"strings"
6+
7+
"github.com/wttech/aemc/pkg/common"
88
)
99

1010
type ReplAgent struct {
@@ -47,12 +47,17 @@ func (ra ReplAgent) Setup(props map[string]any) (bool, error) {
4747
return changed, fmt.Errorf("%s > cannot read replication agent '%s' exist: %w", ra.Instance().IDColor(), pageContent.Path(), err)
4848
}
4949
if !pageContentState.Exists {
50-
maps.Copy(props, map[string]any{
50+
defaultProps := map[string]any{
5151
"jcr:primaryType": "nt:unstructured",
5252
"jcr:title": strings.ToTitle(ra.Name()),
5353
"sling:resourceType": "cq/replication/components/agent",
5454
"cq:template": "/libs/cq/replication/templates/agent",
55-
})
55+
}
56+
for k, v := range defaultProps {
57+
if _, exists := props[k]; !exists {
58+
props[k] = v
59+
}
60+
}
5661
err = pageContent.Save(props)
5762
if err != nil {
5863
return changed, fmt.Errorf("%s > cannot create replication agent '%s': %w", ra.Instance().IDColor(), pageContent.Path(), err)

0 commit comments

Comments
 (0)