https://prefect.io logo
#prefect-community
Title
# prefect-community
j

Jonathan Mathews

05/06/2022, 8:43 AM
Hi, I’ve switched to the git storage class from gitlab and I’m getting an error when using the attached setup. The error is: {‘repo’: [‘Field may not be null.’]} According to the docs, repo is optional when git_clone_url_secret_name is set
Looking in the source code, I can’t see that error in there, so not 100% sure where it might be coming from
a

Anna Geller

05/06/2022, 10:12 AM
Nice work finding the relevant issue. Git class is tricky because it's so generic, it may be more difficult to configure. What's your use case? are you actually using GitLab but want to configure it via Git storage class? Also, did you try still providing the repo explicitly (I know it says optional)?
j

Jonathan Mathews

05/06/2022, 11:13 AM
Thanks Anna. Yeah, I’m actually using gitlab, but the problem is it only works with personal access token and that gives read/write access to all my repos. I asked about it here: https://prefect-community.slack.com/archives/CL09KU1K7/p1651135178620219 I will try providing the repo explicitly - don’t know why I didn’t try that. Also, I didn’t try project-level access tokens (rather than deploy keys) in gitlab. That would be the backup plan
a

Anna Geller

05/06/2022, 11:30 AM
That's true, PAT is usually also the approach recommended by GitHub and GitLab and afaik you could restrict the permissions of those, am I wrong? Regarding Gitlab, you're right that setting project-level access tokens is the right approach - setting permissions can be tricky though, this thread shows how you can set the right permission scopes and how you can test whether the token is working
j

Jonathan Mathews

05/06/2022, 12:19 PM
Great, thanks. Well it turns out that just adding “flow” works, so now I can use the deploy key! Thanks again for your help!
a

Anna Geller

05/06/2022, 12:27 PM
Nice, glad it worked! If you want to share your code for posterity, feel free to post your working version directly here.
j

Jonathan Mathews

05/06/2022, 1:18 PM
Great! Sure:
Copy code
def set_storage(flow_name: str) -> Git:
    return Git(
        repo="{repo_name}",
        branch_name="main",
        flow_path=f"prefect/flows/{flow_name}.py",
        git_clone_url_secret_name="GIT_CLONE_URL"
    )
🙏 1
💯 1
17 Views