Skip to content

[public-api] Implement ProjectsService.CreateProject #14643

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

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Nov 13, 2022

Description

Related Issue(s)

How to test

  1. Preview, sign in with Github and give perms to Read Repo
  2. Obtain an Access Token by running the following in the console, after logging in
    await window._gp.gitpodService.server.generateNewGitpodToken({ type: 1, scopes: ["function:getGitpodTokenScopes",
    		"function:createTeam",
            "function:createProject",
    		"function:getTeamMembers",
    		"function:getGenericInvite",
    		"function:getTeams",
    		"function:getTeam",
    		"resource:default",]})
  3. Setup the token as env variable BEARER_TOKEN="<token>" in your terminal
  4. Create a team programmatically
    	curl \
        --header 'Content-Type: application/json' \
        --header "Authorization: Bearer $BEARER_TOKEN" \
        --data '{ "name": "<team_name>" }' \
        https://api.mp-papi-cr5eede70b3a.preview.gitpod-dev.com/gitpod.experimental.v1.TeamsService/CreateTeam
  5. Take note of the Team ID in the response, use it in step 6
  6. Create a Project in this team, choose one of your GitHub repos
    curl \
      --header 'Content-Type: application/json' \
      --header "Authorization: Bearer $BEARER_TOKEN" \
      --data '{ "name": "connect-go-prometheus", "slug": "connect-go-prometheus", "cloneUrl": "https://github.com/easyCZ/connect-go-prometheus.git", "teamId": "<team-id>", }' \
      https://api.mp-papi-cr5eede70b3a.preview.gitpod-dev.com/gitpod.experimental.v1.ProjectsService/CreateProject
    
  7. Use the project from the dashboard

Release Notes

NONE

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mp-papi-create-project.2 because the annotations in the pull request description changed
(with .werft/ from main)

@easyCZ easyCZ force-pushed the mp/protocol-add-team-apis branch from 4477412 to 77d34d6 Compare November 14, 2022 10:12
@easyCZ easyCZ force-pushed the mp/papi-create-project branch from c8371d6 to 0479409 Compare November 14, 2022 10:12
Base automatically changed from mp/protocol-add-team-apis to main November 15, 2022 08:10
@roboquat roboquat added size/XXL and removed size/XL labels Nov 15, 2022
@easyCZ easyCZ force-pushed the mp/papi-create-project branch from 0479409 to 5fbad1b Compare November 15, 2022 08:25
@roboquat roboquat added size/XL and removed size/XXL labels Nov 15, 2022
@easyCZ
Copy link
Member Author

easyCZ commented Nov 15, 2022

/werft run

👍 started the job as gitpod-build-mp-papi-create-project.5
(with .werft/ from main)

@easyCZ easyCZ force-pushed the mp/papi-create-project branch 5 times, most recently from 7b971bb to 13a6594 Compare November 16, 2022 07:42
@easyCZ easyCZ marked this pull request as ready for review November 16, 2022 13:46
@easyCZ easyCZ requested a review from a team November 16, 2022 13:46
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Nov 16, 2022
@geropl
Copy link
Member

geropl commented Nov 18, 2022

/werft run

👍 started the job as gitpod-build-mp-papi-create-project.11
(with .werft/ from main)

@easyCZ easyCZ force-pushed the mp/papi-create-project branch from 13a6594 to 298f1b2 Compare November 20, 2022 20:50
@easyCZ easyCZ force-pushed the mp/papi-create-project branch from 298f1b2 to 3ea3159 Compare November 20, 2022 20:50
@easyCZ
Copy link
Member Author

easyCZ commented Nov 21, 2022

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-mp-papi-create-project.14
(with .werft/ from main)

@laushinka
Copy link
Contributor

laushinka commented Nov 23, 2022

At step 6, when I did

curl \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $BEARER_TOKEN" \
  --data '{ "name": "testing-prebuild-gh", "slug": "testing-prebuild-gh", "cloneUrl": "https://github.com/laushinka/testing-prebuild-gh.git", "teamId": "ee4c2b7e-e7ff-498b-b576-d3ba92d3d01f", }' \
  https://api.mp-papi-cr5eede70b3a.preview.gitpod-dev.com/gitpod.experimental.v1.ProjectsService/CreateProject

I got {"code":"invalid_argument","message":"unmarshal into *v1.CreateProjectRequest: proto: (line 1:3): unknown field \"name\""}

Did I do something wrong in the curl?

Note: I entered the name and slug arbitrarily.

@easyCZ
Copy link
Member Author

easyCZ commented Nov 23, 2022

@laushinka
Thanks. I've copy-pasted the instructions wrong (sorry about that). The right command is:

curl \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer $BEARER_TOKEN" \
  --data '{ "project": {"name": "testing-prebuild-gh", "slug": "testing-prebuild-gh", "cloneUrl": "https://github.com/laushinka/testing-prebuild-gh.git", "teamId": "ee4c2b7e-e7ff-498b-b576-d3ba92d3d01f"} }' \
  https://api.mp-papi-cr5eede70b3a.preview.gitpod-dev.com/gitpod.experimental.v1.ProjectsService/CreateProject

The payload has to be in the form:

{ project: {
    name:
    slug:
    cloneUrl:
  }
}

@laushinka
Copy link
Contributor

@easyCZ Thanks! So my requests were responded with {"code":"internal","message":"Request createProject failed with message: GitHub API Error. Status: 404"}, but turns out the projects did get created. So it works but it responded with the wrong message?

Copy link
Contributor

@laushinka laushinka left a comment

Choose a reason for hiding this comment

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

Approving with a hold for this question[1]

/hold

@easyCZ
Copy link
Member Author

easyCZ commented Nov 23, 2022

@laushinka Yeah, this relates to https://gitpod.slack.com/archives/C02EN94AEPL/p1668585656105419

@easyCZ
Copy link
Member Author

easyCZ commented Nov 23, 2022

It's possible you did not do step 1. to grant read perms to Github

  1. Preview, sign in with Github and give perms to Read Repo

@laushinka
Copy link
Contributor

  1. Preview, sign in with Github and give perms to Read Repo

INDEED. Sorry, let me try again with a different repo.

@laushinka
Copy link
Contributor

  1. Preview, sign in with Github and give perms to Read Repo

INDEED. Sorry, let me try again with a different repo.

Like a charm.

/unhold

@roboquat roboquat merged commit 0d759f7 into main Nov 23, 2022
@roboquat roboquat deleted the mp/papi-create-project branch November 23, 2022 13:58
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/XL team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants