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

Conversation

@brandon-welsch
Copy link
Member

commented Jul 26, 2019

Close #445

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved

@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
cmd/repo_link.go Outdated Show resolved Hide resolved
cmd/repo_link.go Outdated Show resolved Hide resolved
cmd/repo_link.go Outdated Show resolved Hide resolved
cmd/repo_link.go Outdated Show resolved Hide resolved
repolink/manual_review_app.go Outdated Show resolved Hide resolved
repolink/manual_review_app.go Outdated Show resolved Hide resolved
repolink/show.go Outdated Show resolved Hide resolved
repolink/update.go Outdated Show resolved Hide resolved
review_apps/show.go Outdated Show resolved Hide resolved

@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
cmd/repo_link.go Outdated Show resolved Hide resolved
cmd/repo_link.go Outdated Show resolved Hide resolved
@Soulou

This comment has been minimized.

Copy link
Member

commented Aug 20, 2019

And --no-auto-review-apps?

@EtienneM

This comment has been minimized.

Copy link
Member

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

@EtienneM

This comment has been minimized.

Copy link
Member

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.

@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 referenced this pull request Aug 28, 2019

@EtienneM EtienneM requested review from johnsudaar and removed request for Soulou Aug 29, 2019

brandon-welsch and others added 20 commits Aug 5, 2019
Rename scm-integrations-* commands to integrations-* and rename the i…
…ntegrations-create to integrations-add
integration-link-create only takes a URL as argument
The integration type is infered from it

@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)

This comment has been minimized.

Copy link
@johnsudaar

johnsudaar Aug 29, 2019

Member

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.

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

if branch != "" && p.repoLink.Branch != branch {

This comment has been minimized.

Copy link
@johnsudaar

johnsudaar Aug 29, 2019

Member

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.

}

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

This comment has been minimized.

Copy link
@johnsudaar

johnsudaar Aug 29, 2019

Member

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

This comment has been minimized.

Copy link
@EtienneM

EtienneM Aug 30, 2019

Member

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

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

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

repoLink, err := c.SCMRepoLinkShow(app)

This comment has been minimized.

Copy link
@johnsudaar

johnsudaar Aug 29, 2019

Member

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

This comment has been minimized.

Copy link
@EtienneM

EtienneM Aug 30, 2019

Member

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.
cmd/scm_integrations.go Show resolved Hide resolved
EtienneM added 2 commits Aug 30, 2019

@EtienneM EtienneM requested a review from johnsudaar Aug 30, 2019

EtienneM added 2 commits 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

continuous-integration/codeship Build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.