private String validateAndGetReplicaName(AuthConfig authConfig, String appName, String serviceName, String replicaName,
                                             String namespace) throws HyscaleException {

        // Fetch latest replicas of the given service & app in the namespace
        // if replica is not provided by the user , validation happens on all the replicas of that service
        // if replica is provides by the user, validation happens only on the latest replicas of the service
        List<ReplicaInfo> replicaInfoList = replicaProcessingService.getReplicas(appName, serviceName, namespace, replicaName != null ? false : true);
        if (replicaInfoList == null || replicaInfoList.isEmpty()) {
            if (replicaProcessingService.hasService(authConfig, appName, serviceName, namespace)) {
                WorkflowLogger.error(DeployerActivity.SERVICE_WITH_ZERO_REPLICAS);
            } else {
                WorkflowLogger.error(ControllerActivity.SERVICE_NOT_CREATED);
                WorkflowLogger.error(ControllerActivity.CHECK_SERVICE_STATUS);
            }
            WorkflowLogger.footer();
            return null;
        }

        // Replica is not provided by the user
        if (replicaName == null) {
            ReplicaInfo replicaInfo = null;
            // If a single replica exists , consume replica name from cluster directly
            if (replicaInfoList.size() == 1) {
                replicaInfo = replicaInfoList.get(0);
            }
            // interactively consume the replica name from the user if replicaInfo is null
            return replicaInfo != null ? replicaInfo.getName() : serviceLogsInputHandler.getPodFromUser(replicaInfoList);
        }

        if (!replicaProcessingService.doesReplicaExist(replicaName, replicaInfoList)) {
            StringBuilder pods = new StringBuilder();
            replicaInfoList.stream().filter(Objects::nonNull).forEach(each -> pods.append(each.getName() + ", "));
            WorkflowLogger.error(ControllerActivity.REPLICA_DOES_NOT_EXIT, replicaName,
                    HyscaleStringUtil.removeSuffixStr(pods, ", "));
            WorkflowLogger.footer();
            HyscaleException ex = new HyscaleException(DeployerErrorCodes.REPLICA_DOES_NOT_EXIT, replicaName);
            throw ex;
        }

        return replicaName;
    }
implementation :
<b>
1. Replica name provided by user, validate and return replica name
2. Replica name not provided by user
     a. If single replica, return replica name
     b. else prompt user to provide replica name
</b>

@param authConfig
@param appName
@param serviceName
@param replicaName
@param namespace
@return replica name
@throws HyscaleException
workflow-controller/controller-service/src/main/java/io/hyscale/controller/util/LoggerUtility.java