use of com.redhat.devtools.intellij.tektoncd.tkn.Resource in project intellij-tekton by redhat-developer.
the class OutputResourcesStep method addListener.
private void addListener(String idParam, JComboBox cmbValueResource) {
// listener for when value in output resources combo box changes
cmbValueResource.addItemListener(itemEvent -> {
if (itemEvent.getStateChange() == 1) {
// when outputsResourcesCB combo box value changes, the new value is saved and preview is updated
Resource resourceSelected = (Resource) itemEvent.getItem();
setOutputValue(idParam, resourceSelected.name());
fireStateChanged();
}
});
}
use of com.redhat.devtools.intellij.tektoncd.tkn.Resource in project intellij-tekton by redhat-developer.
the class ActionToRunModel method setDefaultValueResources.
private void setDefaultValueResources() {
if (this.pipelineResources == null || this.pipelineResources.isEmpty()) {
if (!this.getInputResources().isEmpty() || !this.getOutputResources().isEmpty()) {
errorMessage += " * The " + this.kind + " requires resources to be started but no resources were found in the cluster.\n";
isValid = false;
}
}
// set the first resource for a specific type (git, image, ...) as the default value for input/output
Map<String, List<Resource>> resourceGroupedByType = pipelineResources.stream().collect(Collectors.groupingBy(Resource::type));
if (!this.resource.getInputResources().isEmpty()) {
for (Input input : this.resource.getInputResources()) {
List<Resource> resourcesByInputType = resourceGroupedByType.get(input.type());
if (resourcesByInputType == null) {
errorMessage += " * The input " + input.name() + " requires a resource of type " + input.type() + " but no resource of that type was found in the cluster.\n";
isValid = false;
continue;
}
input.setValue(resourcesByInputType.get(0).name());
}
}
if (!this.resource.getOutputResources().isEmpty()) {
for (Output output : this.resource.getOutputResources()) {
List<Resource> resourcesByOutputType = resourceGroupedByType.get(output.type());
if (resourcesByOutputType == null) {
errorMessage += " * The output " + output.name() + " requires a resource of type " + output.type() + " but no resource of that type was found in the cluster.\n";
isValid = false;
continue;
}
output.setValue(resourcesByOutputType.get(0).name());
}
}
}
use of com.redhat.devtools.intellij.tektoncd.tkn.Resource in project intellij-tekton by redhat-developer.
the class StartAction method createModel.
private StartResourceModel createModel(Tkn tkncli, ParentableNode element, String namespace) {
StartResourceModel model = null;
try {
List<Resource> resources = tkncli.getResources(namespace);
List<String> serviceAccounts = tkncli.getServiceAccounts(namespace);
List<String> secrets = tkncli.getSecrets(namespace);
List<String> configMaps = tkncli.getConfigMaps(namespace);
List<String> persistentVolumeClaims = tkncli.getPersistentVolumeClaim(namespace);
model = createModel(element, namespace, tkncli, resources, serviceAccounts, secrets, configMaps, persistentVolumeClaims);
} catch (IOException e) {
String errorMessage = element.getName() + " in namespace " + namespace + " failed to start. An error occurred while retrieving information.\n" + e.getLocalizedMessage();
UIHelper.executeInUI(() -> {
telemetry.error(anonymizeResource(element.getName(), namespace, errorMessage)).send();
Messages.showErrorDialog(errorMessage, "Error");
});
logger.warn("Error: " + errorMessage, e);
}
return model;
}
Aggregations