Skip to content
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

GitHub tree #133

Merged
merged 3 commits into from
Sep 19, 2022
Merged

GitHub tree #133

merged 3 commits into from
Sep 19, 2022

Conversation

asfaltboy
Copy link
Contributor

Example query results

Results
Add example SQL query results here (please include the input queries as well)

@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale No recent activity has been detected on this issue/PR and it will be closed label Apr 21, 2022
@asfaltboy asfaltboy closed this Apr 22, 2022
@cbruno10
Copy link
Contributor

Hey @asfaltboy , thanks for opening this PR and sorry we've missed it for so long! I'm going to re-open it and we'll review it early next week. If we have any feedback or suggestions, we'll add them back in the PR.

@cbruno10 cbruno10 reopened this Apr 22, 2022
@cbruno10 cbruno10 removed the stale No recent activity has been detected on this issue/PR and it will be closed label Apr 22, 2022
return &plugin.Table{
Name: "github_tree",
Description: "Tree in the given repository, lists files in the git tree",
Get: &plugin.GetConfig{
Copy link
Contributor

@bigdatasourav bigdatasourav Apr 26, 2022

Choose a reason for hiding this comment

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

Could you please replace get with the list as below -

List: &plugin.ListConfig{
			Hydrate:           tableGitHubTreeGet,
			ShouldIgnoreError: isNotFoundError([]string{"404"}),
			KeyColumns: []*plugin.KeyColumn{
				{Name: "repository_full_name", Require: plugin.Required},
				{Name: "sha", Require: plugin.Required},
				{Name: "recursive", Require: plugin.Optional},
			},
		},

logger.Trace("Connecting to client")
client := connect(ctx, d)

if h.Item != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this if-else block for hydrate data, as it is not required here.

quals := d.KeyColumnQuals
logger.Trace("Parsing key column quals", quals)
fullName := quals["repository_full_name"].GetStringValue()
sha := quals["tree_sha"].GetStringValue()
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a check for empty values like below -

// check if fullName and sha is empty
	if fullName == "" || sha == "" {
		return nil, nil
	}

tree := getResp.tree
if tree != nil {
logger.Trace("Returning tree", tree)
return tree, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return tree, nil
d.StreamListItem(ctx, tree)

logger.Trace("Returning tree", tree)
return tree, nil
}
logger.Error("Nothing found")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.Error("Nothing found")

getResp := getResponse.(GetResponse)
tree := getResp.tree
if tree != nil {
logger.Trace("Returning tree", tree)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.Trace("Returning tree", tree)

Columns: []*plugin.Column{
// Top columns
{Name: "repository_full_name", Type: proto.ColumnType_STRING, Transform: transform.FromQual("repository_full_name"), Description: "Full name of the repository"},
{Name: "tree_sha", Type: proto.ColumnType_STRING, Transform: transform.FromQual("tree_sha"), Description: "Tree SHA"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{Name: "tree_sha", Type: proto.ColumnType_STRING, Transform: transform.FromQual("tree_sha"), Description: "Tree SHA"},
{Name: "sha", Type: proto.ColumnType_STRING, Transform: transform.FromQual("sha"), Description: "Tree SHA"},

quals := d.KeyColumnQuals
logger.Trace("Parsing key column quals", quals)
fullName := quals["repository_full_name"].GetStringValue()
sha := quals["tree_sha"].GetStringValue()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sha := quals["tree_sha"].GetStringValue()
sha := quals["sha"].GetStringValue()

@bigdatasourav
Copy link
Contributor

@asfaltboy Hope you are doing good!
While reviewing the PR I have suggested some changes. Also, there are merge conflicts which need to resolve.

Additionally, add a doc file (github_tree.md), example.

Please let us know if you need any help.

@bigdatasourav
Copy link
Contributor

bigdatasourav commented May 12, 2022

Hey @asfaltboy, please let us know if you have any questions or need any help with this PR, as we’d love to get your table in!

@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale No recent activity has been detected on this issue/PR and it will be closed label Jul 11, 2022
@cbruno10 cbruno10 changed the base branch from main to add-github-tree-table July 12, 2022 12:22
@cbruno10 cbruno10 changed the base branch from add-github-tree-table to main July 12, 2022 12:22
@github-actions
Copy link

This PR was closed because it has been stalled for 90 days with no activity.

@github-actions github-actions bot closed this Aug 11, 2022
@cbruno10 cbruno10 removed the stale No recent activity has been detected on this issue/PR and it will be closed label Aug 12, 2022
@cbruno10 cbruno10 reopened this Aug 12, 2022
@github-actions
Copy link

'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.'

@github-actions github-actions bot added the stale No recent activity has been detected on this issue/PR and it will be closed label Sep 11, 2022
@cbruno10 cbruno10 marked this pull request as ready for review September 19, 2022 19:53
@cbruno10 cbruno10 changed the base branch from main to add-github-tree-table September 19, 2022 19:53
@cbruno10 cbruno10 changed the base branch from add-github-tree-table to main September 19, 2022 19:53
@cbruno10 cbruno10 changed the base branch from main to add-github-tree-table September 19, 2022 19:58
@cbruno10 cbruno10 merged commit b5fa7f3 into turbot:add-github-tree-table Sep 19, 2022
@cbruno10 cbruno10 removed the stale No recent activity has been detected on this issue/PR and it will be closed label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants