MCPcopy Create free account
hub / github.com/github/gh-aw / insertSandboxAfterNetworkBlock

Function insertSandboxAfterNetworkBlock

pkg/cli/codemod_network_firewall.go:129–153  ·  view source on GitHub ↗
(lines []string, sandboxLines []string)

Source from the content-addressed store, hash-verified

127}
128
129func insertSandboxAfterNetworkBlock(lines []string, sandboxLines []string) []string {
130 insertIndex := -1
131 inNetworkBlock := false
132 for i, line := range lines {
133 trimmed := strings.TrimSpace(line)
134 if strings.HasPrefix(trimmed, "network:") {
135 inNetworkBlock = true
136 continue
137 }
138 if inNetworkBlock && len(trimmed) > 0 && isTopLevelKey(line) {
139 insertIndex = i
140 break
141 }
142 }
143
144 if insertIndex >= 0 {
145 newLines := make([]string, 0, len(lines)+len(sandboxLines))
146 newLines = append(newLines, lines[:insertIndex]...)
147 newLines = append(newLines, sandboxLines...)
148 newLines = append(newLines, lines[insertIndex:]...)
149 return newLines
150 }
151
152 return append(lines, sandboxLines...)
153}
154
155func mergeFirewallIntoExistingSandbox(lines []string, fieldValue any) ([]string, bool) {
156 agentLines := sandboxAgentLinesForExistingSandbox(fieldValue)

Callers 1

Calls 1

isTopLevelKeyFunction · 0.85

Tested by

no test coverage detected