feat: add imagesearch provider (#6449)
* feat: add imagesearch provider * update * update * update * update url and queries * add func getProviderTypeByHost --------- Signed-off-by: wenhaozhou <wenhaozhou@yunify.com> Signed-off-by: hongming <coder.scala@gmail.com> Co-authored-by: wenhaozhou <wenhaozhou@yunify.com>
This commit is contained in:
committed by
GitHub
parent
d412777b97
commit
1564abca4d
36
pkg/models/registries/imagesearch/configuration.go
Normal file
36
pkg/models/registries/imagesearch/configuration.go
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Please refer to the LICENSE file in the root directory of the project.
|
||||
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package imagesearch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
SecretDataKey = "configuration.yaml"
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
// The provider name.
|
||||
Name string `json:"name" yaml:"name"`
|
||||
|
||||
// The type of image search provider
|
||||
Type string `json:"type" yaml:"type"`
|
||||
|
||||
// The options of image search provider
|
||||
ProviderOptions map[string]interface{} `json:"provider" yaml:"provider"`
|
||||
}
|
||||
|
||||
func UnmarshalFrom(secret *v1.Secret) (*Configuration, error) {
|
||||
config := &Configuration{}
|
||||
if err := yaml.Unmarshal(secret.Data[SecretDataKey], config); err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal secret data: %s", err)
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
Reference in New Issue
Block a user