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

Display helpful error when encountering old Kptfile format #2161

Merged
merged 3 commits into from
Jun 10, 2021

Conversation

mortent
Copy link
Contributor

@mortent mortent commented Jun 4, 2021

Adds verification that the Kptfile is using the v1alpha2 format. If a file with the legacy v1alpha1 version is found, an error message is shown to the user.

If the legacy version if found in a file that is already in the local fork, we display an error that includes the path to the package on the local filesystem. If a Kptfile with the legacy version is found when fetching/updating a package from an upstream repo, we display an error message that includes the git reference (instead of the path to some temporary directory).

To make sure we only have to do this check in one place, this PR removes the ReadFile function from the kptfileutil package and updates all code to read Kptfiles using the function in the pkg package. It also makes sure we pass around the Kptfile struct as a pointer rather than a value. Both are valid, but this makes sure we are consistent.

Error message when running kpt fn render on an old package:

$ kpt fn render helloworld-set 
Error: Kptfile at "/Users/mortent/Development/mortent/temp/kpttest/helloworld-set" has an old version ("v1alpha1") of the Kptfile schema. Please update the package to the latest format. See https://kpt.dev/installation/migration for more details

Error message when using kpt pkg get to fetch an old package:

$ kpt pkg get https://github.com/GoogleContainerTools/kpt.git/package-examples/helloworld-set

Package "helloworld-set":
Fetching https://github.com/GoogleContainerTools/kpt@master.
From https://github.com/GoogleContainerTools/kpt
 * branch              master     -> FETCH_HEAD
Error: Kptfile at "https:/github.com/GoogleContainerTools/kpt/package-examples/helloworld-set@master" has an old version ("v1alpha1") of the Kptfile schema. Please update the package to the latest format. See https://kpt.dev/installation/migration for more details. 

Error message when running kpt fn render on a package where the Kptfile has an unknown GVK:

Error: Kptfile at "/Users/mortent/Development/mortent/temp/kpttest/helloworld-set" has an unknown resource type ("kpt.com/v1beta1, Kind=Kptfile").

@frankfarzan
Copy link
Contributor

frankfarzan commented Jun 4, 2021

Just commenting on the PR description for now:

Adds verification that the Kptfile is using the v1alpha2 format. If a file with the legacy v1alpha1 version is found, an error message is shown to the user.

To be future proof, how do you want to handle v1alpha2 and v1? The major change will be ignore stuff, but there may others. We don't need to decide now, but assume there may be v1alpha2 packages in the wild when we release v1.

If the legacy version if found in a file that is already in the local fork, we display an error that includes the path to the package on the local filesystem. If a Kptfile with the legacy version is found when fetching/updating a package from an upstream repo, we display an error message that includes the git reference (instead of the path to some temporary directory).

To make sure we only have to do this check in one place, this PR removes the ReadFile function from the kptfileutil package and updates all code to read Kptfiles using the function in the pkg package. It also makes sure we pass around the Kptfile struct as a pointer rather than a value. Both are valid, but this makes sure we are consistent.

Error message when running kpt fn render on an old package:

$ kpt fn render helloworld-set 
Error: Kptfile at "/Users/mortent/Development/mortent/temp/kpttest/helloworld-set" is using and old version of the Kptfile format used by pre-1.0 versions of kpt. Please update the package to use the new format. See https://kpt.dev for more details on how to do the migration.

Error message when using `kpt pkg get` to fetch an old package:

$ kpt pkg get https://github.com/GoogleContainerTools/kpt.git/package-examples/helloworld-set

Package "helloworld-set":
Fetching https://github.com/GoogleContainerTools/kpt@master.
From https://github.com/GoogleContainerTools/kpt

  • branch master -> FETCH_HEAD
    Error: Kptfile at "https:/github.com/GoogleContainerTools/kpt/package-examples/helloworld-set@master" is using and old version of the Kptfile format used by pre-1.0 versions of kpt. Please update the package to use the new format. See https://kpt.dev for more details on how to do the migration.

@mortent mortent force-pushed the ProperErrOnOldKptfileFormat branch 2 times, most recently from 98fa9e8 to 6d410c6 Compare June 7, 2021 23:56
@mortent
Copy link
Contributor Author

mortent commented Jun 8, 2021

To be future proof, how do you want to handle v1alpha2 and v1? The major change will be ignore stuff, but there may others. We don't need to decide now, but assume there may be v1alpha2 packages in the wild when we release v1.

Updated the PR to handle this better. We now have a list of deprecated versions that will result in an error message asking users to upgrade the package. It also introduces a custom error message used whenever the GVK in the Kptfile doesn't match what we expect or is one of the known old formats.

Fixed

@mortent mortent force-pushed the ProperErrOnOldKptfileFormat branch from 35affdd to 3b04ccf Compare June 10, 2021 00:55
@mortent mortent merged commit ed3c785 into kptdev:next Jun 10, 2021
@mortent mortent deleted the ProperErrOnOldKptfileFormat branch June 11, 2021 20:38
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.

2 participants