Skip to content

Commit 347cd86

Browse files
committed
docs(sdk/provisioner): document new behaviours
1 parent 7cd21b3 commit 347cd86

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sdk/provisioner.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ func (out *ProvisionOutput) AddEnvVar(name string, value string) {
102102
out.Environment[name] = value
103103
}
104104

105+
// AddArgsAtIndex inserts additional arguments into the command line at the specified index.
106+
// - If position is -1 or greater than the current length, the arguments are appended.
107+
// - If position is 0 or negative, the arguments are prepended.
108+
// - Otherwise, the arguments are inserted at the specified index, shifting existing elements forward.
105109
func (out *ProvisionOutput) AddArgsAtIndex(position int, args ...string) {
106110
if position == -1 || position >= len(out.CommandLine) {
107111
out.CommandLine = append(out.CommandLine, args...)
@@ -116,12 +120,14 @@ func (out *ProvisionOutput) AddArgsAtIndex(position int, args ...string) {
116120
out.CommandLine = append(out.CommandLine[:position], append(args, out.CommandLine[position:]...)...)
117121
}
118122

119-
// PrependArgs can be used to add additional arguments to the command line of the provision output.
123+
// PrependArgs inserts additional arguments at the beginning of the command line, after the first argument.
124+
// This ensures that the first argument (typically the executable name) remains unchanged.
120125
func (out *ProvisionOutput) PrependArgs(args ...string) {
121126
out.AddArgsAtIndex(1, args...)
122127
}
123128

124-
// AppendArgs can be used to add additional arguments to the command line of the provision output.
129+
// AppendArgs appends additional arguments to the end of the command line.
130+
// This ensures that new arguments are always added last, preserving existing order.
125131
func (out *ProvisionOutput) AppendArgs(args ...string) {
126132
out.AddArgsAtIndex(-1, args...)
127133
}

0 commit comments

Comments
 (0)