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

Add AppDefaults #17

Merged
merged 1 commit into from Apr 5, 2022
Merged

Conversation

jiaqiluo
Copy link
Member

@jiaqiluo jiaqiluo commented Apr 1, 2022

Issue: rancher/rancher#36827

Problem:

We use channelserver to host rke2/k3s version information in rancher/rancher, and we need the ability to set different default versions for different rancher versions.
This ability should be general enough to support any app and not tied to Rancher.

Solution:

This PR adds the support for setting app defaults in the config file.
An example of the value looks like this

appDefaults:
    - appName: rancher
      defaults:
        - appVersion: '> 2.6.2-0 < 2.6.3-0'
          defaultVersion: '1.20.x'
        - appVersion: '> 2.6.2-0 < 2.6.4-0'
          defaultVersion: '1.21.x'
        - appVersion: '> 2.6.4-0'
          defaultVersion: '1.22.x'
    - appName: anotherApp
      defaults:
        - appVersion: '1.2.x'
          defaultVersion: '1.19.5'

Problem:

In the case where the 404 NotFound is returned from the HTTP GET request, channelserver cannot parse the response's data and is stuck in returning errors.

Solution:

This PR adds checks for the response's status code and continues to parse the data only if it is 200.

Problem:

The default value for the flag path-prefix is not applied.

Solution:

It is a bug in the urfave/cli module: urfave/cli#1121
This PR bumps github.com/urfave/cli/v2 to v2.4.0 to get the fix

Others Improvements:

  • update error messages to be clear
  • update the readme and default config file

@jiaqiluo jiaqiluo changed the title Add AddDefaults Add AppDefaults Apr 1, 2022
@snasovich snasovich requested review from thedadams, kinarashah, Oats87 and a team April 1, 2022 20:42
Copy link
Contributor

@thedadams thedadams left a comment

Choose a reason for hiding this comment

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

A few minor things.

pkg/config/get.go Outdated Show resolved Hide resolved
pkg/config/get.go Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@jiaqiluo
Copy link
Member Author

jiaqiluo commented Apr 4, 2022

@thedadams Please check the latest commit that addresses your comments.

pkg/config/get.go Outdated Show resolved Hide resolved
pkg/config/get.go Outdated Show resolved Hide resolved
pkg/config/get.go Outdated Show resolved Hide resolved
@jiaqiluo
Copy link
Member Author

jiaqiluo commented Apr 5, 2022

@thedadams Please check the latest commit: 41efe6c

pkg/config/get.go Outdated Show resolved Hide resolved
…ion range to a release range and can be used to set the default release version(s) per app version(s).

This PR improves the handling of HTTP errors, especially the 404 not found, from the source URL.
This PR also bumps github.com/urfave/cli/v2 to v2.4.0 to fix the issue where the default value is not set for string slice flags.
@thedadams thedadams merged commit 28c9b37 into rancher:master Apr 5, 2022
@jiaqiluo jiaqiluo deleted the enhance-default-version branch April 5, 2022 17:09
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.

None yet

3 participants