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

Adding Bitbucket Server integration for pyup #349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MaxBurgert
Copy link

We (@timko98 and I) would like to propose an additional provider to pyup. The provider implements support for Atlassian Bitbucket Server by using Stashy with additional functionality by us.

Some of our solutions differ in the concepts from the Github and Gitlab implementations since the python client for the Bitbucket Server API was limited to Stashy which resulted in some workarounds. Even though this provider may not fully comply with existing providers this might be a basis for future work.

If you have any additional requests, questions or remarks, feel free to contact us.

Example usage

pyup --provider bitbucket_server --repo <projectname>/<reponame> --user-token <username>@<user_token>@<host>

* Added unittests
* Added provider
* Modified setup and cli to fit the added provider
@codecov
Copy link

codecov bot commented May 9, 2019

Codecov Report

Attention: Patch coverage is 95.07042% with 7 lines in your changes missing coverage. Please review.

Project coverage is 94.05%. Comparing base (b20fa88) to head (df05345).
Report is 65 commits behind head on master.

Files Patch % Lines
pyup/providers/bitbucket_server.py 95.07% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
+ Coverage   93.92%   94.05%   +0.13%     
==========================================
  Files          11       12       +1     
  Lines        1103     1245     +142     
==========================================
+ Hits         1036     1171     +135     
- Misses         67       74       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timko98
Copy link

timko98 commented Jul 2, 2019

Small bump @Jwomers 😊

@rafaelpivato rafaelpivato added the considering Under consideration label Mar 28, 2020
Copy link
Contributor

@rafaelpivato rafaelpivato left a comment

Choose a reason for hiding this comment

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

Thanks for the great work here. It would be really great supporting BitBucket servers. I would say my main concern is which server are we supporting with this. Atlassian merged its branding of BitBucket Server, BitBucket Cloud and Stash. So, I am wondering which one this supports.

My second point relates to the base-url in the user-token. It is OK to use a token with user@app-password format or something like that, but the URL has its own place to go as far as I understand. Also, the URL could default to BitBucket cloud, just in case.

Looking forward your feedback on this review. 👍

@@ -4,6 +4,7 @@
from pyup.requirements import RequirementFile, RequirementsBundle
from pyup.providers.github import Provider as GithubProvider
from pyup.providers.gitlab import Provider as GitlabProvider
from pyup.providers.bitbucket_server import Provider as BitbucketServerProvider
Copy link
Contributor

Choose a reason for hiding this comment

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

As Atlassian itself unified their branding, lets use just bitbucket here. By the way, I assume this work for Their on-premise and cloud versions, right?

@@ -13,12 +14,12 @@
@click.command()
@click.version_option(__version__, '-v', '--version')
@click.option('--repo', prompt='repository', help='')
@click.option('--user-token', prompt='user token', help='')
@click.option('--user-token', prompt='user token', help='When using bitbucket_server, use this format: user@token@base_url')
Copy link
Contributor

Choose a reason for hiding this comment

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

In regards to the help string. I would try documenting this somewhere else and let this to contain either none or some generic short help string.

class Provider(object):
name = "bitbucket_server"

def __init__(self, bundle, intergration=False, url=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a typo here on intergration?

Also, we have now an ignore-ssl option. Is there a way to add that here?

def _api(self, token):
"""
Create a stashy connection object with the given token.
:param token: should be in format: "user@token@base_url"
Copy link
Contributor

Choose a reason for hiding this comment

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

This format is really weird. Why do we need a base-url here anyway? I think you can rely on self.url.

Comment on lines +48 to +50
user = parts[0]
token = parts[1]
base_url = parts[2]
Copy link
Contributor

Choose a reason for hiding this comment

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

user, token, base_url = parts

return stashy.connect(base_url, user, token)

def get_user(self, token):
# TODO: Return some kind of Bitbucket Server User object
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't looks like our provider interface requires returning one specific kind of object here. So, it would be OK if Stashy has some user object, dict or something.

@@ -25,7 +25,10 @@
"python-gitlab>=1.3.0",
"dparse>=0.4",
"safety",
"jinja2>=2.3"
"jinja2>=2.3",
"GitPython>=2.1.11",
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are we using this, please?

"jinja2>=2.3",
"GitPython>=2.1.11",
"stashy",
"requests-toolbelt"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this dependency. It would be good to reduce dependencies as much as possible.

Do you think there are any other parts of our code that could benefit from using this?

Comment on lines +13 to +16
self.provider = Provider(bundle=Mock())
self.provider._api = Mock()
self.repo = Mock()
self.token = "foo@foo@http://example.com/stash"
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think the base_url looks weird. Can we make something like this instead?

provider = Provider(bundle=Mock(), url="http://example.com/stash")
token = "foo@bar"

@rafaelpivato rafaelpivato self-assigned this Mar 28, 2020
@iwan933 iwan933 mentioned this pull request Jan 26, 2021
@konyskoCic
Copy link

What is the status of this pull request? What prevents it from being merged?

@macejiko
Copy link

any news on this?

@yeisonvargasf
Copy link
Member

Hi! We are revamping our tools, so it isn't merged yet because we want to make sure PyUp CLI features play nicely and makes sense with the other tools and features. For instance, Safety 2.0 is in the process of becoming stable (https://github.com/pyupio/safety/releases).

I'll take a look at this PR in the following weeks, and if it plays nicely with the plans for all our tools, I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants