MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / UpdateDirective

Method UpdateDirective

agent/utils/nginx/components/block.go:45–73  ·  view source on GitHub ↗
(key string, params []string)

Source from the content-addressed store, hash-verified

43}
44
45func (b *Block) UpdateDirective(key string, params []string) {
46 if key == "" || len(params) == 0 {
47 return
48 }
49 directives := b.GetDirectives()
50 index := -1
51 for i, dir := range directives {
52 if dir.GetName() == key {
53 if IsRepeatKey(key) {
54 oldParams := dir.GetParameters()
55 if !(len(oldParams) > 0 && oldParams[0] == params[0]) {
56 continue
57 }
58 }
59 index = i
60 break
61 }
62 }
63 newDirective := &Directive{
64 Name: key,
65 Parameters: params,
66 }
67 if index > -1 {
68 directives[index] = newDirective
69 } else {
70 directives = append(directives, newDirective)
71 }
72 b.Directives = directives
73}
74
75func (b *Block) RemoveDirective(key string, params []string) {
76 directives := b.GetDirectives()

Callers

nothing calls this directly

Calls 4

GetDirectivesMethod · 0.95
IsRepeatKeyFunction · 0.85
GetNameMethod · 0.65
GetParametersMethod · 0.65

Tested by

no test coverage detected