mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
* Feat: filter by source addon in `vela def list` Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: change header year to 2022 Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: use generic filters for extensibility Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: change variable addonFilter to addonName Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: update tests according to code changes Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Refactor: unify SearchDefinition params using filters Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: simplify tests Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: remove redundant code Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests with multiple filters Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: show SOURCE-ADDON column in `def list`, if any Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: add addon filter to apiserver definition-lists Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: fix lint issues Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Chore: update swagger doc accordingly Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests for filter Applying Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: add a helper function to apply filters to lists Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Style: format imports Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Feat: add OwnerAddon to DefinitionBase Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add tests for OwnerAddon field Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com> * Test: add addon util tests Signed-off-by: Charlie Chiang <charlie_c_0129@outlook.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
/*
|
|
Copyright 2022 The KubeVela 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 addon
|
|
|
|
import "strings"
|
|
|
|
// AddonSecPrefix is the prefix for secret of addons
|
|
const AddonSecPrefix = "addon-secret-"
|
|
|
|
// Addon2SecName returns the secret name that contains addon arguments
|
|
func Addon2SecName(addonName string) string {
|
|
if addonName == "" {
|
|
return ""
|
|
}
|
|
|
|
return AddonSecPrefix + addonName
|
|
}
|
|
|
|
// AddonAppPrefix is the prefix for corresponding Application of an addon
|
|
const AddonAppPrefix = "addon-"
|
|
|
|
// Addon2AppName return the app name that represents the addon
|
|
func Addon2AppName(addonName string) string {
|
|
if addonName == "" {
|
|
return ""
|
|
}
|
|
|
|
return AddonAppPrefix + addonName
|
|
}
|
|
|
|
// AppName2Addon converts an addon app name to the actual addon name
|
|
// If it is not a addon app name, empty string is returned.
|
|
func AppName2Addon(appName string) string {
|
|
if !strings.HasPrefix(appName, AddonAppPrefix) {
|
|
return ""
|
|
}
|
|
|
|
return appName[len(AddonAppPrefix):]
|
|
}
|