Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update library and replace deprecate method #116

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<name>Kubernetes CLI Plugin</name>
<url>https://github.com/jenkinsci/kubernetes-cli-plugin</url>
<groupId>org.jenkins-ci.plugins</groupId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the groupId not needed anymore ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a warning because the group took it from the parent

<artifactId>kubernetes-cli</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
Expand All @@ -20,15 +19,13 @@
<hpi.compatibleSinceVersion>1.0.0</hpi.compatibleSinceVersion>

<!-- dependency versions -->
<jenkins.version>2.401.1</jenkins.version>
<jenkins.version>2.401.3</jenkins.version>
<bom.artifactId>bom-2.401.x</bom.artifactId>
<bom.version>2357.v1043f8578392</bom.version>
<bom.version>2555.v3190a_8a_c60c6</bom.version>

<!-- jenkins plugins versions -->
<jenkins-env-inject.version>2.3.0</jenkins-env-inject.version>
<jenkins-declarative.version>1.4.0</jenkins-declarative.version>
<jenkins-kubernetes-credentials.version>0.11</jenkins-kubernetes-credentials.version>


<!-- maven plugins versions -->
<maven-coveralls.version>4.3.0</maven-coveralls.version>

Expand Down Expand Up @@ -102,7 +99,6 @@
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>kubernetes-credentials</artifactId>
<version>${jenkins-kubernetes-credentials.version}</version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decided to unpin all those dependencies ? Doesn't it mean that Jenkins will be less restrictive when deciding which plugins it can update / start with, and this would lead to runtime errors instead of update/boot errors ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using managed version from group io.jenkins.tools.bom - bom-2.401.x

</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down Expand Up @@ -136,7 +132,6 @@
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
<version>${jenkins-declarative.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -163,13 +158,11 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>docker-commons</artifactId>
<version>439.va_3cb_0a_6a_fb_29</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>2.6.6</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static ListBoxModel doFillCredentialsIdItems(@Nonnull @AncestorInPath Ite
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
ACL.SYSTEM,
ACL.SYSTEM2,
item,
StandardCredentials.class,
URIRequirementBuilder.fromUri(serverUrl).build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public void testEnvVariableFormat() throws Exception {
assertBuildStatus(b, Result.SUCCESS);
String regExp = "Using temporary file '(.+).kube(.+)config'";
Pattern kubeConfigPathRegexp = Pattern.compile(regExp);
assertTrue("No line in the logs matched the regular expression '" + regExp + "': " + r.getLog(b),
kubeConfigPathRegexp.matcher(r.getLog(b)).find());
assertTrue("No line in the logs matched the regular expression '" + regExp + "': " + JenkinsRule.getLog(b),
kubeConfigPathRegexp.matcher(JenkinsRule.getLog(b)).find());
}

private void assertBuildStatus(WorkflowRun b, Result result) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.jenkinsci.plugins.envinject.EnvInjectBuildWrapper;
import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo;
import org.jenkinsci.plugins.kubernetes.cli.helpers.DummyCredentials;
import org.jenkinsci.plugins.matrixauth.AuthorizationType;
import org.jenkinsci.plugins.matrixauth.PermissionEntry;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
Expand Down Expand Up @@ -140,10 +142,10 @@ public void testListingCredentialsWithoutAncestorAndMissingPermissions() throws

r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
ProjectMatrixAuthorizationStrategy as = new ProjectMatrixAuthorizationStrategy();
as.add(Jenkins.READ, "user-not-enough-permissions");
as.add(Jenkins.READ, new PermissionEntry(AuthorizationType.EITHER, "user-not-enough-permissions"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For myself:
image

r.jenkins.setAuthorizationStrategy(as);

try (ACLContext unused = ACL.as(User.get("user-not-enough-permissions", true, null).impersonate())) {
try (ACLContext unused = ACL.as2(User.get("user-not-enough-permissions", true, null).impersonate2())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListBoxModel options = d.doFillCredentialsIdItems(null, "", "1");
assertEquals("- current -", options.get(0).name);
assertEquals(1, options.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public static BaseStandardCredentials secretCredential(String credentialId) {

public static BaseStandardCredentials certificateCredential(String credentialId) {
byte[] storeFile = TestResourceLoader.loadAsByteArray("kubernetes.pkcs12");
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(null,
SecretBytes.fromBytes(storeFile));
return new CertificateCredentialsImpl(CredentialsScope.GLOBAL, credentialId, "sample", PASSPHRASE,
keyStoreSource);
}

public static BaseStandardCredentials brokenCertificateCredential(String credentialId) {
byte[] storeFile = TestResourceLoader.loadAsByteArray("kubernetes.pkcs12");
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(
CertificateCredentialsImpl.KeyStoreSource keyStoreSource = new CertificateCredentialsImpl.UploadedKeyStoreSource(null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SecretBytes.fromBytes(storeFile));
return new CertificateCredentialsImpl(CredentialsScope.GLOBAL, credentialId, "sample", "bad-passphrase",
keyStoreSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

public class DummyTokenCredentialImpl extends UsernamePasswordCredentialsImpl implements TokenProducer {

public DummyTokenCredentialImpl(CredentialsScope scope, String id, String description, String username,
/**
*
*/
private static final long serialVersionUID = 1L;

public DummyTokenCredentialImpl(CredentialsScope scope, String id, String description, String username,
String password) {
super(scope, id, description, username, password);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

public class UnsupportedCredentialImpl extends BaseStandardCredentials {

public UnsupportedCredentialImpl(String id, String description) {
/**
*
*/
private static final long serialVersionUID = 1L;

public UnsupportedCredentialImpl(String id, String description) {
super(id, description);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class KubeConfigWriterAuthTest {

FilePath workspace;
Launcher mockLauncher;
AbstractBuild build;
AbstractBuild<?, ?> build;

private static String dumpBuilder(ConfigBuilder configBuilder) throws JsonProcessingException {
return Serialization.asYaml(configBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class KubeConfigWriterBuilderTest {
public TemporaryFolder tempFolder = new TemporaryFolder();
FilePath workspace;
Launcher mockLauncher;
AbstractBuild build;
AbstractBuild<?, ?> build;

private static String dumpBuilder(ConfigBuilder configBuilder) throws JsonProcessingException {
return Serialization.asYaml(configBuilder.build());
Expand Down
Loading