core/src/main/java/io/fabric8/maven/core/service/ApplyService.java
public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName) throws Exception {
        String namespace = getNamespace();
        String id = getName(serviceAccount);
        Objects.requireNonNull(id, "No name for " + serviceAccount + " " + sourceName);
        if (isServicesOnlyMode()) {
            log.debug("Only processing Services right now so ignoring ServiceAccount: " + id);
            return;
        }
        ServiceAccount old = kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).get();
        if (isRunning(old)) {
            if (UserConfigurationCompare.configEqual(serviceAccount, old)) {
                log.info("ServiceAccount has not changed so not doing anything");
            } else {
                if (isRecreateMode()) {
                    kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).delete();
                    doCreateServiceAccount(serviceAccount, namespace, sourceName);
                } else {
                    log.info("Updating a ServiceAccount from " + sourceName);
                    try {
                        Object answer = kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).replace(serviceAccount);
                        logGeneratedEntity("Updated ServiceAccount: ", namespace, serviceAccount, answer);
                    } catch (Exception e) {
                        onApplyError("Failed to update ServiceAccount from " + sourceName + ". " + e + ". " + serviceAccount, e);
                    }
                }
            }
        } else {
            if (!isAllowCreate()) {
                log.warn("Creation disabled so not creating a ServiceAccount from " + sourceName + " namespace " + namespace + " name " + getName(serviceAccount));
            } else {
                doCreateServiceAccount(serviceAccount, namespace, sourceName);
            }
        }
    }
public void applyServiceAccount(ServiceAccount serviceAccount, String sourceName) throws Exception {
        String namespace = getNamespace();
        String id = getName(serviceAccount);
        Objects.requireNonNull(id, "No name for " + serviceAccount + " " + sourceName);
        if (isServicesOnlyMode()) {
            log.debug("Only processing Services right now so ignoring ServiceAccount: " + id);
            return;
        }
        ServiceAccount old = kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).get();
        if (isRunning(old)) {
            if (UserConfigurationCompare.configEqual(serviceAccount, old)) {
                log.info("ServiceAccount has not changed so not doing anything");
            } else {
                if (isRecreateMode()) {
                    kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).delete();
                    doCreateServiceAccount(serviceAccount, namespace, sourceName);
                } else {
                    log.info("Updating a ServiceAccount from " + sourceName);
                    try {
                        Object answer = kubernetesClient.serviceAccounts().inNamespace(namespace).withName(id).replace(serviceAccount);
                        logGeneratedEntity("Updated ServiceAccount: ", namespace, serviceAccount, answer);
                    } catch (Exception e) {
                        onApplyError("Failed to update ServiceAccount from " + sourceName + ". " + e + ". " + serviceAccount, e);
                    }
                }
            }
        } else {
            if (!isAllowCreate()) {
                log.warn("Creation disabled so not creating a ServiceAccount from " + sourceName + " namespace " + namespace + " name " + getName(serviceAccount));
            } else {
                doCreateServiceAccount(serviceAccount, namespace, sourceName);
            }
        }
    }
public void applyServiceAccount ( ServiceAccount serviceAccount , String sourceName ) throws Exception { String namespace = getNamespace ( ) ; String id = getName ( serviceAccount ) ; Objects . requireNonNull ( id , "No name for " + serviceAccount + " " + sourceName ) ; if ( isServicesOnlyMode ( ) ) { log . debug ( "Only processing Services right now so ignoring ServiceAccount: " + id ) ; return ; } ServiceAccount old = kubernetesClient . serviceAccounts ( ) . inNamespace ( namespace ) . withName ( id ) . get ( ) ; if ( isRunning ( old ) ) { if ( UserConfigurationCompare . configEqual ( serviceAccount , old ) ) { log . info ( "ServiceAccount has not changed so not doing anything" ) ; } else { if ( isRecreateMode ( ) ) { kubernetesClient . serviceAccounts ( ) . inNamespace ( namespace ) . withName ( id ) . delete ( ) ; doCreateServiceAccount ( serviceAccount , namespace , sourceName ) ; } else { log . info ( "Updating a ServiceAccount from " + sourceName ) ; try { Object answer = kubernetesClient . serviceAccounts ( ) . inNamespace ( namespace ) . withName ( id ) . replace ( serviceAccount ) ; logGeneratedEntity ( "Updated ServiceAccount: " , namespace , serviceAccount , answer ) ; } catch ( Exception e ) { onApplyError ( "Failed to update ServiceAccount from " + sourceName + ". " + e + ". " + serviceAccount , e ) ; } } } } else { if ( ! isAllowCreate ( ) ) { log . warn ( "Creation disabled so not creating a ServiceAccount from " + sourceName + " namespace " + namespace + " name " + getName ( serviceAccount ) ) ; } else { doCreateServiceAccount ( serviceAccount , namespace , sourceName ) ; } } }
Creates/updates a service account and processes it returning the processed DTOs
Creates / updates a service account and processes it returning the processed DTOs