mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-11 14:22:08 +08:00
【修改】k8s 配置
This commit is contained in:
43
apps/devops/services/k8s/secret/secret_detail.go
Normal file
43
apps/devops/services/k8s/secret/secret_detail.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package secret
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"pandax/base/global"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
// SecretDetail API resource provides mechanisms to inject containers with configuration data while keeping
|
||||
// containers agnostic of Kubernetes
|
||||
type SecretDetail struct {
|
||||
// Extends list item structure.
|
||||
Secret `json:",inline"`
|
||||
|
||||
// Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN
|
||||
// or leading dot followed by valid DNS_SUBDOMAIN.
|
||||
// The serialized form of the secret data is a base64 encoded string,
|
||||
// representing the arbitrary (possibly non-string) data value here.
|
||||
Data map[string][]byte `json:"data"`
|
||||
}
|
||||
|
||||
// GetSecretDetail returns detailed information about a secret
|
||||
func GetSecretDetail(client kubernetes.Interface, namespace, name string) (*SecretDetail, error) {
|
||||
global.Log.Info(fmt.Sprintf("Getting details of %s secret in %s namespace", name, namespace))
|
||||
|
||||
rawSecret, err := client.CoreV1().Secrets(namespace).Get(context.TODO(), name, metaV1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return getSecretDetail(rawSecret), nil
|
||||
}
|
||||
|
||||
func getSecretDetail(rawSecret *v1.Secret) *SecretDetail {
|
||||
return &SecretDetail{
|
||||
Secret: toSecret(rawSecret),
|
||||
Data: rawSecret.Data,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user