2021-03-18 22:40:29 +00:00
|
|
|
// Copyright 2020 The Kubernetes Authors.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package provider
|
|
|
|
|
|
|
|
import (
|
2021-05-14 17:12:55 +00:00
|
|
|
"sigs.k8s.io/kustomize/api/hasher"
|
2021-03-18 22:40:29 +00:00
|
|
|
"sigs.k8s.io/kustomize/api/ifc"
|
|
|
|
"sigs.k8s.io/kustomize/api/internal/validate"
|
|
|
|
"sigs.k8s.io/kustomize/api/resource"
|
|
|
|
)
|
|
|
|
|
2021-05-14 17:12:55 +00:00
|
|
|
// DepProvider is a dependency provider, injecting different
|
|
|
|
// implementations depending on the context.
|
2021-03-18 22:40:29 +00:00
|
|
|
type DepProvider struct {
|
2021-05-14 17:12:55 +00:00
|
|
|
resourceFactory *resource.Factory
|
|
|
|
// implemented by api/internal/validate.FieldValidator
|
|
|
|
// See TODO inside the validator for status.
|
|
|
|
// At time of writing, this is a do-nothing
|
|
|
|
// validator as it's not critical to kustomize function.
|
|
|
|
fieldValidator ifc.Validator
|
2021-03-18 22:40:29 +00:00
|
|
|
}
|
|
|
|
|
2021-05-14 17:12:55 +00:00
|
|
|
func NewDepProvider() *DepProvider {
|
|
|
|
rf := resource.NewFactory(&hasher.Hasher{})
|
2021-03-18 22:40:29 +00:00
|
|
|
return &DepProvider{
|
2021-05-14 17:12:55 +00:00
|
|
|
resourceFactory: rf,
|
|
|
|
fieldValidator: validate.NewFieldValidator(),
|
2021-03-18 22:40:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDefaultDepProvider() *DepProvider {
|
2021-05-14 17:12:55 +00:00
|
|
|
return NewDepProvider()
|
2021-03-18 22:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dp *DepProvider) GetResourceFactory() *resource.Factory {
|
|
|
|
return dp.resourceFactory
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dp *DepProvider) GetFieldValidator() ifc.Validator {
|
|
|
|
return dp.fieldValidator
|
|
|
|
}
|