Skip to content

Commit

Permalink
🐛 Fix GitHub org name (#1882)
Browse files Browse the repository at this point in the history
* 🐛 Fix GitHub org name

Fixes #1858

Signed-off-by: Christian Zunker <[email protected]>

* Fix org id for org discovery

Signed-off-by: Christian Zunker <[email protected]>

* Fix repo asset name for discovery

Signed-off-by: Christian Zunker <[email protected]>

---------

Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker authored Sep 25, 2023
1 parent 4ad0c31 commit c78ba30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions providers/github/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnect
return nil, err
}
assetList = append(assetList, &inventory.Asset{
PlatformIds: []string{connection.NewGithubOrgIdentifier(org.Name.Data)},
PlatformIds: []string{connection.NewGithubOrgIdentifier(org.Login.Data)},
Name: org.Name.Data,
Platform: connection.GithubOrgPlatform,
Labels: map[string]string{},
Expand All @@ -108,8 +108,8 @@ func org(runtime *plugin.Runtime, orgName string, conn *connection.GithubConnect
for i := range org.GetRepositories().Data {
repo := org.GetRepositories().Data[i].(*mqlGithubRepository)
assetList = append(assetList, &inventory.Asset{
PlatformIds: []string{connection.NewGitHubRepoIdentifier(org.Name.Data, repo.Name.Data)},
Name: org.Name.Data + "/" + repo.Name.Data,
PlatformIds: []string{connection.NewGitHubRepoIdentifier(org.Login.Data, repo.Name.Data)},
Name: org.Login.Data + "/" + repo.Name.Data,
Platform: connection.GithubRepoPlatform,
Labels: make(map[string]string),
Connections: []*inventory.Config{cloneInventoryConf(conn.Conf)},
Expand Down
8 changes: 5 additions & 3 deletions providers/github/resources/github_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ func initGithubOrganization(runtime *plugin.Runtime, args map[string]*llx.RawDat
}

var name string
if x, ok := args["name"]; ok {
name = x.Value.(string)
if org.Name != nil {
name = *org.Name
}
if name == "" {
name = *org.Name
if x, ok := args["name"]; ok {
name = x.Value.(string)
}
}
args["id"] = llx.IntDataPtr(org.ID)
args["name"] = llx.StringData(name)
Expand Down

0 comments on commit c78ba30

Please sign in to comment.