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

[JENKINS-50204] Implemented the Credentials view page #7

Merged
merged 5 commits into from Apr 13, 2018
Merged

[JENKINS-50204] Implemented the Credentials view page #7

merged 5 commits into from Apr 13, 2018

Conversation

agentgonzo
Copy link
Contributor

@agentgonzo agentgonzo commented Apr 12, 2018

@@ -67,6 +67,10 @@
<id>teilo</id>
<name>James Nord</name>
</developer>
<developer>
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dockerfile Outdated
@@ -1,4 +1,4 @@
FROM jenkins/jenkins:lts

RUN /usr/local/bin/install-plugins.sh credentials:2.1.16 credentials-binding:1.15
COPY target/kubernetes-credential-provider.hpi /usr/share/jenkins/ref/plugins/kubernetes-credential-provider.jpi
COPY target/kubernetes-credentials-provider.hpi /usr/share/jenkins/ref/plugins/kubernetes-credential-provider.jpi
Copy link
Member

Choose a reason for hiding this comment

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

conflict

import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import org.acegisecurity.Authentication;
import org.apache.commons.lang.NotImplementedException;
Copy link
Member

@jtnord jtnord Apr 12, 2018

Choose a reason for hiding this comment

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

not the exception you are looking for?


@Override
public boolean addCredentials(@NonNull Domain domain, @NonNull Credentials credentials) {
throw new NotImplementedException();
Copy link
Member

Choose a reason for hiding this comment

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

should only throw an IOException (as per parent signature)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NotImplementedException (and your suggestion of UnsupportedOperationException for that matter) are both RuntimeExceptions


@Override
public boolean removeCredentials(@NonNull Domain domain, @NonNull Credentials credentials) {
throw new NotImplementedException();
Copy link
Member

Choose a reason for hiding this comment

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

should only throw an IOException (as per parent signature)

This allows inspecting of individual secrets when clicking on them in
the credentials view instead of receiving a big stapler stack trace
@Override
public boolean updateCredentials(@NonNull Domain domain, @NonNull Credentials current,
@NonNull Credentials replacement) {
throw new NotImplementedException();
Copy link
Member

Choose a reason for hiding this comment

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

should only throw an IOException (as per parent signature)

*/
@Override
public String getIconClassName() {
return isVisible()
Copy link
Member

Choose a reason for hiding this comment

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

what is isVisible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


@Override
public boolean hasPermission(@NonNull Authentication authentication, @NonNull Permission permission) {
return Jenkins.getInstance().getACL().hasPermission(authentication, permission);
Copy link
Member

Choose a reason for hiding this comment

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

As we don;t support Credential.ADD / UPDATE / REMOVE you should check these and return false (otherwise you would see the stack trace when you try to update / save)

@NonNull
@Override
public List<Credentials> getCredentials(@NonNull Domain domain) {
// TODO: Filter by domain - how do I do this?
Copy link
Member

Choose a reason for hiding this comment

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

Domain.global is a static I think you can use

}

/**
* {@inheritDoc}
Copy link
Member

Choose a reason for hiding this comment

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

NIT: this is the default.

* {@inheritDoc}
*/
@NonNull
public CredentialsStore getStore() {
Copy link
Member

Choose a reason for hiding this comment

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

@Override

@jtnord
Copy link
Member

jtnord commented Apr 12, 2018

@agentgonzo can you add some screenshots please?

@agentgonzo
Copy link
Contributor Author

image

@agentgonzo
Copy link
Contributor Author

image

return provider.getCredentials(Credentials.class, Jenkins.getInstance(), ACL.SYSTEM);
// Only the global domain is supported
return Domain.global().equals(domain)
? provider.getCredentials(Credentials.class, Jenkins.getInstance(), ACL.SYSTEM)
Copy link
Member

Choose a reason for hiding this comment

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

Ahh I think you need to pass jenkins.getAuthentication() rather than ACL.SYSTEM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I do that, then this check fails and we don't see the credentials

Copy link
Member

Choose a reason for hiding this comment

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

Hmm.. I used this code as a reference for that.

@agentgonzo agentgonzo merged commit 0e8df31 into jenkinsci:master Apr 13, 2018
@agentgonzo agentgonzo deleted the JENKINS-50204 branch April 23, 2018 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants