Files
kubesphere/pkg/models/registries/imagesearch/configuration.go
KubeSphere CI Bot 1564abca4d 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>
2025-03-19 11:03:58 +08:00

37 lines
830 B
Go

/*
* 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
}