mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-05-05 12:32:34 +02:00
Alter existing "deprecated" function to return all migration notices (#159)
This commit is contained in:
parent
5960d7facb
commit
709b136563
7 changed files with 19 additions and 122 deletions
|
@ -13,7 +13,6 @@ Usage:
|
|||
corefile-tool deprecated --from <coredns-ver> --to <coredns-ver> --corefile <path>
|
||||
corefile-tool migrate --from <coredns-ver> --to <coredns-ver> --corefile <path> [--deprecations <true|false>]
|
||||
corefile-tool released --dockerImageId <id>
|
||||
corefile-tool removed --from <coredns-ver> --to <coredns-ver> --corefile <path>
|
||||
corefile-tool unsupported --from <coredns-ver> --to <coredns-ver> --corefile <path>
|
||||
corefile-tool validversions
|
||||
```
|
||||
|
@ -25,14 +24,12 @@ The following operations are supported:
|
|||
|
||||
- `default`: returns true if the Corefile is the default for the given version of Kubernetes. If `--k8sversion` is not specified, then this will return true if the Corefile is the default for any version of Kubernetes supported by the tool.
|
||||
|
||||
- `deprecated`: returns a list of plugins/options in the Corefile that have been deprecated.
|
||||
- `deprecated`: returns a list of plugins/options in the Corefile that have been deprecated, removed, ignored or is a new default plugin/option.
|
||||
|
||||
- `migrate`: updates your CoreDNS corefile to be compatible with the `-to` version. Setting the `--deprecations` flag to `true` will migrate plugins/options as soon as they are announced as deprecated. Setting the `--deprecations` flag to `false` will migrate plugins/options only once they are removed (or made a no-op). The default is `false`.
|
||||
|
||||
- `released`: determines if the `--dockerImageID` was an official CoreDNS release or not. Only official releases of CoreDNS are supported by the tool.
|
||||
|
||||
- `removed`: returns a list plugins/options in the Corefile that have been removed from CoreDNS.
|
||||
|
||||
- `unsupported`: returns a list of plugins/options in the Corefile that are not supported by the migration tool (but may still be valid in CoreDNS).
|
||||
|
||||
- `validversions`: Shows the list of CoreDNS versions supported by the this tool.
|
||||
|
@ -57,11 +54,6 @@ corefile-tool deprecated --from 1.4.0 --to 1.5.0 --corefile /path/to/Corefile
|
|||
corefile-tool unsupported --from 1.4.0 --to 1.5.0 --corefile /path/to/Corefile
|
||||
```
|
||||
|
||||
```bash
|
||||
# See removed plugins CoreDNS from v1.4.0 to v1.5.0.
|
||||
corefile-tool removed --from 1.4.0 --to 1.5.0 --corefile /path/to/Corefile
|
||||
```
|
||||
|
||||
```bash
|
||||
# Migrate CoreDNS from v1.4.0 to v1.5.0 and also migrate all the deprecations
|
||||
# that are present in the current Corefile.
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
func NewDeprecatedCmd() *cobra.Command {
|
||||
deprecatedCmd := &cobra.Command{
|
||||
Use: "deprecated",
|
||||
Short: "Deprecated returns a list of deprecated plugins or directives present in the Corefile.",
|
||||
Example: `# See deprecated plugins CoreDNS from v1.4.0 to v1.5.0.
|
||||
Short: "Deprecated returns a list of deprecated, removed, ignored and new default plugins or directives present in the Corefile.",
|
||||
Example: `# See deprecated, removed, ignored and new default plugins CoreDNS from v1.4.0 to v1.5.0.
|
||||
corefile-tool deprecated --from 1.4.0 --to 1.5.0 --corefile /path/to/Corefile`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
from, _ := cmd.Flags().GetString("from")
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/coredns/deployment/kubernetes/migration"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// NewRemovedCmd represents the removed command
|
||||
func NewRemovedCmd() *cobra.Command {
|
||||
removedCmd := &cobra.Command{
|
||||
Use: "removed",
|
||||
Short: "Removed returns a list of removed plugins or directives present in the Corefile.",
|
||||
Example: `# See removed plugins CoreDNS from v1.4.0 to v1.5.0.
|
||||
corefile-tool removed --from 1.4.0 --to 1.5.0 --corefile /path/to/Corefile`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
from, _ := cmd.Flags().GetString("from")
|
||||
to, _ := cmd.Flags().GetString("to")
|
||||
corefile, _ := cmd.Flags().GetString("corefile")
|
||||
removed, err := removedCorefileFromPath(from, to, corefile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while listing deprecated plugins: %v \n", err)
|
||||
}
|
||||
for _, rem := range removed {
|
||||
fmt.Println(rem.ToString())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
}
|
||||
removedCmd.Flags().String("from", "", "Required: The version you are migrating from. ")
|
||||
removedCmd.MarkFlagRequired("from")
|
||||
removedCmd.Flags().String("to", "", "Required: The version you are migrating to.")
|
||||
removedCmd.MarkFlagRequired("to")
|
||||
removedCmd.Flags().String("corefile", "", "Required: The path where your Corefile is located.")
|
||||
removedCmd.MarkFlagRequired("corefile")
|
||||
|
||||
return removedCmd
|
||||
}
|
||||
|
||||
// removedCorefileFromPath takes the path where the Corefile is located and returns the plugins or directives
|
||||
// that have been removed.
|
||||
func removedCorefileFromPath(fromCoreDNSVersion, toCoreDNSVersion, corefilePath string) ([]migration.Notice, error) {
|
||||
fileBytes, err := getCorefileFromPath(corefilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
corefileStr := string(fileBytes)
|
||||
return migration.Removed(fromCoreDNSVersion, toCoreDNSVersion, corefileStr)
|
||||
}
|
|
@ -26,7 +26,6 @@ func CorefileTool() *cobra.Command {
|
|||
|
||||
`),
|
||||
}
|
||||
rootCmd.AddCommand(NewRemovedCmd())
|
||||
rootCmd.AddCommand(NewMigrateCmd())
|
||||
rootCmd.AddCommand(NewDefaultCmd())
|
||||
rootCmd.AddCommand(NewDeprecatedCmd())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue