Skip to content

Commit 01efeab

Browse files
committed
JENKINS-28441
Changed AwsSecretKey type to Secret
1 parent 0f8f62a commit 01efeab

File tree

5 files changed

+30
-26
lines changed

5 files changed

+30
-26
lines changed

src/main/java/com/xti/jenkins/plugin/awslambda/LambdaVariables.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
* #L%
2727
*/
2828

29-
import com.xti.jenkins.plugin.awslambda.upload.UpdateModeValue;
3029
import com.xti.jenkins.plugin.awslambda.upload.DeployConfig;
30+
import com.xti.jenkins.plugin.awslambda.upload.UpdateModeValue;
3131
import hudson.EnvVars;
3232
import hudson.Extension;
3333
import hudson.Util;
3434
import hudson.model.AbstractDescribableImpl;
3535
import hudson.model.Descriptor;
3636
import hudson.util.ListBoxModel;
37+
import hudson.util.Secret;
3738
import org.kohsuke.stapler.DataBoundConstructor;
3839
import org.kohsuke.stapler.QueryParameter;
3940

@@ -42,7 +43,7 @@
4243
*/
4344
public class LambdaVariables extends AbstractDescribableImpl<LambdaVariables> {
4445
private String awsAccessKeyId;
45-
private String awsSecretKey;
46+
private Secret awsSecretKey;
4647
private String awsRegion;
4748
private String artifactLocation;
4849
private String description;
@@ -56,7 +57,7 @@ public class LambdaVariables extends AbstractDescribableImpl<LambdaVariables> {
5657
private String updateMode;
5758

5859
@DataBoundConstructor
59-
public LambdaVariables(String awsAccessKeyId, String awsSecretKey, String awsRegion, String artifactLocation, String description, String functionName, String handler, Integer memorySize, String role, String runtime, Integer timeout, boolean successOnly, String updateMode) {
60+
public LambdaVariables(String awsAccessKeyId, Secret awsSecretKey, String awsRegion, String artifactLocation, String description, String functionName, String handler, Integer memorySize, String role, String runtime, Integer timeout, boolean successOnly, String updateMode) {
6061
this.awsAccessKeyId = awsAccessKeyId;
6162
this.awsSecretKey = awsSecretKey;
6263
this.awsRegion = awsRegion;
@@ -76,7 +77,7 @@ public String getAwsAccessKeyId() {
7677
return awsAccessKeyId;
7778
}
7879

79-
public String getAwsSecretKey() {
80+
public Secret getAwsSecretKey() {
8081
return awsSecretKey;
8182
}
8283

@@ -128,7 +129,7 @@ public void setAwsAccessKeyId(String awsAccessKeyId) {
128129
this.awsAccessKeyId = awsAccessKeyId;
129130
}
130131

131-
public void setAwsSecretKey(String awsSecretKey) {
132+
public void setAwsSecretKey(Secret awsSecretKey) {
132133
this.awsSecretKey = awsSecretKey;
133134
}
134135

@@ -178,7 +179,7 @@ public void setSuccessOnly(boolean successOnly) {
178179

179180
public void expandVariables(EnvVars env) {
180181
awsAccessKeyId = expand(awsAccessKeyId, env);
181-
awsSecretKey = expand(awsSecretKey, env);
182+
awsSecretKey = Secret.fromString(expand(Secret.toString(awsSecretKey), env));
182183
awsRegion = expand(awsRegion, env);
183184
artifactLocation = expand(artifactLocation, env);
184185
description = expand(description, env);
@@ -193,7 +194,7 @@ public LambdaVariables getClone(){
193194
}
194195

195196
public DeployConfig getUploadConfig(){
196-
return new DeployConfig(awsAccessKeyId, awsSecretKey, awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, successOnly, updateMode);
197+
return new DeployConfig(awsAccessKeyId, Secret.toString(awsSecretKey), awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, successOnly, updateMode);
197198
}
198199

199200
private String expand(String value, EnvVars env) {

src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeBuildStepVariables.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@
3131
import hudson.Util;
3232
import hudson.model.AbstractDescribableImpl;
3333
import hudson.model.Descriptor;
34+
import hudson.util.Secret;
3435
import org.kohsuke.stapler.DataBoundConstructor;
3536

3637
import java.util.ArrayList;
3738
import java.util.List;
3839

3940
public class LambdaInvokeBuildStepVariables extends AbstractDescribableImpl<LambdaInvokeBuildStepVariables> {
4041
private String awsAccessKeyId;
41-
private String awsSecretKey;
42+
private Secret awsSecretKey;
4243
private String awsRegion;
4344
private String functionName;
4445
private String payload;
4546
private boolean synchronous;
4647
private List<JsonParameterVariables> jsonParameters;
4748

4849
@DataBoundConstructor
49-
public LambdaInvokeBuildStepVariables(String awsAccessKeyId, String awsSecretKey, String awsRegion, String functionName, String payload, boolean synchronous, List<JsonParameterVariables> jsonParameters) {
50+
public LambdaInvokeBuildStepVariables(String awsAccessKeyId, Secret awsSecretKey, String awsRegion, String functionName, String payload, boolean synchronous, List<JsonParameterVariables> jsonParameters) {
5051
this.awsAccessKeyId = awsAccessKeyId;
5152
this.awsSecretKey = awsSecretKey;
5253
this.awsRegion = awsRegion;
@@ -60,7 +61,7 @@ public String getAwsAccessKeyId() {
6061
return awsAccessKeyId;
6162
}
6263

63-
public String getAwsSecretKey() {
64+
public Secret getAwsSecretKey() {
6465
return awsSecretKey;
6566
}
6667

@@ -92,7 +93,7 @@ public void setAwsAccessKeyId(String awsAccessKeyId) {
9293
this.awsAccessKeyId = awsAccessKeyId;
9394
}
9495

95-
public void setAwsSecretKey(String awsSecretKey) {
96+
public void setAwsSecretKey(Secret awsSecretKey) {
9697
this.awsSecretKey = awsSecretKey;
9798
}
9899

@@ -118,7 +119,7 @@ public void setJsonParameters(List<JsonParameterVariables> jsonParameters) {
118119

119120
public void expandVariables(EnvVars env) {
120121
awsAccessKeyId = expand(awsAccessKeyId, env);
121-
awsSecretKey = expand(awsSecretKey, env);
122+
awsSecretKey = Secret.fromString(expand(Secret.toString(awsSecretKey), env));
122123
awsRegion = expand(awsRegion, env);
123124
functionName = expand(functionName, env);
124125
}
@@ -136,7 +137,7 @@ public InvokeConfig getInvokeConfig(){
136137
for (JsonParameterVariables jsonParameterVariables : getJsonParameters()) {
137138
jsonParameters.add(jsonParameterVariables.getJsonParameter());
138139
}
139-
return new InvokeConfig(awsAccessKeyId, awsSecretKey, awsRegion, functionName, payload, synchronous, false,jsonParameters);
140+
return new InvokeConfig(awsAccessKeyId, Secret.toString(awsSecretKey), awsRegion, functionName, payload, synchronous, false, jsonParameters);
140141
}
141142

142143
@Extension // This indicates to Jenkins that this is an implementation of an extension point.

src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvokeVariables.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
import hudson.Util;
3232
import hudson.model.AbstractDescribableImpl;
3333
import hudson.model.Descriptor;
34+
import hudson.util.Secret;
3435
import org.kohsuke.stapler.DataBoundConstructor;
3536

3637
import java.util.ArrayList;
3738
import java.util.List;
3839

3940
public class LambdaInvokeVariables extends AbstractDescribableImpl<LambdaInvokeVariables> {
4041
private String awsAccessKeyId;
41-
private String awsSecretKey;
42+
private Secret awsSecretKey;
4243
private String awsRegion;
4344
private String functionName;
4445
private String payload;
@@ -47,7 +48,7 @@ public class LambdaInvokeVariables extends AbstractDescribableImpl<LambdaInvokeV
4748
private List<JsonParameterVariables> jsonParameters;
4849

4950
@DataBoundConstructor
50-
public LambdaInvokeVariables(String awsAccessKeyId, String awsSecretKey, String awsRegion, String functionName, String payload, boolean synchronous, boolean successOnly, List<JsonParameterVariables> jsonParameters) {
51+
public LambdaInvokeVariables(String awsAccessKeyId, Secret awsSecretKey, String awsRegion, String functionName, String payload, boolean synchronous, boolean successOnly, List<JsonParameterVariables> jsonParameters) {
5152
this.awsAccessKeyId = awsAccessKeyId;
5253
this.awsSecretKey = awsSecretKey;
5354
this.awsRegion = awsRegion;
@@ -62,7 +63,7 @@ public String getAwsAccessKeyId() {
6263
return awsAccessKeyId;
6364
}
6465

65-
public String getAwsSecretKey() {
66+
public Secret getAwsSecretKey() {
6667
return awsSecretKey;
6768
}
6869

@@ -98,7 +99,7 @@ public void setAwsAccessKeyId(String awsAccessKeyId) {
9899
this.awsAccessKeyId = awsAccessKeyId;
99100
}
100101

101-
public void setAwsSecretKey(String awsSecretKey) {
102+
public void setAwsSecretKey(Secret awsSecretKey) {
102103
this.awsSecretKey = awsSecretKey;
103104
}
104105

@@ -128,7 +129,7 @@ public void setJsonParameters(List<JsonParameterVariables> jsonParameters) {
128129

129130
public void expandVariables(EnvVars env) {
130131
awsAccessKeyId = expand(awsAccessKeyId, env);
131-
awsSecretKey = expand(awsSecretKey, env);
132+
awsSecretKey = Secret.fromString(expand(Secret.toString(awsSecretKey), env));
132133
awsRegion = expand(awsRegion, env);
133134
functionName = expand(functionName, env);
134135
}
@@ -146,7 +147,7 @@ public InvokeConfig getInvokeConfig(){
146147
for (JsonParameterVariables jsonParameterVariables : getJsonParameters()) {
147148
jsonParameters.add(jsonParameterVariables.getJsonParameter());
148149
}
149-
return new InvokeConfig(awsAccessKeyId, awsSecretKey, awsRegion, functionName, payload, synchronous, successOnly, jsonParameters);
150+
return new InvokeConfig(awsAccessKeyId, Secret.toString(awsSecretKey), awsRegion, functionName, payload, synchronous, successOnly, jsonParameters);
150151
}
151152

152153
@Extension // This indicates to Jenkins that this is an implementation of an extension point.

src/main/java/com/xti/jenkins/plugin/awslambda/invoke/LambdaInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public LambdaInvoker(InvokeConfig config, AbstractBuild<?, ?> build, BuildListen
4848
}
4949

5050
public LambdaInvocationResult invoke() throws IOException, InterruptedException {
51-
logger.log("%nStarting lambda invocation procedure");
51+
logger.log("%nStarting lambda invocation.");
5252

5353
String output = lambda.invokeLambdaFunction(config);
5454

src/main/java/com/xti/jenkins/plugin/awslambda/upload/LambdaUploadBuildStepVariables.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import hudson.model.AbstractDescribableImpl;
3333
import hudson.model.Descriptor;
3434
import hudson.util.ListBoxModel;
35+
import hudson.util.Secret;
3536
import org.kohsuke.stapler.DataBoundConstructor;
3637
import org.kohsuke.stapler.QueryParameter;
3738

@@ -40,7 +41,7 @@
4041
*/
4142
public class LambdaUploadBuildStepVariables extends AbstractDescribableImpl<LambdaUploadBuildStepVariables> {
4243
private String awsAccessKeyId;
43-
private String awsSecretKey;
44+
private Secret awsSecretKey;
4445
private String awsRegion;
4546
private String artifactLocation;
4647
private String description;
@@ -53,7 +54,7 @@ public class LambdaUploadBuildStepVariables extends AbstractDescribableImpl<Lamb
5354
private String updateMode;
5455

5556
@DataBoundConstructor
56-
public LambdaUploadBuildStepVariables(String awsAccessKeyId, String awsSecretKey, String awsRegion, String artifactLocation, String description, String functionName, String handler, Integer memorySize, String role, String runtime, Integer timeout, String updateMode) {
57+
public LambdaUploadBuildStepVariables(String awsAccessKeyId, Secret awsSecretKey, String awsRegion, String artifactLocation, String description, String functionName, String handler, Integer memorySize, String role, String runtime, Integer timeout, String updateMode) {
5758
this.awsAccessKeyId = awsAccessKeyId;
5859
this.awsSecretKey = awsSecretKey;
5960
this.awsRegion = awsRegion;
@@ -72,7 +73,7 @@ public String getAwsAccessKeyId() {
7273
return awsAccessKeyId;
7374
}
7475

75-
public String getAwsSecretKey() {
76+
public Secret getAwsSecretKey() {
7677
return awsSecretKey;
7778
}
7879

@@ -120,7 +121,7 @@ public void setAwsAccessKeyId(String awsAccessKeyId) {
120121
this.awsAccessKeyId = awsAccessKeyId;
121122
}
122123

123-
public void setAwsSecretKey(String awsSecretKey) {
124+
public void setAwsSecretKey(Secret awsSecretKey) {
124125
this.awsSecretKey = awsSecretKey;
125126
}
126127

@@ -166,7 +167,7 @@ public void setUpdateMode(String updateMode) {
166167

167168
public void expandVariables(EnvVars env) {
168169
awsAccessKeyId = expand(awsAccessKeyId, env);
169-
awsSecretKey = expand(awsSecretKey, env);
170+
awsSecretKey = Secret.fromString(expand(Secret.toString(awsSecretKey), env));
170171
awsRegion = expand(awsRegion, env);
171172
artifactLocation = expand(artifactLocation, env);
172173
description = expand(description, env);
@@ -181,7 +182,7 @@ public LambdaUploadBuildStepVariables getClone(){
181182
}
182183

183184
public DeployConfig getUploadConfig(){
184-
return new DeployConfig(awsAccessKeyId, awsSecretKey, awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, false, updateMode);
185+
return new DeployConfig(awsAccessKeyId, Secret.toString(awsSecretKey), awsRegion, artifactLocation, description, functionName, handler, memorySize, role, runtime, timeout, false, updateMode);
185186
}
186187

187188
private String expand(String value, EnvVars env) {

0 commit comments

Comments
 (0)