/** * Create a Kubernetes secret containing the provided secret data section * * @param namespace Namespace * @param name Secret name * @param data Map with secret data / files * @param labels Labels to add to the Secret * @param annotations annotations to add to the Secret * @param ownerReference owner of the Secret * @return the Secret */ public Secret createSecret(String namespace, String name, Map<String, String> data, Map<String, String> labels, Map<String, String> annotations, OwnerReference ownerReference) { List<OwnerReference> or = ownerReference != null ? singletonList(ownerReference) : emptyList(); Secret secret = new SecretBuilder() .withNewMetadata() .withName(name) .withNamespace(namespace) .withLabels(labels) .withAnnotations(annotations) .withOwnerReferences(or) .endMetadata() .withData(data) .build(); return secret; }
public static Secret createSecret(String name, String namespace, Labels labels, OwnerReference ownerReference, Map<String, String> data) { if (ownerReference == null) { return new SecretBuilder() .withNewMetadata() .withName(name) .withNamespace(namespace) .withLabels(labels.toMap()) .endMetadata() .withData(data).build(); } else { return new SecretBuilder() .withNewMetadata() .withName(name) .withOwnerReferences(ownerReference) .withNamespace(namespace) .withLabels(labels.toMap()) .endMetadata() .withData(data).build(); } }