コード例 #1
0
ファイル: main.go プロジェクト: cloudnautique/external-dns
func setEnv() {
	flag.Parse()
	provider = providers.GetProvider(*providerName)
	if *debug {
		logrus.SetLevel(logrus.DebugLevel)
	}
	if *logFile != "" {
		if output, err := os.OpenFile(*logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err != nil {
			logrus.Fatalf("Failed to log to file %s: %v", *logFile, err)
		} else {
			logrus.SetOutput(output)
			formatter := &logrus.TextFormatter{
				FullTimestamp: true,
			}
			logrus.SetFormatter(formatter)
		}
	}

	// configure metadata client
	m = metadata.NewClient(metadataUrl)
	selfStack, err := m.GetSelfStack()
	if err != nil {
		logrus.Fatalf("Error reading stack info: %v", err)
	}
	EnvironmentName = selfStack.EnvironmentName

	cattleUrl := os.Getenv("CATTLE_URL")
	if len(cattleUrl) == 0 {
		logrus.Fatal("CATTLE_URL is not set")
	}

	cattleApiKey := os.Getenv("CATTLE_ACCESS_KEY")
	if len(cattleApiKey) == 0 {
		logrus.Fatal("CATTLE_ACCESS_KEY is not set")
	}

	cattleSecretKey := os.Getenv("CATTLE_SECRET_KEY")
	if len(cattleSecretKey) == 0 {
		logrus.Fatal("CATTLE_SECRET_KEY is not set")
	}

	//configure cattle client
	c, err = NewCattleClient(cattleUrl, cattleApiKey, cattleSecretKey)
	if err != nil {
		logrus.Fatalf("Failed to configure cattle client: %v", err)
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: prachidamle/external-dns
func setEnv() {
	flag.Parse()
	provider = providers.GetProvider(*providerName)
	if *debug {
		log.SetLevel(log.DebugLevel)
	}
	if *logFile != "" {
		if output, err := os.OpenFile(*logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err != nil {
			log.Fatalf("Failed to log to file %s: %v", *logFile, err)
		} else {
			log.SetOutput(output)
			formatter := &log.TextFormatter{
				FullTimestamp: true,
			}
			log.SetFormatter(formatter)
		}
	}
	m = metadata.NewHandler(metadataUrl)
	selfStack, err := m.GetSelfStack()
	if err != nil {
		log.Errorf("Error reading stack info: %v", err)
	}
	stack = selfStack
}