Skip to content

Azure devops#216

Open
souleb wants to merge 45 commits into
mainfrom
azure-devops
Open

Azure devops#216
souleb wants to merge 45 commits into
mainfrom
azure-devops

Conversation

@souleb
Copy link
Copy Markdown
Member

@souleb souleb commented Apr 28, 2023

Description

New azure devops implementation.

It can effectively reconcile azuredevops repositories using the azure zsk. It uses a PAT as ssh keys are not supported.

Commits and Pull requests are supported but teamspermissions are still to be implemented.

cc @nellyk

Test results

https://github.com/fluxcd/go-git-providers/actions/runs/4832004149/jobs/8610205652

@souleb souleb requested review from makkes and yiannistri April 28, 2023 15:23
Comment thread go.mod
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.2
github.com/ktrysmt/go-bitbucket v0.9.48
github.com/microsoft/azure-devops-go-api/azuredevops/v6 v6.0.1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

@souleb souleb May 11, 2023

Choose a reason for hiding this comment

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

we can't use V7 until they fix ContinuationToken field type. It is unconsistent depending on which struct you use.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@souleb is it related to this issue? microsoft/azure-devops-go-api#97 did you find it in a different struct?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i've mentioned this to the relevant team and will let you know when it gets resolved

Comment thread .github/workflows/e2e.yaml Outdated
nellyk and others added 19 commits May 10, 2023 18:31
Signed-off-by: Soule BA <soule@weave.works>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Nelly Kiboi <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Nelly Kiboi <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Nelly Kiboi <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Nelly Kiboi <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: nellyk <3062772+nellyk@users.noreply.github.com>
Signed-off-by: Soule BA <soule@weave.works>
Signed-off-by: Soule BA <soule@weave.works>
Also cleaning up and refactoring where needed.

Signed-off-by: Soule BA <soule@weave.works>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2023

Codecov Report

❌ Patch coverage is 60.93089% with 277 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.00%. Comparing base (f57ef5c) to head (f3bf893).
⚠️ Report is 147 commits behind head on main.

Files with missing lines Patch % Lines
azuredevops/client_repository_pullrequest.go 20.43% 73 Missing and 1 partial ⚠️
azuredevops/client_repository_tree.go 0.00% 58 Missing ⚠️
azuredevops/resource_repository.go 65.46% 42 Missing and 6 partials ⚠️
azuredevops/util.go 64.15% 15 Missing and 4 partials ⚠️
azuredevops/client_repositories.go 78.20% 13 Missing and 4 partials ⚠️
azuredevops/auth.go 51.61% 10 Missing and 5 partials ⚠️
azuredevops/azuredevopsclient.go 64.70% 11 Missing and 1 partial ⚠️
azuredevops/client_organizations.go 72.09% 9 Missing and 3 partials ⚠️
azuredevops/client_repository_commit.go 87.23% 7 Missing and 5 partials ⚠️
azuredevops/resource_pullrequest.go 82.14% 4 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
- Coverage   59.48%   59.00%   -0.49%     
==========================================
  Files          44       88      +44     
  Lines        3019     6891    +3872     
==========================================
+ Hits         1796     4066    +2270     
- Misses       1038     2251    +1213     
- Partials      185      574     +389     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread DEVELOPMENT.md
| Test team | fluxcd-test-team | `STASH_TEST_TEAM_NAME` |


### Azure DevOps
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
### Azure DevOps
#### Azure DevOps

// No default value at POST-time.
// Added for Azure devops compatibility since it allows updating the name
// +optional
Name *string `json:"name"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This type is also returned by e.g. UserRepository.Get. We should adapt the other implementations to properly fill this field. Otherwise it will be nil which feels strange, esp. since the information is available from the API types.


const (
azureTokenFile = "/tmp/azure.token"
defaultDescription = "Foo description"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This variable is only ever consumed once and it's not very important to declare it here (as opposed to the variable above). We should just inline it. Alternatively give it a name that make it easier to determine its intended use.

)

const (
azureTokenFile = "/tmp/azure.token"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Optional: inline this value.

Comment on lines +58 to +59
testing.Init()
rand.Seed(time.Now().UnixNano())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it really necessary to do this in an init func as opposed to TestProvider or in the azure Provider spec? I personally avoid init wherever possible as it's really hard to control or discover when navigating the code.

// Create if not found
if errors.Is(err, gitprovider.ErrNotFound) {
resp, err := c.Create(ctx, ref, req, toCreateOpts(opts...)...)
return resp, true, err
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return resp, true, err
return resp, true, fmt.Errof("failed creating repository %q: %w", ref, err)

)

const (
emptyObjectPlaceholder = "0000000000000000000000000000000000000000"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This definitely needs an explanatory comment. What is it used for and why do we need it?

gitRefPrefix = "refs/heads/"
)

// BranchClient implements the gitprovider.BranchClient interface.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// BranchClient implements the gitprovider.BranchClient interface.

I think this is self-explanatory to a Go programmer.

repositoryId := c.ref.GetRepository()
projectId := c.ref.GetIdentity()
ref := gitRefPrefix + branch
all := make([]any, 0, len(files))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
all := make([]any, 0, len(files))
allFiles := make([]any, 0, len(files))

?

requests := make([]gitprovider.PullRequest, len(*prs))

for idx, pr := range *prs {
requests[idx] = newPullRequest(c.clientContext, &pr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
requests[idx] = newPullRequest(c.clientContext, &pr)
pr := pr
requests[idx] = newPullRequest(c.clientContext, &pr)

This is needed because Go reuses variables. You may end up with requests pointing to the same address for all items in the slice.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants