From 6df39af0d1371f0961e67356f483f210da3ed5c7 Mon Sep 17 00:00:00 2001 From: Yauhen Shulitski Date: Sun, 22 Oct 2023 21:55:54 +0200 Subject: [PATCH] :m: Add only flag to sync one domain --- cmd/cmd_dns.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/cmd_dns.go b/cmd/cmd_dns.go index 16ec632..0f933a7 100644 --- a/cmd/cmd_dns.go +++ b/cmd/cmd_dns.go @@ -144,6 +144,14 @@ var dnsSyncCmd = &cobra.Command{ return err } + only, err := cmd.Flags().GetString("only") + if err != nil { + return err + } + if only != "" { + logger.Printf("syncing only %s domain", only) + } + config, err := getConfig(configFile) if err != nil { return err @@ -160,6 +168,9 @@ var dnsSyncCmd = &cobra.Command{ } for domainName := range config.DNS { + if only != "" && only != domainName { + continue + } var domainID int for _, domain := range domains { @@ -219,4 +230,5 @@ func init() { dnsSyncCmd.PersistentFlags().StringP("config", "c", "", "configuration file, filepath") dnsSyncCmd.PersistentFlags().Bool("doit", false, "apply planned changes") dnsSyncCmd.PersistentFlags().Bool("remove", false, "remove resources which are not present in configuration file") + dnsSyncCmd.PersistentFlags().String("only", "", "execute sync command only for specified domain name") }