forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 2
/
import.go
54 lines (42 loc) · 1.25 KB
/
import.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package app
import (
"fmt"
"os"
"github.com/StackVista/stackstate-agent/cmd/agent/common"
"github.com/fatih/color"
"github.com/spf13/cobra"
)
var (
importCmd = &cobra.Command{
Use: "import <old_configuration_dir> <destination_dir>",
Short: "Import and convert configuration files from previous versions of the Agent",
Long: ``,
RunE: doImport,
SilenceUsage: true,
}
force = false
)
func init() {
// attach the command to the root
AgentCmd.AddCommand(importCmd)
// local flags
importCmd.Flags().BoolVarP(&force, "force", "f", force, "overwrite existing files")
}
func doImport(cmd *cobra.Command, args []string) error {
if len(args) != 2 {
return fmt.Errorf("please provide all the required arguments")
}
if confFilePath != "" {
fmt.Fprintf(os.Stderr, "Please note configdir option has no effect\n")
}
oldConfigDir := args[0]
newConfigDir := args[1]
if flagNoColor {
color.NoColor = true
}
return common.ImportConfig(oldConfigDir, newConfigDir, force)
}