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

Add SCM integration link commands #458

Merged
merged 46 commits into from Aug 30, 2019
Merged

Conversation

@brandon-welsch
Copy link
Member

@brandon-welsch brandon-welsch commented Jul 26, 2019

Close #445

README.md Show resolved Hide resolved
Loading
README.md Outdated Show resolved Hide resolved
Loading
@brandon-welsch brandon-welsch changed the title Add Repo Link commands Add repo link commands Jul 29, 2019
@brandon-welsch brandon-welsch changed the title Add repo link commands Add scm repo link commands Aug 2, 2019
@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from 089d127 to c096c1d Aug 20, 2019
README.md Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
repolink/manual_review_app.go Outdated Show resolved Hide resolved
Loading
repolink/manual_review_app.go Outdated Show resolved Hide resolved
Loading
repolink/show.go Outdated Show resolved Hide resolved
Loading
repolink/update.go Outdated Show resolved Hide resolved
Loading
review_apps/show.go Outdated Show resolved Hide resolved
Loading
@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from da19428 to bc17ee2 Aug 20, 2019
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
cmd/repo_link.go Outdated Show resolved Hide resolved
Loading
@Soulou
Copy link
Member

@Soulou Soulou commented Aug 20, 2019

And --no-auto-review-apps?

Loading

@EtienneM
Copy link
Member

@EtienneM EtienneM commented Aug 20, 2019

$ scalingo integrations-add github
$ scalingo integrations-add github-enterprise --url https://github.mycorp.com --token <token>
$ scalingo integrations-add gitlab-self-hosted --url https://gitlab.scalingo.com --token <token>
$ scalingo integrations-add gitlab-self-hosted --url https://gitlab.mycorp.com --token <token>

# If SaaS GitHub integration already exists
$ scalingo -a my-app integration-links-create https://github.com/betagouv/civilsdeladefense
Branch to auto-deploy (empty to disable): prod
Automatically deploy pull requests [y/N]: N
→ Application has been linked to github repository betagouv/civilsdeladefense

# Without GitHub integration
$ scalingo -a my-app integration-links-create https://github.com/betagouv/civilsdeladefense
→ No github integration found, please go to https://auth.scalingo.com/oauth/github

# Like SaaS GitHub
$ scalingo -a my-app integration-links-create https://gitlab.com/betagouv/civilsdeladefense

$ scalingo -a my-app integration-links-create https://gitlab.scalingo.com/betagouv/civilsdeladefense
 ! No integration found for URL https://gitlab.scalingo.com
 ! Please run `scalingo integrations-add gitlab-self-hosted|github-enterprise --url https://gitlab.scalingo.com

# Integration already exists, same wizard as show before
$ scalingo -a my-app integration-links-create https://github.scalingo.com/betagouv/civilsdeladefense
scalingo -a my-app integration-links-update --no-auto-deploy
scalingo -a my-app integration-links-update --auto-deploy --branch production
scalingo -a my-app integration-links-delete

s/integration-links/integration-link/g

Loading

@EtienneM
Copy link
Member

@EtienneM EtienneM commented Aug 21, 2019

With no integration set

  1. GL
scalingo --app test-etienne integration-link-create https://gitlab.com/Scalingo/api
 !     No GitLab integration found, please follow this URL to add it:
 !     https://auth.st-sc.fr/users/gitlab/link
  1. GH
scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini
 !     No GitHub integration found, please follow this URL to add it:
 !     https://auth.st-sc.fr/users/github/link
  1. GHE/GL self-hosted
scalingo --app test-etienne integration-link-create https://github.example.com/EtienneM/sample-go-martini
 !     No integration found for URL https://github.example.com/EtienneM/sample-go-martini.
 !     Please run the command:
 !     scalingo integrations-add gitlab-self-hosted|github-enterprise --url https://github.example.com --token <personal-access-token>

With integration set

  1. With flags
scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini --auto-deploy --branch master
-----> Your app 'test-etienne' is linked to the repository https://github.com/EtienneM/sample-go-martini.
  1. With interactive mode:

    2.1. No review apps:

scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini
? Branch to auto-deploy (empty to disable): master
? Automatically deploy review apps: No
-----> Your app 'test-etienne' is linked to the repository https://github.com/EtienneM/sample-go-martini.
2.2. With review apps:
scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini
? Branch to auto-deploy (empty to disable): master
? Automatically deploy review apps: Yes
? Automatically destroy review apps when the pull/merge request is closed: Yes
? Hours before automatically destroying the review apps: 0
? Automatically destroy review apps after some time without deploy/commits: No
-----> Your app 'test-etienne' is linked to the repository https://github.com/EtienneM/sample-go-martini.

Loading

@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from 46a1d41 to 3f7e59f Aug 21, 2019
@EtienneM EtienneM requested review from Soulou and removed request for Soulou Aug 21, 2019
@EtienneM EtienneM changed the title Add scm repo link commands Add SCM integration link commands Aug 22, 2019
@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from b0965c3 to d061ec2 Aug 22, 2019
@EtienneM EtienneM mentioned this pull request Aug 28, 2019
@EtienneM EtienneM requested review from johnsudaar and removed request for Soulou Aug 29, 2019
@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from d061ec2 to 6fb8077 Aug 29, 2019

currentApp := appdetect.CurrentApp(c)
integrationURL := c.Args()[0]
integrationType, err := scmintegrations.GetTypeFromURL(integrationURL)
Copy link
Member

@johnsudaar johnsudaar Aug 29, 2019

Choose a reason for hiding this comment

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

Could you move all the "logic" to the scm_integrations package? In this package all Actions are quite small and just delegate the logic to the specific package. I find this easier to read.

Loading

func (p *paramsChecker) lookupBranch() *string {
branch := p.ctx.String("branch")

if branch != "" && p.repoLink.Branch != branch {
Copy link
Member

@johnsudaar johnsudaar Aug 29, 2019

Choose a reason for hiding this comment

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

Why are those test needed? if we don't do them, we do not need to show the RepoLink which will remove the Show API call.

Loading

}

t := tablewriter.NewWriter(os.Stdout)
t.SetHeader([]string{
Copy link
Member

@johnsudaar johnsudaar Aug 29, 2019

Choose a reason for hiding this comment

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

A table for a single element ?

Why not using something that is a bit more readable like:

App: myapp (58ab56456def)
Integration: gitlab-self-hosted (scm-asd4556-5645-564)

Repo: Scalingo/api
Branch: prod
Owner: johnsudaar

AutoDeploy: true

Review Apps: Enabled
   Destroy on close: 1h
   Destroy on Stale: 2h

Loading

Copy link
Member

@EtienneM EtienneM Aug 30, 2019

Choose a reason for hiding this comment

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

Screenshot from 2019-08-30 13-54-42

I used the same color as for the display of logs archive

Loading

return errgo.Notef(err, "fail to get the integration")
}

repoLink, err := c.SCMRepoLinkShow(app)
Copy link
Member

@johnsudaar johnsudaar Aug 29, 2019

Choose a reason for hiding this comment

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

Wont SCMRepoLinkShow send an error if not SCM is configured (like a 404 ?)

Loading

Copy link
Member

@EtienneM EtienneM Aug 30, 2019

Choose a reason for hiding this comment

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

Surprisingly, no..

╰─$ scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini --auto-deploy --branch master
-----> Your app 'test-etienne' is linked to the repository https://github.com/EtienneM/sample-go-martini.
╭─emichon@biniou ~/Documents/Scalingo/golang/src/github.com/Scalingo/cli 2.4.2‹feature/445/add_repo_link_commands› 
╰─$ scalingo --app test-etienne integration-link-create https://github.com/EtienneM/sample-go-martini --auto-deploy --branch master
-----> Your app is already linked to https://github.com/EtienneM/sample-go-martini#master.

Loading

cmd/scm_integrations.go Show resolved Hide resolved
Loading
@EtienneM EtienneM requested a review from johnsudaar Aug 30, 2019
@EtienneM EtienneM force-pushed the feature/445/add_repo_link_commands branch from 8f1629b to b7c505d Aug 30, 2019
@johnsudaar johnsudaar merged commit a9ec1f1 into master Aug 30, 2019
1 check passed
Loading
@EtienneM EtienneM deleted the feature/445/add_repo_link_commands branch May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants