git creation with env params;
This commit is contained in:
parent
290d0d1f48
commit
632fbd249e
|
|
@ -92,26 +92,19 @@ func (wc *WorkflowController) createGitForExistingProject(ctx context.Context, r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WorkflowController) CreateGit(ctx context.Context, req GitRequest) *ProjectResponse {
|
func (wc *WorkflowController) CreateGit(ctx context.Context, req GitRequest) *ProjectResponse {
|
||||||
if req.ChannelID == "" {
|
|
||||||
return &ProjectResponse{
|
|
||||||
Project: nil,
|
|
||||||
Message: errors.New("empty channel string"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p, err := wc.GetProjectByChannelID(ctx, req.ChannelID)
|
var p *domain.Project = nil
|
||||||
if err != nil {
|
|
||||||
return &ProjectResponse{
|
|
||||||
Project: nil,
|
|
||||||
Message: fmt.Errorf("unable to retrieve project from db: %v", err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// var (
|
if req.ChannelID != "" {
|
||||||
// name string
|
projectFromDB, err := wc.GetProjectByChannelID(ctx, req.ChannelID)
|
||||||
// dbticket db.Ticket
|
if err != nil {
|
||||||
// result ProjectResponse
|
return &ProjectResponse{
|
||||||
// )
|
Project: nil,
|
||||||
|
Message: fmt.Errorf("unable to retrieve project from db: %v", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = projectFromDB
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case p != nil && req.IsBuildGit:
|
case p != nil && req.IsBuildGit:
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ type GitConfig struct {
|
||||||
BaseUrl string
|
BaseUrl string
|
||||||
Token string
|
Token string
|
||||||
User string
|
User string
|
||||||
|
OrgName string
|
||||||
|
Team string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CloudConfig struct {
|
type CloudConfig struct {
|
||||||
|
|
@ -71,6 +73,8 @@ func InitConfig(envFilePath string) Config {
|
||||||
BaseUrl: os.Getenv("GIT_BASE_URL"),
|
BaseUrl: os.Getenv("GIT_BASE_URL"),
|
||||||
Token: os.Getenv("GIT_TOKEN"),
|
Token: os.Getenv("GIT_TOKEN"),
|
||||||
User: os.Getenv("GIT_USER"),
|
User: os.Getenv("GIT_USER"),
|
||||||
|
OrgName: os.Getenv("ORG"),
|
||||||
|
Team: os.Getenv("TEAM"),
|
||||||
},
|
},
|
||||||
Cloud: CloudConfig{
|
Cloud: CloudConfig{
|
||||||
BaseUrl: os.Getenv("CLOUD_BASE_URL"),
|
BaseUrl: os.Getenv("CLOUD_BASE_URL"),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"ticket-pimp/internal/domain"
|
"ticket-pimp/internal/domain"
|
||||||
"ticket-pimp/internal/helpers"
|
"ticket-pimp/internal/helpers"
|
||||||
|
|
@ -9,6 +10,7 @@ import (
|
||||||
|
|
||||||
type Git struct {
|
type Git struct {
|
||||||
*CommonClient
|
*CommonClient
|
||||||
|
conf *domain.GitConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type IGit interface {
|
type IGit interface {
|
||||||
|
|
@ -30,6 +32,7 @@ func NewGit(conf domain.GitConfig) *Git {
|
||||||
|
|
||||||
return &Git{
|
return &Git{
|
||||||
CommonClient: &CommonClient{client},
|
CommonClient: &CommonClient{client},
|
||||||
|
conf: &conf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +70,7 @@ func (gb *Git) newRepo(name string) (*domain.Git, error) {
|
||||||
resp, _ := gb.R().
|
resp, _ := gb.R().
|
||||||
SetBody(&payload).
|
SetBody(&payload).
|
||||||
SetSuccessResult(&git).
|
SetSuccessResult(&git).
|
||||||
Post("/orgs/mobilerino/repos")
|
Post(fmt.Sprintf("/orgs/%s/repos", gb.conf.OrgName))
|
||||||
|
|
||||||
if resp.Err != nil {
|
if resp.Err != nil {
|
||||||
log.Print(resp.Status, resp.Err)
|
log.Print(resp.Status, resp.Err)
|
||||||
|
|
@ -87,7 +90,8 @@ func (gb *Git) defaultGroupAsCollaborator(git *domain.Git) (*domain.Git, error)
|
||||||
Perm: "push",
|
Perm: "push",
|
||||||
}
|
}
|
||||||
|
|
||||||
respURL := "/orgs/mobilerino/teams/devs/repos/mobilerino/" + git.Name
|
// respURL := "/orgs/mobilerino/teams/devs/repos/mobilerino/" + git.Name
|
||||||
|
respURL := fmt.Sprintf("/orgs/%s/teams/devs/repos/%s/%s", gb.conf.OrgName, gb.conf.OrgName, git.Name)
|
||||||
|
|
||||||
resp, _ := gb.R().
|
resp, _ := gb.R().
|
||||||
SetBody(&payload).
|
SetBody(&payload).
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
# Разработка:
|
# Разработка:
|
||||||
|
|
||||||
## Запуск вспомогательного контейнера с базой:
|
## Запуск вспомогательного контейнера с базой:
|
||||||
`docker-compose -f compose.dev.yaml up -d`
|
`docker-compose up -d`
|
||||||
|
|
||||||
## Migrations / sqlc:
|
## Migrations / sqlc:
|
||||||
*Deprecated*, т.к. проверяем и делаем миграции в коде.
|
*Deprecated*, т.к. проверяем и делаем миграции в коде.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue