-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MINOR: arguments: add IC arg to allow disabling one or several config…
… snippet types
- Loading branch information
1 parent
5a55fb7
commit 5846dd5
Showing
13 changed files
with
250 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.vscode/* | ||
.idea/* | ||
.test/* | ||
kubernetes-ingress | ||
dist/ | ||
.code-generator/ | ||
|
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
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,97 @@ | ||
// Copyright 2023 HAProxy Technologies LLC | ||
// | ||
// 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 annotations | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func Test_DisableConfigSnippets(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
disableConfigSnippets string | ||
want map[cfgSnippetType]struct{} | ||
}{ | ||
{ | ||
name: "No meaningful value", | ||
disableConfigSnippets: "invalid", | ||
want: map[cfgSnippetType]struct{}{}, | ||
}, | ||
{ | ||
name: "all", | ||
disableConfigSnippets: "all", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetBackend: {}, | ||
configSnippetFrontend: {}, | ||
configSnippetGlobal: {}, | ||
}, | ||
}, | ||
{ | ||
name: "frontend only", | ||
disableConfigSnippets: "frontend", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetFrontend: {}, | ||
}, | ||
}, | ||
{ | ||
name: "backend only", | ||
disableConfigSnippets: "backend", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetBackend: {}, | ||
}, | ||
}, | ||
{ | ||
name: "global only", | ||
disableConfigSnippets: "global", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetGlobal: {}, | ||
}, | ||
}, | ||
{ | ||
name: "frontend and backend", | ||
disableConfigSnippets: "backend,frontend", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetFrontend: {}, | ||
configSnippetBackend: {}, | ||
}, | ||
}, | ||
{ | ||
name: "frontend and global, whitespaces", | ||
disableConfigSnippets: " frontend, global", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetGlobal: {}, | ||
configSnippetFrontend: {}, | ||
}, | ||
}, | ||
{ | ||
name: "frontend global, backend", | ||
disableConfigSnippets: "backend,global,frontend", | ||
want: map[cfgSnippetType]struct{}{ | ||
configSnippetBackend: {}, | ||
configSnippetFrontend: {}, | ||
configSnippetGlobal: {}, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
DisableConfigSnippets(tt.disableConfigSnippets) | ||
if !reflect.DeepEqual(cfgSnippet.disabledSnippets, tt.want) { | ||
t.Errorf("DisabledConfigSnippets() = %v, want %v", cfgSnippet.disabledSnippets, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.