Search in sources :

Example 1 with Resource

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();
        }
    });
}
Also used : Resource(com.redhat.devtools.intellij.tektoncd.tkn.Resource)

Example 2 with Resource

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());
        }
    }
}
Also used : Input(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input) Output(com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output) Resource(com.redhat.devtools.intellij.tektoncd.tkn.Resource) List(java.util.List)

Example 3 with Resource

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;
}
Also used : StartResourceModel(com.redhat.devtools.intellij.tektoncd.utils.model.actions.StartResourceModel) Resource(com.redhat.devtools.intellij.tektoncd.tkn.Resource) AnonymizeUtils.anonymizeResource(com.redhat.devtools.intellij.telemetry.core.util.AnonymizeUtils.anonymizeResource) IOException(java.io.IOException)

Aggregations

Resource (com.redhat.devtools.intellij.tektoncd.tkn.Resource)3 Input (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Input)1 Output (com.redhat.devtools.intellij.tektoncd.tkn.component.field.Output)1 StartResourceModel (com.redhat.devtools.intellij.tektoncd.utils.model.actions.StartResourceModel)1 AnonymizeUtils.anonymizeResource (com.redhat.devtools.intellij.telemetry.core.util.AnonymizeUtils.anonymizeResource)1 IOException (java.io.IOException)1 List (java.util.List)1