Skip to content

Commit

Permalink
Merge pull request #181 from donhui/0514
Browse files Browse the repository at this point in the history
fix: corrected the NullPointerException when delete resource
  • Loading branch information
garethjevans authored May 19, 2021
2 parents c040551 + 2ec78a4 commit efd75c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.waveywaves.jenkins.plugins.tekton.client.build.delete;

import com.google.common.base.Strings;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
Expand Down Expand Up @@ -41,7 +42,8 @@ public DeleteRaw(String resourceType, String clusterName, DeleteAllBlock deleteA
super();
this.resourceType = resourceType;
this.resourceName = deleteAllStatus != null ? deleteAllStatus.resourceName : null;
setTektonClient(TektonUtils.getTektonClient(clusterName));
this.clusterName = clusterName;
setTektonClient(TektonUtils.getTektonClient(getClusterName()));
}

public static class DeleteAllBlock {
Expand All @@ -53,13 +55,25 @@ public DeleteAllBlock(String resourceName) {
}
}

public String getClusterName() {
if (Strings.isNullOrEmpty(clusterName)) {
clusterName = TektonUtils.DEFAULT_CLIENT_KEY;
}
return clusterName;
}
public String getResourceType(){
return this.resourceType;
}
public String getResourceName(){
return this.resourceName;
}

@DataBoundSetter
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
setTektonClient(TektonUtils.getTektonClient(getClusterName()));
}

@DataBoundSetter
protected void setResourceType(String resourceType) {
this.resourceType = resourceType;
Expand All @@ -74,6 +88,8 @@ private TektonResourceType getTypedResourceType(){
return TektonResourceType.valueOf(getResourceType());
}



@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException {
runDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<f:select name="resourceType"></f:select>
</f:entry>
<f:entry title="Cluster Name" field="clusterName">
<f:select name="inputType"></f:select>
<f:select name="clusterName"></f:select>
</f:entry>
<f:block>
<f:optionalBlock
Expand Down

0 comments on commit efd75c2

Please sign in to comment.