redhat-developer / kam

GitOps Application Manager: An opinionated CLI that generates the Kubernetes resources for managing your Tekton-based CI manifests, ArgoCD-based CD manifests and Application manifests in Git.
Apache License 2.0
145 stars 83 forks source link

kam should use Github push API instead of `git push` command #128

Open iam-veeramalla opened 3 years ago

iam-veeramalla commented 3 years ago

Is your feature request related to a problem? Please describe. kam can make use of the github push api to push the files/folders it creates when --push-to-git=true flag is enabled. Right now, User has to add his public key to github account. https://github.com/redhat-developer/kam/blob/104bc4958d7929c492b2d85272386b63ed6530c3/pkg/pipelines/utils.go#L85

Describe the solution you'd like Use the Github Push API. https://docs.github.com/en/free-pro-team@latest/graphql/reference/objects#push

Describe alternatives you've considered Its not a blocker as user can still get the things done by adding his public key to github account.

Additional context Issue: https://github.com/redhat-developer/kam/blob/104bc4958d7929c492b2d85272386b63ed6530c3/pkg/pipelines/utils.go#L85

Solution towards the Issue: https://docs.github.com/en/free-pro-team@latest/graphql/reference/objects#push

bigkevmcd commented 3 years ago

The biggest problem with this, is that we'd need to implement more functionality from git into the kam binary (probably using go-git).

We'd need the equivalent of git push and the various options that uses, and probably functionality around getting to the git hosting service (proxy configuration).

iam-veeramalla commented 3 years ago

The motive behind raising this issue is to understand , if we can make kam more API friendly. For example, instead of using git push can we use the equivalent API from git Providers(Github, BitBucket and more).

Something like this:

curl -i -X PUT -H ‘Authorization: token xxxx’ -d
‘{“message”: “push gitops files”,
“content”:”application/json”
}’ https://api.github.com/repos/gitops/test-appliation

However, the obvious downside is to deal with the different APIs from git providers.

bigkevmcd commented 3 years ago

The biggest problem tho', is that users would need to replace their use of git with kam for most git operations?

We'd need to implement functionality for at least the following git actions.

I'm not sure there's any benefit in using the API, over using something like go-git, but authenticating with a token.

But, replacing git with kam doesn't really feel like something we should be doing?

iam-veeramalla commented 3 years ago

The biggest problem tho', is that users would need to replace their use of git with kam for most git operations?

We'd need to implement functionality for at least the following git actions.

  • git push
  • git pull
  • git diff with an upstream branch
  • git fetch

I'm not sure there's any benefit in using the API, over using something like go-git, but authenticating with a token.

But, replacing git with kam doesn't really feel like something we should be doing?

@bigkevmcd I was only talking about replacing git push , I agree that we should not replace git with kam for any other use cases.

bigkevmcd commented 3 years ago

But if we only replace git push, what about the other use-cases?

Can you maybe explain the benefits of only replacing git push?

iam-veeramalla commented 3 years ago

But if we only replace git push, what about the other use-cases?

Can you maybe explain the benefits of only replacing git push?

I haven't explored the code completely kevin, I will take some time on this today and comment.

bigkevmcd commented 3 years ago

@iam-veeramalla can you maybe update with the results of your explorations?