git creation with env params;

This commit is contained in:
naudachu 2023-11-20 21:33:46 +05:00
parent 290d0d1f48
commit 632fbd249e
5 changed files with 22 additions and 21 deletions

View File

@ -92,26 +92,19 @@ func (wc *WorkflowController) createGitForExistingProject(ctx context.Context, r
}
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 req.ChannelID != "" {
projectFromDB, err := wc.GetProjectByChannelID(ctx, req.ChannelID)
if err != nil {
return &ProjectResponse{
Project: nil,
Message: fmt.Errorf("unable to retrieve project from db: %v", err),
}
}
// var (
// name string
// dbticket db.Ticket
// result ProjectResponse
// )
p = projectFromDB
}
switch {
case p != nil && req.IsBuildGit:

View File

@ -20,6 +20,8 @@ type GitConfig struct {
BaseUrl string
Token string
User string
OrgName string
Team string
}
type CloudConfig struct {
@ -71,6 +73,8 @@ func InitConfig(envFilePath string) Config {
BaseUrl: os.Getenv("GIT_BASE_URL"),
Token: os.Getenv("GIT_TOKEN"),
User: os.Getenv("GIT_USER"),
OrgName: os.Getenv("ORG"),
Team: os.Getenv("TEAM"),
},
Cloud: CloudConfig{
BaseUrl: os.Getenv("CLOUD_BASE_URL"),

View File

@ -1,6 +1,7 @@
package services
import (
"fmt"
"log"
"ticket-pimp/internal/domain"
"ticket-pimp/internal/helpers"
@ -9,6 +10,7 @@ import (
type Git struct {
*CommonClient
conf *domain.GitConfig
}
type IGit interface {
@ -30,6 +32,7 @@ func NewGit(conf domain.GitConfig) *Git {
return &Git{
CommonClient: &CommonClient{client},
conf: &conf,
}
}
@ -67,7 +70,7 @@ func (gb *Git) newRepo(name string) (*domain.Git, error) {
resp, _ := gb.R().
SetBody(&payload).
SetSuccessResult(&git).
Post("/orgs/mobilerino/repos")
Post(fmt.Sprintf("/orgs/%s/repos", gb.conf.OrgName))
if resp.Err != nil {
log.Print(resp.Status, resp.Err)
@ -87,7 +90,8 @@ func (gb *Git) defaultGroupAsCollaborator(git *domain.Git) (*domain.Git, error)
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().
SetBody(&payload).

View File

@ -11,7 +11,7 @@
# Разработка:
## Запуск вспомогательного контейнера с базой:
`docker-compose -f compose.dev.yaml up -d`
`docker-compose up -d`
## Migrations / sqlc:
*Deprecated*, т.к. проверяем и делаем миграции в коде.