Skip to content

include projects api #2006

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
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/bootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ func Bootstrap(templates embed.FS, diggerController controllers.DiggerController
reposApiGroup.GET("/", controllers.ListReposApi)
reposApiGroup.GET("/:repo_id/jobs", controllers.GetJobsForRepoApi)

projectsApiGroup := apiGroup.Group("/projects")
projectsApiGroup.GET("/", controllers.ListProjectsApi)
Comment on lines +232 to +233
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Log debug context when handling projects API requests to improve traceability


githubApiGroup := apiGroup.Group("/github")
githubApiGroup.POST("/link", controllers.LinkGithubInstallationToOrgApi)

Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func setupSuite(tb testing.TB) (func(tb testing.TB), *models.Database) {

// create test project
projectName := "test project"
_, err = database.CreateProject(projectName, org, repo.RepoFullName, false, false)
_, err = database.CreateProject(projectName, "", org, repo.RepoFullName, false, false)
if err != nil {
panic(err)
}
Expand Down
53 changes: 47 additions & 6 deletions backend/controllers/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,50 @@ import (
"gorm.io/gorm"
)

func ListProjects(c *gin.Context) {
func ListProjectsApi(c *gin.Context) {
// assume all exists as validated in middleware
organisationId := c.GetString(middleware.ORGANISATION_ID_KEY)
organisationSource := c.GetString(middleware.ORGANISATION_SOURCE_KEY)

var org models.Organisation
err := models.DB.GormDB.Where("external_id = ? AND external_source = ?", organisationId, organisationSource).First(&org).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
slog.Info("Organisation not found", "organisationId", organisationId, "source", organisationSource)
c.String(http.StatusNotFound, "Could not find organisation: "+organisationId)
} else {
slog.Error("Error fetching organisation", "organisationId", organisationId, "source", organisationSource, "error", err)
c.String(http.StatusInternalServerError, "Error fetching organisation")
}
return
}

var projects []models.Project

err = models.DB.GormDB.Preload("Organisation").
Where("projects.organisation_id = ?", org.ID).
Order("name").
Find(&projects).Error

if err != nil {
slog.Error("Error fetching projects", "organisationId", organisationId, "orgId", org.ID, "error", err)
c.String(http.StatusInternalServerError, "Unknown error occurred while fetching database")
return
}

marshalledRepos := make([]interface{}, 0)

for _, p := range projects {
marshalled := p.MapToJsonStruct()
marshalledRepos = append(marshalledRepos, marshalled)
}

slog.Info("Successfully fetched projects", "organisationId", organisationId, "orgId", org.ID, "projectCount", len(projects))

response := make(map[string]interface{})
response["result"] = marshalledRepos

c.JSON(http.StatusOK, response)
}

func FindProjectsForRepo(c *gin.Context) {
Expand Down Expand Up @@ -353,11 +395,10 @@ func ReportProjectsForRepo(c *gin.Context) {
)

project := models.Project{
Name: request.Name,
ConfigurationYaml: request.ConfigurationYaml,
OrganisationID: org.ID,
RepoFullName: repo.RepoFullName,
Organisation: org,
Name: request.Name,
OrganisationID: org.ID,
RepoFullName: repo.RepoFullName,
Organisation: org,
}
Comment on lines 397 to 402
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: ConfigurationYaml field has been removed from project creation. Ensure this doesn't break any existing code that expects this field.


err = models.DB.GormDB.Create(&project).Error
Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ require (
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/go-github/v61 v61.0.0
github.com/google/uuid v1.6.0
github.com/imdatngo/slog-gorm/v2 v2.0.0
github.com/ktrysmt/go-bitbucket v0.9.81
github.com/migueleliasweb/go-github-mock v0.0.23
github.com/orandin/slog-gorm v1.4.0
github.com/robfig/cron v1.2.0
github.com/samber/lo v1.39.0
github.com/samber/slog-gin v1.15.0
Expand Down
4 changes: 2 additions & 2 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imdatngo/slog-gorm/v2 v2.0.0 h1:SrMVqpExd3USDZjiFlJoFg3FJvZOreJX/d8N8G6PQ4w=
github.com/imdatngo/slog-gorm/v2 v2.0.0/go.mod h1:hp2V0UOoVXwMT9YUbB/EbaXCN7g/7txxekKaalO/6fU=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
Expand Down Expand Up @@ -1683,8 +1685,6 @@ github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQ
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/opencontainers/runc v1.1.9 h1:XR0VIHTGce5eWPkaPesqTBrhW2yAcaraWfsEalNwQLM=
github.com/opencontainers/runc v1.1.9/go.mod h1:CbUumNnWCuTGFukNXahoo/RFBZvDAgRh/smNYNOhA50=
github.com/orandin/slog-gorm v1.4.0 h1:FgA8hJufF9/jeNSYoEXmHPPBwET2gwlF3B85JdpsTUU=
github.com/orandin/slog-gorm v1.4.0/go.mod h1:MoZ51+b7xE9lwGNPYEhxcUtRNrYzjdcKvA8QXQQGEPA=
github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA=
github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs=
github.com/owenrumney/go-sarif v1.1.1 h1:QNObu6YX1igyFKhdzd7vgzmw7XsWN3/6NMGuDzBgXmE=
Expand Down
2 changes: 2 additions & 0 deletions backend/migrations/20250704024948.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "projects" table
ALTER TABLE "public"."projects" ADD COLUMN "directory" text NULL;
2 changes: 2 additions & 0 deletions backend/migrations/20250704025208.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "projects" table
ALTER TABLE "public"."projects" DROP COLUMN "configuration_yaml";
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using IF EXISTS clause to prevent errors if column was already dropped in some environments

Suggested change
ALTER TABLE "public"."projects" DROP COLUMN "configuration_yaml";
ALTER TABLE "public"."projects" DROP COLUMN IF EXISTS "configuration_yaml";

Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify that all references to configuration_yaml have been removed.

This migration drops the configuration_yaml column, which is a destructive operation. Ensure that:

  1. All code references to ConfigurationYaml field have been removed or updated
  2. Any data migration from configuration_yaml to directory has been completed
  3. This migration is safe to run in production

🏁 Script executed:

#!/bin/bash
# Search for any remaining references to configuration_yaml or ConfigurationYaml
echo "Searching for configuration_yaml references..."
rg -i "configuration_yaml|configurationyaml" --type go --type sql

echo "Searching for ConfigurationYaml field references..."
rg "ConfigurationYaml" --type go -A 3 -B 3

Length of output: 9506


Ensure Complete Removal of configuration_yaml References and Safe Data Migration

Please address the following before merging this destructive migration:

  • Remove all code references to the dropped configuration_yaml column and replace them with the new directory field (or appropriate substitute):
    • next/model/projects.gen.go & next/models_generated/projects.gen.go: eliminate the ConfigurationYaml field, regenerate models.
    • backend/controllers/projects.go: remove ConfigurationYaml from CreateProjectRequest and any handlers (e.g., ReportProjectsForRepo).
    • libs/backendapi/diggerapi.go: drop the configurationYaml parameter and JSON payload, update client calls to use directory.
  • Add a pre-migration step (in an earlier migration) to copy existing configuration_yaml data into directory (or the new storage) for all rows.
  • Delete or update the older migration (20231227132525.sql) that initially created configuration_yaml, if it’s no longer needed.
  • Regenerate and commit any affected codegen artifacts (models, clients) so the codebase compiles without the old field.
  • Verify in a staging environment that:
    1. Data is correctly migrated.
    2. No runtime errors occur in endpoints or background jobs.
    3. The new field behaves as expected.
🤖 Prompt for AI Agents
In backend/migrations/20250704025208.sql at lines 1-2, the migration drops the
configuration_yaml column but does not handle related code or data migration. To
fix this, remove all references to configuration_yaml in the codebase including
the specified Go model files, controller, and API client, replacing them with
the directory field. Add a prior migration that copies data from
configuration_yaml to directory for all existing rows. Also, delete or update
the older migration that created configuration_yaml if obsolete. Regenerate all
affected codegen artifacts to reflect these changes and verify in staging that
data migration is successful and no runtime errors occur.

4 changes: 3 additions & 1 deletion backend/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:IeQ6uHSz71Ox7tBqG6sy05KmaRMpYqhr0SeipkVSEbM=
h1:E1MYgdCTYDdHVINjSBVtGufzvYspZC8Wur7nvPK7fN0=
20231227132525.sql h1:43xn7XC0GoJsCnXIMczGXWis9d504FAWi4F1gViTIcw=
20240115170600.sql h1:IW8fF/8vc40+eWqP/xDK+R4K9jHJ9QBSGO6rN9LtfSA=
20240116123649.sql h1:R1JlUIgxxF6Cyob9HdtMqiKmx/BfnsctTl5rvOqssQw=
Expand Down Expand Up @@ -50,3 +50,5 @@ h1:IeQ6uHSz71Ox7tBqG6sy05KmaRMpYqhr0SeipkVSEbM=
20250512172515.sql h1:iIZIhFq3TTyjTzsxNWv3k4FcIkXfOCdHtmHNmYqjBMM=
20250512213729.sql h1:n8bYIXWko9xOUs+FPcG7lS3GXMVQBSygXX7Hpj20eVs=
20250530015921.sql h1:FidRW+0ur3mCDBPgP7V/sqr2jjfmi/CFJPRpNxTmqGs=
20250704024948.sql h1:ki8bOrfd8y7Mfq40Dz5lH6MUuQqPVah+oimeRDVHOOQ=
20250704025208.sql h1:XRY66dphINSj53mbxl5ALmyWqebuB1swPvUuUPvNR88=
20 changes: 9 additions & 11 deletions backend/models/orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ const (

type Project struct {
gorm.Model
Name string `gorm:"uniqueIndex:idx_project_org"`
OrganisationID uint `gorm:"uniqueIndex:idx_project_org"`
Organisation *Organisation
RepoFullName string `gorm:"uniqueIndex:idx_project_org"`
ConfigurationYaml string // TODO: probably needs to be deleted
Status ProjectStatus
IsGenerated bool
IsInMainBranch bool
Name string `gorm:"uniqueIndex:idx_project_org"`
Directory string
OrganisationID uint `gorm:"uniqueIndex:idx_project_org"`
Organisation *Organisation
RepoFullName string `gorm:"uniqueIndex:idx_project_org"`
Status ProjectStatus
IsGenerated bool
IsInMainBranch bool
}

func (p *Project) MapToJsonStruct() interface{} {
Expand All @@ -97,9 +97,6 @@ func (p *Project) MapToJsonStruct() interface{} {
OrganisationName string `json:"organisation_name"`
RepoID uint `json:"repo_id"`
RepoFullName string `json:"repo_full_name"`
RepoName string `json:"repo_name"`
RepoOrg string `json:"repo_org"`
RepoUrl string `json:"repo_url"`
IsInMainBranch bool `json:"is_in_main_branch"`
IsGenerated bool `json:"is_generated"`
LastActivityTimestamp string `json:"last_activity_timestamp"`
Expand All @@ -108,6 +105,7 @@ func (p *Project) MapToJsonStruct() interface{} {
}{
Id: p.ID,
Name: p.Name,
Directory: p.Directory,
OrganisationID: p.OrganisationID,
OrganisationName: p.Organisation.Name,
RepoFullName: p.RepoFullName,
Expand Down
2 changes: 1 addition & 1 deletion backend/models/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func setupSuiteScheduler(tb testing.TB) (func(tb testing.TB), *Database) {
}

projectName := "test project"
_, err = database.CreateProject(projectName, org, repo.RepoFullName, false, false)
_, err = database.CreateProject(projectName, "", org, repo.RepoFullName, false, false)
if err != nil {
panic(err)
}
Expand Down
21 changes: 16 additions & 5 deletions backend/models/setup.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package models

import (
"log/slog"
"os"

slogGorm "github.com/orandin/slog-gorm"
sloggorm "github.com/imdatngo/slog-gorm/v2"
"gorm.io/driver/postgres"
_ "gorm.io/driver/postgres"
"gorm.io/gorm"
"log/slog"
"os"
"time"
)

type Database struct {
Expand All @@ -20,8 +20,19 @@ var DEFAULT_ORG_NAME = "digger"
var DB *Database

func ConnectDatabase() {
slogger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Set log level based on DIGGER_LOG_LEVEL environment variable instead of hardcoding to LevelInfo

Suggested change
slogger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
logLevel := slog.LevelInfo
if os.Getenv("DIGGER_LOG_LEVEL") == "DEBUG" {
logLevel = slog.LevelDebug
}
slogger := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: logLevel}))


cfg := sloggorm.NewConfig(slogger.Handler()).
WithGroupKey("db").
WithSlowThreshold(time.Second).
WithIgnoreRecordNotFoundError(true)

if os.Getenv("DIGGER_LOG_LEVEL") == "DEBUG" {
cfg.WithTraceAll(true)
}
glogger := sloggorm.NewWithConfig(cfg)
database, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_URL")), &gorm.Config{
Logger: slogGorm.New(),
Logger: glogger,
})
if err != nil {
slog.Error("Failed to connect to database", "error", err)
Expand Down
11 changes: 8 additions & 3 deletions backend/models/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (db *Database) GetRepo(orgIdKey any, repoName string) (*Repo, error) {
}

func (db *Database) GetRepoByFullName(orgIdKey any, repoFullName string) (*Repo, error) {
slog.Info("getting repo by name",
slog.Info("getting repo by full name",
"orgId", orgIdKey,
"repoName", repoFullName)

Expand Down Expand Up @@ -1402,9 +1402,10 @@ func (db *Database) CreateOrganisation(name string, externalSource string, tenan
return org, nil
}

func (db *Database) CreateProject(name string, org *Organisation, repoFullName string, isGenerated bool, isInMainBranch bool) (*Project, error) {
func (db *Database) CreateProject(name string, directory string, org *Organisation, repoFullName string, isGenerated bool, isInMainBranch bool) (*Project, error) {
project := &Project{
Name: name,
Directory: directory,
Organisation: org,
RepoFullName: repoFullName,
Status: ProjectActive,
Expand Down Expand Up @@ -1642,15 +1643,19 @@ func (db *Database) RefreshProjectsFromRepo(orgId string, config configuration.D
err = db.GormDB.Transaction(func(tx *gorm.DB) error {
for _, dc := range config.Projects {
projectName := dc.Name
projectDirectory := dc.Dir
p, err := db.GetProjectByName(orgId, repoFullName, projectName)
if err != nil {
return fmt.Errorf("error retrieving project by name: %v", err)
}
if p == nil {
_, err := db.CreateProject(projectName, org, repoFullName, false, true)
_, err := db.CreateProject(projectName, projectDirectory, org, repoFullName, false, true)
if err != nil {
return fmt.Errorf("could not create project: %v", err)
}
} else {
p.Directory = projectDirectory
db.GormDB.Save(p)
}
Comment on lines +1656 to 1659
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for the database save operation.

The direct save operation on line 1658 lacks error handling, which could lead to silent failures when updating the project directory.

 } else {
   p.Directory = projectDirectory
-  db.GormDB.Save(p)
+  err := db.GormDB.Save(p).Error
+  if err != nil {
+    return fmt.Errorf("error updating project directory: %v", err)
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else {
p.Directory = projectDirectory
db.GormDB.Save(p)
}
} else {
p.Directory = projectDirectory
err := db.GormDB.Save(p).Error
if err != nil {
return fmt.Errorf("error updating project directory: %v", err)
}
}
🤖 Prompt for AI Agents
In backend/models/storage.go around lines 1656 to 1659, the call to
db.GormDB.Save(p) does not handle potential errors, risking silent failures.
Modify the code to capture the error returned by the Save operation, check if an
error occurred, and handle it appropriately, such as logging the error or
returning it to the caller to ensure failures are not ignored.

}
return nil
Expand Down
7 changes: 3 additions & 4 deletions backend/services/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
"github.com/diggerhq/digger/backend/models"
utils3 "github.com/diggerhq/digger/backend/utils"
"github.com/diggerhq/digger/ee/drift/utils"
dg_configuration "github.com/diggerhq/digger/libs/digger_config"
utils2 "github.com/diggerhq/digger/next/utils"
"log/slog"
"strconv"
"strings"
)

func LoadProjectsFromGithubRepo(gh utils2.GithubClientProvider, installationId string, repoFullName string, repoOwner string, repoName string, cloneUrl string, branch string) error {
func LoadProjectsFromGithubRepo(gh utils3.GithubClientProvider, installationId string, repoFullName string, repoOwner string, repoName string, cloneUrl string, branch string) error {
installationId64, err := strconv.ParseInt(installationId, 10, 64)
if err != nil {
slog.Error("failed to convert installation id %v to int64", "insallationId", installationId)
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Typo in error log parameter name 'insallationId'

Suggested change
slog.Error("failed to convert installation id %v to int64", "insallationId", installationId)
slog.Error("failed to convert installation id %v to int64", "installationId", installationId)

Expand All @@ -36,7 +34,8 @@ func LoadProjectsFromGithubRepo(gh utils2.GithubClientProvider, installationId s
return fmt.Errorf("repo not found: Org: %v | repo: %v", orgId, diggerRepoName)
}

_, token, err := utils.GetGithubService(gh, installationId64, repoFullName, repoOwner, repoName)
slog.Debug("getting github service", "installationId", installationId, "repoFullName", repoFullName, "repoOwner", repoOwner, "repoName", repoName)
_, token, err := utils3.GetGithubService(gh, installationId64, repoFullName, repoOwner, repoName)
if err != nil {
slog.Error("getting github service", "error", err)
return fmt.Errorf("error getting github service")
Expand Down
4 changes: 2 additions & 2 deletions backend/tasks/runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func setupSuite(tb testing.TB) (func(tb testing.TB), *models.Database) {

// create test project
projectName := "test project"
_, err = database.CreateProject(projectName, org, repo.RepoFullName, false, false)
_, err = database.CreateProject(projectName, "", org, repo.RepoFullName, false, false)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestThatRunQueueItemMovesFromQueuedToPlanningAfterPickup(t *testing.T) {
for i, testParam := range testParameters {
ciService := github2.MockCiService{}
batch, _ := models.DB.CreateDiggerBatch(models.DiggerVCSGithub, 123, "", "", "", 22, "", "", "", nil, 0, "", false, true, nil)
project, _ := models.DB.CreateProject(fmt.Sprintf("test%v", i), nil, "", false, false)
project, _ := models.DB.CreateProject(fmt.Sprintf("test%v", i), "", nil, "", false, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Missing error handling for CreateProject - ignoring error could mask test failures

Suggested change
project, _ := models.DB.CreateProject(fmt.Sprintf("test%v", i), "", nil, "", false, false)
project, err := models.DB.CreateProject(fmt.Sprintf("test%v", i), "", nil, "", false, false)
assert.NoError(t, err)

planStage, _ := models.DB.CreateDiggerRunStage(batch.ID.String())
applyStage, _ := models.DB.CreateDiggerRunStage(batch.ID.String())
diggerRun, _ := models.DB.CreateDiggerRun("", 1, testParam.InitialStatus, "sha", "", 123, 1, project.Name, "apply", &planStage.ID, &applyStage.ID)
Expand Down
5 changes: 5 additions & 0 deletions ee/drift/utils/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import (
"github.com/dominikbraun/graph"
"github.com/google/go-github/v61/github"
"log"
"log/slog"
Comment on lines 15 to +16
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Using both log and slog packages - consider standardizing on slog throughout

net "net/http"
"os"
"path"
"strconv"
)

func GetGithubClient(gh utils.GithubClientProvider, installationId int64, repoFullName string) (*github.Client, *string, error) {
slog.Debug("Getting GitHub client",
"installationId", installationId,
"repoFullName", repoFullName)
repo, err := dbmodels.DB.GetRepoByInstllationIdAndRepoFullName(strconv.FormatInt(installationId, 10), repoFullName)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Method name contains typo: 'Instllation' is missing an 'a'

Suggested change
repo, err := dbmodels.DB.GetRepoByInstllationIdAndRepoFullName(strconv.FormatInt(installationId, 10), repoFullName)
repo, err := dbmodels.DB.GetRepoByInstallationIdAndRepoFullName(strconv.FormatInt(installationId, 10), repoFullName)

if err != nil {
log.Printf("Error getting repo: %v", err)
Expand All @@ -31,6 +35,7 @@ func GetGithubClient(gh utils.GithubClientProvider, installationId int64, repoFu
}

func GetGithubService(gh utils.GithubClientProvider, installationId int64, repoFullName string, repoOwner string, repoName string) (*github2.GithubService, *string, error) {
slog.Debug("getting github client", "installationId", installationId, "repoFullName", repoFullName)
ghClient, token, err := GetGithubClient(gh, installationId, repoFullName)
if err != nil {
log.Printf("Error creating github app client: %v", err)
Expand Down
Loading