unit-test: add unit test for pkg/ingress/kube/annotations (#156)

Signed-off-by: charlie <qianglin98@qq.com>
This commit is contained in:
charlie
2023-02-02 15:22:11 +08:00
committed by GitHub
parent 1092402516
commit 7ceec94a87
6 changed files with 479 additions and 1 deletions

View File

@@ -37,7 +37,7 @@ type DestinationConfig struct {
type destination struct{}
func (a destination) Parse(annotations Annotations, config *Ingress, globalContext *GlobalContext) error {
func (a destination) Parse(annotations Annotations, config *Ingress, _ *GlobalContext) error {
if !needDestinationConfig(annotations) {
return nil
}
@@ -55,6 +55,9 @@ func (a destination) Parse(annotations Annotations, config *Ingress, globalConte
pairs := strings.Fields(line)
var weight int64 = 100
var addrIndex int
if len(pairs) == 0 {
continue
}
if strings.HasSuffix(pairs[0], "%") {
weight, err = strconv.ParseInt(strings.TrimSuffix(pairs[0], "%"), 10, 32)
if err != nil {