func mergeFCC14(ign ignition33Types.Config, snippets []string, pretty, strict bool) (ignition33Types.Config, error) {
	for _, snippet := range snippets {
		ignextBytes, _, err := butane.TranslateBytes([]byte(snippet), common.TranslateBytesOptions{
			Pretty: pretty,
			Strict: strict,
		})
		if err != nil {
			if err == common.ErrNoVariant {
				return ign, fmt.Errorf("Fedora CoreOS snippets require `variant`: %v", err)
			}
			return ign, fmt.Errorf("snippet v1.4.0 translate error: %v", err)
		}
		ignext, _, err := ignition33.Parse(ignextBytes)
		if err != nil {
			return ign, fmt.Errorf("snippet parse error: %v, expect v1.4.0", err)
		}
		ign = ignition33.Merge(ign, ignext)
	}
	return ign, nil
}
merge FCC v1.4.0 snippets
package ct
import (
	"context"
	"encoding/json"
	"fmt"
	"strconv"
	"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
	"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
	butane "github.com/coreos/butane/config"
	"github.com/coreos/butane/config/common"
	clct "github.com/coreos/container-linux-config-transpiler/config"
	ignition "github.com/coreos/ignition/config/v2_3"
	ignitionTypes "github.com/coreos/ignition/config/v2_3/types"
	ignition30 "github.com/coreos/ignition/v2/config/v3_0"
	ignition30Types "github.com/coreos/ignition/v2/config/v3_0/types"
	ignition31 "github.com/coreos/ignition/v2/config/v3_1"
	ignition31Types "github.com/coreos/ignition/v2/config/v3_1/types"
	ignition32 "github.com/coreos/ignition/v2/config/v3_2"
	ignition32Types "github.com/coreos/ignition/v2/config/v3_2/types"
	ignition33 "github.com/coreos/ignition/v2/config/v3_3"
	ignition33Types "github.com/coreos/ignition/v2/config/v3_3/types"
)
func dataSourceCTConfig() *schema.Resource {
	return &schema.Resource{
		ReadContext: dataSourceCTConfigRead,
		Schema: map[string]*schema.Schema{
			"content": &schema.Schema{
				Type:     schema.TypeString,
				Required: true,
			},
			"platform": &schema.Schema{
				Type:     schema.TypeString,
				Optional: true,
				Default:  "",
				ForceNew: true,
			},
			"snippets": &schema.Schema{
				Type: schema.TypeList,
				Elem: &schema.Schema{
					Type: schema.TypeString,
				},
				Optional: true,
				ForceNew: true,
			},
			"pretty_print": &schema.Schema{
				Type:     schema.TypeBool,
				Optional: true,
				Default:  false,
			},
			"strict": &schema.Schema{
				Type:     schema.TypeBool,
				Optional: true,
				Default:  false,
			},
			"rendered": &schema.Schema{
				Type:        schema.TypeString,
				Computed:    true,
				Description: "rendered ignition configuration",
			},
		},
	}
}
func dataSourceCTConfigRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
	var diags diag.Diagnostics
	rendered, err := renderConfig(d)
	if err != nil {
		return diag.FromErr(err)
	}
	d.Set("rendered", rendered)
	d.SetId(strconv.Itoa(hashcode.String(rendered)))
	return diags
}
func renderConfig(d *schema.ResourceData) (string, error) {
	content := d.Get("content").(string)
	platform := d.Get("platform").(string)
	pretty := d.Get("pretty_print").(bool)
	strict := d.Get("strict").(bool)
	snippetsIface := d.Get("snippets").([]interface{})
	snippets := make([]string, len(snippetsIface))
	for i, v := range snippetsIface {
		if v != nil {
			snippets[i] = v.(string)
		}
	}
	ign, err := fccToIgnition([]byte(content), pretty, strict, snippets)
	if err == common.ErrNoVariant {
		ign, err = renderCLC([]byte(content), platform, pretty, strict, snippets)
	}
	return string(ign), err
}
func fccToIgnition(data []byte, pretty, strict bool, snippets []string) ([]byte, error) {
	ignBytes, _, err := butane.TranslateBytes(data, common.TranslateBytesOptions{
		Pretty: pretty,
		Strict: strict,
	})
	if err != nil {
		return nil, err
	}
	if len(snippets) == 0 {
		return ignBytes, nil
	}
	return mergeFCCSnippets(ignBytes, pretty, strict, snippets)
}
func mergeFCCSnippets(ignBytes []byte, pretty, strict bool, snippets []string) ([]byte, error) {
	ign33, _, err := ignition33.Parse(ignBytes)
	if err == nil {
		ign33, err = mergeFCC14(ign33, snippets, pretty, strict)
		if err != nil {
			return nil, fmt.Errorf("FCC v1.4.0 merge error: %v", err)
		}
		return marshalJSON(ign33, pretty)
	}
	ign32, _, err := ignition32.Parse(ignBytes)
	if err == nil {
		ign32, err = mergeFCC12(ign32, snippets, pretty, strict)
		if err != nil {
			return nil, fmt.Errorf("FCC v1.2.0 merge error: %v", err)
		}
		return marshalJSON(ign32, pretty)
	}
	ign31, _, err := ignition31.Parse(ignBytes)
	if err == nil {
		ign31, err = mergeFCC11(ign31, snippets, pretty, strict)
		if err != nil {
			return nil, fmt.Errorf("FCC v1.1.0 merge error: %v", err)
		}
		return marshalJSON(ign31, pretty)
	}
	var ign30 ignition30Types.Config
	ign30, _, err = ignition30.Parse(ignBytes)
	if err != nil {
		return nil, fmt.Errorf("FCC v1.0.0 parse error: %v", err)
	}
	ign30, err = mergeFCCV10(ign30, snippets, pretty, strict)
	if err != nil {
		return nil, fmt.Errorf("FCC v1.0.0 merge error: %v", err)
	}
	return marshalJSON(ign30, pretty)
}