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

Create a Provider (Github/Gitlab) during init and pass it on to other steps #73

Merged
merged 11 commits into from
Mar 22, 2021

Conversation

nathanleiby
Copy link
Contributor

@nathanleiby nathanleiby commented Mar 21, 2021

JIRA

n/a

Overview

The high level goal here is to setup the provider once during
initialize. After that, all following steps will respect this
configuration.

  1. created package lib, which now holds
  • Provider abstraction (for Github or Gitlab)
  • Repo - allows us to pass along the Provider configuration
  1. centralized the logic to setup a Github or Gitlab client, in the
    Provider

This is also prep work that should help simplify adding Github Enterprise support. #44

⚠️ WARNING: This version has a breaking UX change for Gitlab users. We now pass provider and provider-url via flags instead of using env vars to determine (1) Github vs Gitlab and (2) whether or not a custom URL is set. See README.md regarding Gitlab.

NOTE: There's some other cleanup here, apologies for the noise. The key commits for the provider work are:

Testing

  • Test e2e for Github :octocat:
  • Test e2e for Gitlab 🧪

The high level goal here is to setup the provider once during
initialize. After that, all following steps will respect this
configuration.

1. created `package lib`, which now holds
  - `Provider` abstraction (for Github or Gitlab)
  - `Repo` - allows us to pass along the `Provider` configuration
2. centralized the logic to setup a Github or Gitlab client, in the
`Provider`
Version bump only relates to releasing a new version, which can be
managed by repo owners after merge to maser.
@nathanleiby
Copy link
Contributor Author

seems like CODEOWNERS auto-assignment isn't enabled

This is just a script for local testing. It's not yet used in any CI
automation.
github run:
```
❯ ./integration_test.sh github nuke
nuking ./mp
[Init]
1
2
[Clone]
2021/03/21 16:30:27 cloning: microplane-test/2
2021/03/21 16:30:27 cloning: microplane-test/1
[Plan]
2021/03/21 16:30:29 planning 2 repos with parallelism limit [10]
2021/03/21 16:30:29 planning: microplane-test/2
2021/03/21 16:30:29 planning: microplane-test/1
[Push]
2021/03/21 16:30:29 pushing: microplane-test/2
2021/03/21 16:30:29 pushing: microplane-test/1
[Merge]
2021/03/21 16:30:36 microplane-test/2 - merging...
2021/03/21 16:30:36 microplane-test/1 - merging...
```

gitlab run
```
❯ ./integration_test.sh gitlab nuke
nuking ./mp
[Init]
1
2
[Clone]
2021/03/21 16:31:59 cloning: microplane-gitlab/2
2021/03/21 16:31:59 cloning: microplane-gitlab/1
[Plan]
2021/03/21 16:32:00 planning 2 repos with parallelism limit [10]
2021/03/21 16:32:00 planning: microplane-gitlab/2
2021/03/21 16:32:00 planning: microplane-gitlab/1
[Push]
2021/03/21 16:32:00 pushing: microplane-gitlab/2
2021/03/21 16:32:00 pushing: microplane-gitlab/1
[Merge]
2021/03/21 16:32:06 microplane-gitlab/2 - merging...
2021/03/21 16:32:06 microplane-gitlab/1 - merging...
```
Caught via newly created integration test!

Error looked like:
```
[Push]
2021/03/21 16:13:49 pushing: microplane-gitlab/2
2021/03/21 16:13:49 pushing: microplane-gitlab/1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1498e1b]

goroutine 7 [running]:
github.com/Clever/microplane/push.GitlabPush(0x17084c0, 0xc00002a0b8, 0x19ba470, 0x1, 0xc000026b20, 0x11, 0xc000028240, 0x22, 0xc00002b066, 0x6, ...)
	/Users/nathanleiby/go/src/github.com/Clever/microplane/push/pushGitlab.go:79 +0x99b
github.com/Clever/microplane/cmd.pushOneRepo(0x19ba470, 0x1, 0xc000026b20, 0x11, 0xc000028240, 0x22, 0xc00002b066, 0x6, 0x0, 0x0, ...)
	/Users/nathanleiby/go/src/github.com/Clever/microplane/cmd/push.go:137 +0x8fc
github.com/Clever/microplane/cmd.parallelizeLimited.func1(0xc00007e640, 0x17084c0, 0xc00002a0b8, 0xc00010be00, 0x168cc08, 0x19ba470, 0x1, 0xc000026b20, 0x11, 0xc000028240, ...)
	/Users/nathanleiby/go/src/github.com/Clever/microplane/cmd/helpers.go:48 +0x11a
created by github.com/Clever/microplane/cmd.parallelizeLimited
	/Users/nathanleiby/go/src/github.com/Clever/microplane/cmd/helpers.go:43 +0x1b8
```
@nathanleiby
Copy link
Contributor Author

Added an integration_test.sh script and caught some errors in the Gitlab (one I just introduced with this PR e56d44a, and one that existed previously e133845) with it. 🥳

@ghirsch1
Copy link
Contributor

seems like CODEOWNERS auto-assignment isn't enabled

fixed here e6a3cda

Copy link
Contributor

@ghirsch1 ghirsch1 left a comment

Choose a reason for hiding this comment

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

Nice refactoring, and adding the integration test looks awesome!

@nathanleiby nathanleiby merged commit 772c925 into master Mar 22, 2021
@nathanleiby nathanleiby deleted the refactor-provider branch March 22, 2021 20:12
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.

2 participants