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

Method UpdateDirective

agent/utils/nginx/components/upstream.go:84–112  ·  view source on GitHub ↗
(key string, params []string)

Source from the content-addressed store, hash-verified

82}
83
84func (us *Upstream) UpdateDirective(key string, params []string) {
85 if key == "" {
86 return
87 }
88 directives := us.Directives
89 index := -1
90 for i, dir := range directives {
91 if dir.GetName() == key {
92 if IsRepeatKey(key) {
93 oldParams := dir.GetParameters()
94 if !(len(oldParams) > 0 && oldParams[0] == params[0]) {
95 continue
96 }
97 }
98 index = i
99 break
100 }
101 }
102 newDirective := &Directive{
103 Name: key,
104 Parameters: params,
105 }
106 if index > -1 {
107 directives[index] = newDirective
108 } else {
109 directives = append(directives, newDirective)
110 }
111 us.Directives = directives
112}
113
114func (us *Upstream) RemoveDirective(key string, params []string) {
115 directives := us.Directives

Callers 3

CreateLoadBalanceMethod · 0.95
configDefaultNginxFunction · 0.95
UpdateStreamMethod · 0.95

Calls 3

IsRepeatKeyFunction · 0.85
GetNameMethod · 0.65
GetParametersMethod · 0.65

Tested by

no test coverage detected