|
|
@@ -0,0 +1,43 @@
|
|
|
+package nju.seec.SEECdemo.logic.api.k8s.vo;
|
|
|
+
|
|
|
+import io.kubernetes.client.models.V1Secret;
|
|
|
+import lombok.Data;
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
+import nju.seec.SEECdemo.logic.api.k8s.util.SecretTypeEnum;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * author: rale
|
|
|
+ * createdAt: 1/3/19
|
|
|
+ */
|
|
|
+@Data
|
|
|
+@NoArgsConstructor
|
|
|
+public class SecretVO {
|
|
|
+
|
|
|
+ private String name;
|
|
|
+
|
|
|
+ private String namespace;
|
|
|
+
|
|
|
+ private Map<String, String> data;
|
|
|
+
|
|
|
+ private SecretTypeEnum secretType;
|
|
|
+
|
|
|
+ public SecretVO(V1Secret v1Secret) {
|
|
|
+ this.name = v1Secret.getMetadata().getName();
|
|
|
+ this.namespace = v1Secret.getMetadata().getNamespace();
|
|
|
+ this.data = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(v1Secret.getStringData())) {
|
|
|
+ data.putAll(v1Secret.getStringData());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(v1Secret.getData())) {
|
|
|
+ for (Map.Entry<String, byte[]> entry : v1Secret.getData().entrySet()){
|
|
|
+ data.put(entry.getKey(), new String(entry.getValue(), StandardCharsets.UTF_8));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.secretType = SecretTypeEnum.getByValue(v1Secret.getType());
|
|
|
+ }
|
|
|
+}
|