private static void showRandomFailureMessage() { if (ThreadLocalRandom.current().nextInt(0, 100) < 5) { int index = ThreadLocalRandom.current().nextInt(0, failureMessages.length); String message = failureMessages[index]; AnsiUi.failure(message); } }
private static void showRandomFailureMessage() { if (ThreadLocalRandom.current().nextInt(0, 100) < 5) { int index = ThreadLocalRandom.current().nextInt(0, failureMessages.length); String message = failureMessages[index]; AnsiUi.failure(message); } }
@Override protected void executeThis() { String accountName = getArtifactAccountName(); String providerName = getArtifactProviderName(); String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. ArtifactAccount account = new OperationHandler<ArtifactAccount>() .setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".") .setOperation(Daemon.getArtifactAccount(currentDeployment, providerName, accountName, false)) .get(); int originaHash = account.hashCode(); account = editArtifactAccount((T) account); if (originaHash == account.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setFailureMesssage("Failed to edit artifact account " + accountName + " for artifact provider " + providerName + ".") .setSuccessMessage("Successfully edited artifact account " + accountName + " for artifact provider " + providerName + ".") .setOperation(Daemon.setArtifactAccount(currentDeployment, providerName, accountName, !noValidate, account)) .get(); } }
@Override protected void executeThis() { String providerName = getProviderName(); String currentDeployment = getCurrentDeployment(); Provider provider = new OperationHandler<Provider>() .setFailureMesssage("Failed to get provider " + providerName + ".") .setOperation(Daemon.getProvider(currentDeployment, providerName, false)) .get(); int originalHash = provider.hashCode(); provider = editProvider((P) provider); if (originalHash == provider.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setFailureMesssage("Failed to edit provider " + providerName + ".") .setSuccessMessage("Successfully edited provider " + providerName + ".") .setOperation(Daemon.setProvider(currentDeployment, providerName, !noValidate, provider)) .get(); }
@Override protected void executeThis() { String providerName = getProviderName(); String currentDeployment = getCurrentDeployment(); Provider provider = new OperationHandler<Provider>() .setFailureMesssage("Failed to get provider " + providerName + ".") .setOperation(Daemon.getProvider(currentDeployment, providerName, false)) .get(); int originalHash = provider.hashCode(); provider = editProvider((P) provider); if (originalHash == provider.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setFailureMesssage("Failed to edit provider " + providerName + ".") .setSuccessMessage("Successfully edited provider " + providerName + ".") .setOperation(Daemon.setProvider(currentDeployment, providerName, !noValidate, provider)) .get(); }
@Override protected void executeThis() { String persistentStoreType = getPersistentStoreType(); String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. PersistentStore persistentStore = new OperationHandler<PersistentStore>() .setFailureMesssage("Failed to get persistent store \"" + persistentStoreType + "\".") .setOperation(Daemon.getPersistentStore(currentDeployment, persistentStoreType, false)) .get(); int originalHash = persistentStore.hashCode(); persistentStore = editPersistentStore((T) persistentStore); if (originalHash == persistentStore.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setFailureMesssage("Failed to edit persistent store \"" + persistentStoreType + "\".") .setSuccessMessage("Successfully edited persistent store \"" + persistentStoreType + "\".") .setOperation(Daemon.setPersistentStore(currentDeployment, persistentStoreType, !noValidate, persistentStore)) .get(); } }
@Override protected void executeThis() { String providerName = getProviderName(); String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. BakeryDefaults defaults = new OperationHandler<BakeryDefaults>() .setFailureMesssage("Failed to get bakery defaults for " + providerName + "'s bakery.") .setOperation(Daemon.getBakeryDefaults(currentDeployment, providerName, false)) .get(); int originalHash = defaults.hashCode(); defaults = editBakeryDefaults((T) defaults); if (originalHash == defaults.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setSuccessMessage("Successfully edited bakery defaults for " + providerName + "'s bakery.") .setFailureMesssage("Failed to edit bakery defaults for " + providerName + "'s bakery.") .setOperation(Daemon.setBakeryDefaults(currentDeployment, providerName, !noValidate, defaults)) .get(); } }
@Override protected void executeThis() { String notificationName = getNotificationName(); String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. Notification notification = new OperationHandler<Notification>() .setOperation(Daemon.getNotification(currentDeployment, notificationName, !noValidate)) .setFailureMesssage("Failed to get " + notificationName + ".") .get(); int originalHash = notification.hashCode(); notification = editNotification((N) notification); if (originalHash == notification.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setNotification(currentDeployment, notificationName, !noValidate, notification)) .setSuccessMessage("Edited " + notificationName + ".") .setFailureMesssage("Failed to edit " + notificationName + ".") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); MetricStores metricStores = new OperationHandler<MetricStores>() .setOperation(Daemon.getMetricStores(currentDeployment, false)) .setFailureMesssage("Failed to load metric stores.") .get(); int originalHash = metricStores.hashCode(); metricStores.setPeriod(isSet(period) ? period : metricStores.getPeriod()); if (originalHash == metricStores.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStores(currentDeployment, !noValidate, metricStores)) .setFailureMesssage("Failed to edit metric stores.") .setSuccessMessage("Successfully updated metric stores.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); UiSecurity uiSecurity = new OperationHandler<UiSecurity>() .setOperation(Daemon.getUiSecurity(currentDeployment, false)) .setFailureMesssage("Failed to load UI security settings.") .get(); int originalHash = uiSecurity.hashCode(); uiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : uiSecurity.getOverrideBaseUrl()); if (originalHash == uiSecurity.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setUiSecurity(currentDeployment, !noValidate, uiSecurity)) .setFailureMesssage("Failed to edit UI security settings.") .setSuccessMessage("Successfully updated UI security settings.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. PersistentStorage persistentStorage = new OperationHandler<PersistentStorage>() .setFailureMesssage("Failed to get persistent storage.") .setOperation(Daemon.getPersistentStorage(currentDeployment, false)) .get(); int originalHash = persistentStorage.hashCode(); persistentStorage.setPersistentStoreType(isSet(type) ? type : persistentStorage.getPersistentStoreType()); if (originalHash == persistentStorage.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setPersistentStorage(currentDeployment, !noValidate, persistentStorage)) .setFailureMesssage("Failed to edit persistent storage.") .setSuccessMessage("Successfully edited persistent storage.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. PersistentStorage persistentStorage = new OperationHandler<PersistentStorage>() .setFailureMesssage("Failed to get persistent storage.") .setOperation(Daemon.getPersistentStorage(currentDeployment, false)) .get(); int originalHash = persistentStorage.hashCode(); persistentStorage.setPersistentStoreType(isSet(type) ? type : persistentStorage.getPersistentStoreType()); if (originalHash == persistentStorage.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setPersistentStorage(currentDeployment, !noValidate, persistentStorage)) .setFailureMesssage("Failed to edit persistent storage.") .setSuccessMessage("Successfully edited persistent storage.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); MetricStores metricStores = new OperationHandler<MetricStores>() .setOperation(Daemon.getMetricStores(currentDeployment, false)) .setFailureMesssage("Failed to load metric stores.") .get(); int originalHash = metricStores.hashCode(); metricStores.setPeriod(isSet(period) ? period : metricStores.getPeriod()); if (originalHash == metricStores.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStores(currentDeployment, !noValidate, metricStores)) .setFailureMesssage("Failed to edit metric stores.") .setSuccessMessage("Successfully updated metric stores.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); String metricStoreType = getMetricStoreType().getId(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. MetricStore metricStore = new OperationHandler<MetricStore>() .setOperation(Daemon.getMetricStore(currentDeployment, metricStoreType, false)) .setFailureMesssage("Failed to get " + metricStoreType + " method.") .get(); int originalHash = metricStore.hashCode(); metricStore = editMetricStore((T) metricStore); if (originalHash == metricStore.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStore(currentDeployment, metricStoreType, !noValidate, metricStore)) .setFailureMesssage("Failed to edit " + metricStoreType + " method.") .setSuccessMessage("Successfully edited " + metricStoreType + " method.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); UiSecurity uiSecurity = new OperationHandler<UiSecurity>() .setOperation(Daemon.getUiSecurity(currentDeployment, false)) .setFailureMesssage("Failed to load UI security settings.") .get(); int originalHash = uiSecurity.hashCode(); uiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : uiSecurity.getOverrideBaseUrl()); if (originalHash == uiSecurity.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setUiSecurity(currentDeployment, !noValidate, uiSecurity)) .setFailureMesssage("Failed to edit UI security settings.") .setSuccessMessage("Successfully updated UI security settings.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); String metricStoreType = getMetricStoreType().getId(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. MetricStore metricStore = new OperationHandler<MetricStore>() .setOperation(Daemon.getMetricStore(currentDeployment, metricStoreType, false)) .setFailureMesssage("Failed to get " + metricStoreType + " method.") .get(); int originalHash = metricStore.hashCode(); metricStore = editMetricStore((T) metricStore); if (originalHash == metricStore.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setMetricStore(currentDeployment, metricStoreType, !noValidate, metricStore)) .setFailureMesssage("Failed to edit " + metricStoreType + " method.") .setSuccessMessage("Successfully edited " + metricStoreType + " method.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); boolean enable = isEnable(); WebhookTrust webhookTrust = new OperationHandler<WebhookTrust>() .setOperation(Daemon.getWebhookTrust(currentDeployment, false)) .setFailureMesssage("Failed to load webhook trust.") .get(); int originalHash = webhookTrust.hashCode(); webhookTrust.setEnabled(enable); if (originalHash == webhookTrust.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setSuccessMessage("Successfully " + indicativePastPerfectAction() + " webhook trust.") .setFailureMesssage("Failed to " + getCommandName() + " webhook trust.") .setOperation(Daemon.setWebhookTrust(currentDeployment, !noValidate, webhookTrust)) .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); ApiSecurity apiSecurity = new OperationHandler<ApiSecurity>() .setOperation(Daemon.getApiSecurity(currentDeployment, false)) .setFailureMesssage("Failed to load API security settings.") .get(); int originalHash = apiSecurity.hashCode(); apiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : apiSecurity.getOverrideBaseUrl()); apiSecurity.setCorsAccessPattern(isSet(corsAccessPattern) ? corsAccessPattern : apiSecurity.getCorsAccessPattern()); if (originalHash == apiSecurity.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setOperation(Daemon.setApiSecurity(currentDeployment, !noValidate, apiSecurity)) .setFailureMesssage("Failed to edit API security settings.") .setFailureMesssage("Successfully updated API security settings.") .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. Canary canary = new OperationHandler<Canary>() .setFailureMesssage("Failed to get canary.") .setOperation(Daemon.getCanary(currentDeployment, false)) .get(); int originalHash = canary.hashCode(); AbstractCanaryServiceIntegration canaryServiceIntegration = CanaryUtils.getServiceIntegrationByName(canary, currentDeployment, getName(), true); canaryServiceIntegration.setEnabled(isEnable()); if (originalHash == canary.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setSuccessMessage("Successfully " + indicativePastPerfectAction() + " canary analysis " + getName() + " service integration.") .setFailureMesssage("Failed to " + getCommandName() + " canary analysis " + getName() + " service integration.") .setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)) .get(); } }
@Override protected void executeThis() { String currentDeployment = getCurrentDeployment(); // Disable validation here, since we don't want an illegal config to prevent us from fixing it. Canary canary = new OperationHandler<Canary>() .setFailureMesssage("Failed to get canary.") .setOperation(Daemon.getCanary(currentDeployment, false)) .get(); int originalHash = canary.hashCode(); AbstractCanaryServiceIntegration canaryServiceIntegration = CanaryUtils.getServiceIntegrationByName(canary, currentDeployment, getName(), true); canaryServiceIntegration.setEnabled(isEnable()); if (originalHash == canary.hashCode()) { AnsiUi.failure("No changes supplied."); return; } new OperationHandler<Void>() .setSuccessMessage("Successfully " + indicativePastPerfectAction() + " canary analysis " + getName() + " service integration.") .setFailureMesssage("Failed to " + getCommandName() + " canary analysis " + getName() + " service integration.") .setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)) .get(); } }