func CreateRelayBootstrapYamlFile()

in agent/envoy_bootstrap/envoy_bootstrap.go [1677:1702]


func CreateRelayBootstrapYamlFile(agentConfig config.AgentConfig) error {
	statInfo, _ := os.Lstat(agentConfig.EnvoyConfigPath)
	if statInfo == nil {
		return fmt.Errorf("Cannot get stat info of relay bootstrap config file %s", agentConfig.EnvoyConfigPath)
	}

	fileUtilInst := &fileUtil{}
	envoyCLIInst := &envoyCLI{agentConfig.CommandPath}
	envoyConfigYaml, err := GetRelayBootstrapYaml(agentConfig, fileUtilInst, envoyCLIInst)
	if err != nil {
		return err
	}

	// If there's already a non-empty file present at this location, we'll delete and recreate it.
	if err := os.Remove(agentConfig.EnvoyConfigPath); err != nil && !os.IsNotExist(err) {
		log.Warnf("Failed to remove existing Envoy config file at: [%s]. Overwriting with relay config. %v.", agentConfig.AgentAdminUdsPath, err)
	}
	er := os.WriteFile(agentConfig.EnvoyConfigPath, envoyConfigYaml, 0644)
	if er != nil {
		return fmt.Errorf("Cannot write relay bootstrap config to file. %v", er)
	}
	return nil

	e := validateEnvoyConfigPath(agentConfig.EnvoyConfigPath)
	return e
}