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

Support private repository extensions #928

Closed
igorbrites opened this issue Jun 5, 2024 · 6 comments · Fixed by #1207
Closed

Support private repository extensions #928

igorbrites opened this issue Jun 5, 2024 · 6 comments · Fixed by #1207
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@igorbrites
Copy link

Feature description 💡

I created a private terrakube-extensions, and now I need to use it on the executors, though it's showing this error to me:

ERROR org.terrakube.executor.service.scripts.ScriptEngineService - https://github.com/MyOrg/terrakube-extensions: Authentication is required but no CredentialsProvider has been registered

How do I pass the credentials? I thought the same GitHub App used to make Dex work was also being used here, but it's not.

Anything else?

Opened as a feature request because idk if it's a bug 😬

@igorbrites igorbrites added the enhancement New feature or request label Jun 5, 2024
@alfespa17
Copy link
Member

It is not really a bug, it will be a new feature.

You can customize the git repository but for now it does not support a private repository.

@alfespa17
Copy link
Member

The executor component is cloning the directory in this part of the code without adding any kind of authentication as you can see here.

This is the code when you are cloning a private git repository that is used inside a workspace that is really similar

The parameter that the executor receives to execute a job is done in this part of the code, maybe adding some information about the private extension could work.

The API is sending the request with all the parameters to the executor in this part of the code

public boolean execute(Job job, String stepId, Flow flow) {

And finally the Java class that represents the YAML file that you use to define extension is in this part ot the code.

https://github.com/AzBuilder/terrakube/blob/main/api/src/main/java/org/terrakube/api/plugin/scheduler/job/tcl/model/Flow.java

By the way I think you are the first person that want to use a private extension repository

@igorbrites
Copy link
Author

Hmmm got it. Could we mount the SSH key we configure on the organization inside the executors and use it to clone the repo? I used https just because the default extensions repo is using it. And the reason I have a private repo is that I needed a MS Teams extension, to alert me about drift detection.

If it gets too complicated, I can try opening a PR on your extensions repo to add the MS Teams extension, but as I'm not a developer, idk if it would even work (I shamelessly copied inspire myself on the SlackApp one to create mine 🙃).

@alfespa17
Copy link
Member

Mounting the SSH key in executor won't work because JGIT is not using that keys to clone the repository.

You could fork the extension repository and inside your fork you could create a branch with the new feature for MS teams.

In the helm chart you could customize the parameter like this:

executor:
  properties:
    toolsRepository: "https://github.com/mygithubuser/my-extensions"
    toolsBranch: "my_feature_branch"

Now you can test your new extension in a different repository and when you have it ready you could send the pull request with some sample code and some images so we can update the documentation.

All help is welcome this is an open project 👍

@alfespa17 alfespa17 changed the title How to clone private extensions repository inside the executors? Support private repository extensions Jun 6, 2024
@igorbrites
Copy link
Author

I've created a draft on terrakube-extensions repo: AzBuilder/terrakube-extensions#36

I'll test it like you told me to, and then I open the PR for code reviews.

@ehuizar1028
Copy link

By the way I think you are the first person that want to use a private extension repository

I would be the 2nd person :)

I am running this on a private GitHub Enterprise, and would like to avoid having this publicly available within our org in order to pull, so an option to add a PAT would be helpful :)

Thanks!

@alfespa17 alfespa17 added this to the 2.23.0 milestone Aug 15, 2024
@alfespa17 alfespa17 self-assigned this Aug 21, 2024
@alfespa17 alfespa17 linked a pull request Aug 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants