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

Allow cChocoSource to update an existing Source #156

Closed
bozho opened this issue May 4, 2021 · 3 comments · Fixed by #157
Closed

Allow cChocoSource to update an existing Source #156

bozho opened this issue May 4, 2021 · 3 comments · Fixed by #157

Comments

@bozho
Copy link
Contributor

bozho commented May 4, 2021

Is your feature request related to a problem? Please describe.
cChocoSource does not update source URL on an existing source.

Describe the solution you'd like
cChocoSource to update source URL if a source with the specified Name already exists.

Describe alternatives you've considered
Manually deleting Chocolatey source on managed servers when URL changes.

Additional context
I've submitted a patch.

@pauby
Copy link
Member

pauby commented Jul 13, 2021

Appreciate it's been some time since you submitted this but that is not the correct Chocolatey behaviour. Without additional information we can't look into this. Can you go back and complete the bug issue template?

@laoist
Copy link

laoist commented Sep 1, 2021

This might be related, if it's not let me know.

I have my Chocolatey packages sitting in Azure DevOps Artefacts repostiory, hosts need to authenticate using a token which has an expiry date. I'm unable to simply update the credentials in order for the source to be updated, I instead have to remove the source and add it again, which brings further complicates due to the source name being a unique value.

In each of the below scenarios, the source credential is updated ($ChocolateySourceCredential).

Example of what I currently have to do:
This is pretty messy.

    cChocoSource RemoveMyRepo_Old
    {
        Name = 'MyRepo-20210901-0'
        Ensure = 'Absent'
        DependsOn = '[cChocoInstaller]ChocoInstaller'
    }
    cChocoSource AddMyRepo
    {
        Name = 'MyRepo-20210901-1'
        Ensure = 'Present'
        Priority = 0
        Source = 'https://mytenant.pkgs.visualstudio.com/MyCodeRepo/_packaging/MyRepo/nuget/v2/'
        Credentials = $ChocolateySourceCredential
        DependsOn = '[cChocoSource]RemoveMyRepo_Old'
    }

Example of what I'm okay with, but not ideal:
I think this would be okay but as mentioned, it doesn't work due to repo name being a unique key.

    cChocoSource RemoveMyRepo
    {
        Name = 'MyRepo'
        Ensure = 'Absent'
        DependsOn = '[cChocoInstaller]ChocoInstaller'
    }
    cChocoSource AddMyRepo
    {
        Name = 'MyRepo
        Ensure = 'Present'
        Priority = 0
        Source = 'https://mytenant.pkgs.visualstudio.com/MyCodeRepo/_packaging/MyRepo/nuget/v2/'
        Credentials = $ChocolateySourceCredential
        DependsOn = '[cChocoSource]RemoveMyRepo'
    }

Example I'd like to see:
Unsure if this is possible really, as the only thing that would change is the source credential, so it would need to test if the current credential on the host is different to the new one.

    cChocoSource AddMyRepo
    {
        Name = 'MyRepo
        Ensure = 'Present'
        Priority = 0
        Source = 'https://mytenant.pkgs.visualstudio.com/MyCodeRepo/_packaging/MyRepo/nuget/v2/'
        Credentials = $ChocolateySourceCredential
        DependsOn = '[cChocoSource]ChocoInstaller'
    }

@bozho
Copy link
Contributor Author

bozho commented Sep 13, 2021

@pauby Sorry for a late update.

@laoist gave a nice example of the problem.

Chocolatey does not support altering the URL. My patch removes and re-creates the source on URL changes.

@pauby pauby added this to the 2.6.0 milestone May 16, 2022
pauby added a commit that referenced this issue May 16, 2022
(GH-156) cChocoSource can now update source URL
@vexx32 vexx32 changed the title cChocoSource does not update Source Allow cChocoSource to update an existing Source Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants