blob: 29bc7dafd60a72ec4ad54afcd4653cc98ccdb1da [file] [log] [blame]
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package proxy
import (
"fmt"
"os/exec"
)
// ATSManager talks to ATS
// In the future, this is the struct that should manage
// everything related to ATS
type ATSManager struct {
Namespace string
IngressClass string
}
func (m *ATSManager) IncludeIngressClass(c string) bool {
if m.IngressClass == "" {
return true
}
if m.IngressClass == c {
return true
}
return false
}
// ConfigSet configures reloadable ATS config. When there is no error,
// a message string is returned
func (m *ATSManager) ConfigSet(k, v string) (msg string, err error) {
cmd := exec.Command("traffic_ctl", "config", "set", k, v)
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to execute: traffic_ctl config set %s %s Error: %s", k, v, err.Error())
}
return fmt.Sprintf("Ran p.Key: %s p.Val: %s --> stdoutStderr: %q", k, v, stdoutStderr), nil
}