-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable hairpin for kube-router by default
We agreed that the most logical decision was to enable hairpin by default. The old configuration doesn't reflect our real needs, for this reason we decided to deprecate the old configuration and add a new configuration. This commit handles all these details. Fixes #1953 Co-authored-by: Tom Wieczorek <twz123@users.noreply.github.com> Signed-off-by: Juan-Luis de Sousa-Valadas Castaño <jvaladas@mirantis.com>
- Loading branch information
1 parent
8f89bab
commit d005baf
Showing
8 changed files
with
254 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
Copyright 2022 k0s authors | ||
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 v1beta1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type KubeRouterSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func TestUnmarshalJSON(t *testing.T) { | ||
|
||
type unmarshalTestCases struct { | ||
input string | ||
expectedOutput HairpinModeValues | ||
expectsError bool | ||
} | ||
|
||
tests := []unmarshalTestCases{ | ||
{ | ||
input: "\"enabled\"", | ||
expectedOutput: HairpinEnabled, | ||
expectsError: false, | ||
}, | ||
{ | ||
input: "\"ALLOWED\"", | ||
expectedOutput: HairpinAllowed, | ||
expectsError: false, | ||
}, | ||
{ | ||
input: "\"DiSaBlEd\"", | ||
expectedOutput: HairpinDisabled, | ||
expectsError: false, | ||
}, | ||
{ | ||
input: "\"true\"", | ||
expectsError: true, | ||
}, | ||
{ | ||
input: "true", | ||
expectedOutput: HairpinEnabled, | ||
expectsError: false, | ||
}, | ||
{ | ||
input: "false", | ||
expectedOutput: HairpinDisabled, | ||
expectsError: false, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
var hm HairpinMode | ||
err := hm.UnmarshalJSON([]byte(tc.input)) | ||
if tc.expectedOutput != hm.Value { | ||
t.Fatalf("Testcase (%#v) expected %s and got %s", tc, tc.expectedOutput, hm.Value) | ||
} | ||
|
||
if tc.expectsError && err == nil { | ||
t.Fatalf("Testcase (%#v) was expected to fail ", tc) | ||
} else if !tc.expectsError && err != nil { | ||
t.Fatalf("Testcase (%#v) was expected to fail with error: (%#v) ", tc, err) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
pkg/apis/k0s.k0sproject.io/v1beta1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.