update dependencies (#6267)

Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
hongming
2024-11-06 10:27:06 +08:00
committed by GitHub
parent faf255a084
commit cfebd96a1f
4263 changed files with 341374 additions and 132036 deletions

View File

@@ -41,30 +41,36 @@ func (rf *Factory) Hasher() ifc.KustHasher {
}
// FromMap returns a new instance of Resource.
func (rf *Factory) FromMap(m map[string]interface{}) *Resource {
return rf.FromMapAndOption(m, nil)
func (rf *Factory) FromMap(m map[string]interface{}) (*Resource, error) {
res, err := rf.FromMapAndOption(m, nil)
if err != nil {
return nil, fmt.Errorf("failed to create resource from map: %w", err)
}
return res, nil
}
// FromMapWithName returns a new instance with the given "original" name.
func (rf *Factory) FromMapWithName(n string, m map[string]interface{}) *Resource {
func (rf *Factory) FromMapWithName(n string, m map[string]interface{}) (*Resource, error) {
return rf.FromMapWithNamespaceAndName(resid.DefaultNamespace, n, m)
}
// FromMapWithNamespaceAndName returns a new instance with the given "original" namespace.
func (rf *Factory) FromMapWithNamespaceAndName(ns string, n string, m map[string]interface{}) *Resource {
r := rf.FromMapAndOption(m, nil)
return r.setPreviousId(ns, n, r.GetKind())
func (rf *Factory) FromMapWithNamespaceAndName(ns string, n string, m map[string]interface{}) (*Resource, error) {
r, err := rf.FromMapAndOption(m, nil)
if err != nil {
return nil, fmt.Errorf("failed to create resource from map: %w", err)
}
return r.setPreviousId(ns, n, r.GetKind()), nil
}
// FromMapAndOption returns a new instance of Resource with given options.
func (rf *Factory) FromMapAndOption(
m map[string]interface{}, args *types.GeneratorArgs) *Resource {
m map[string]interface{}, args *types.GeneratorArgs) (*Resource, error) {
n, err := yaml.FromMap(m)
if err != nil {
// TODO: return err instead of log.
log.Fatal(err)
return nil, fmt.Errorf("failed to convert map to YAML node: %w", err)
}
return rf.makeOne(n, args)
return rf.makeOne(n, args), nil
}
// makeOne returns a new instance of Resource.

View File

@@ -287,12 +287,25 @@ func (r *Resource) getCsvAnnotation(name string) []string {
return strings.Split(annotations[name], ",")
}
// PrefixesSuffixesEquals is conceptually doing the same task
// as OutermostPrefixSuffix but performs a deeper comparison
// of the suffix and prefix slices.
func (r *Resource) PrefixesSuffixesEquals(o ResCtx) bool {
return utils.SameEndingSubSlice(r.GetNamePrefixes(), o.GetNamePrefixes()) &&
utils.SameEndingSubSlice(r.GetNameSuffixes(), o.GetNameSuffixes())
// PrefixesSuffixesEquals is conceptually doing the same task as
// OutermostPrefixSuffix but performs a deeper comparison of the suffix and
// prefix slices.
// The allowEmpty flag determines whether an empty prefix/suffix
// should be considered a match on anything.
// This is used when filtering, starting with a coarser pass allowing empty
// matches, before requiring exact matches if there are multiple
// remaining candidates.
func (r *Resource) PrefixesSuffixesEquals(o ResCtx, allowEmpty bool) bool {
if allowEmpty {
eitherPrefixEmpty := len(r.GetNamePrefixes()) == 0 || len(o.GetNamePrefixes()) == 0
eitherSuffixEmpty := len(r.GetNameSuffixes()) == 0 || len(o.GetNameSuffixes()) == 0
return (eitherPrefixEmpty || utils.SameEndingSubSlice(r.GetNamePrefixes(), o.GetNamePrefixes())) &&
(eitherSuffixEmpty || utils.SameEndingSubSlice(r.GetNameSuffixes(), o.GetNameSuffixes()))
} else {
return utils.SameEndingSubSlice(r.GetNamePrefixes(), o.GetNamePrefixes()) &&
utils.SameEndingSubSlice(r.GetNameSuffixes(), o.GetNameSuffixes())
}
}
// RemoveBuildAnnotations removes annotations created by the build process.