github.com/hashicorp/packer@v1.14.3/hcl2template/types.build.from.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package hcl2template
     5  
     6  import (
     7  	"strings"
     8  )
     9  
    10  func sourceRefFromString(in string) SourceRef {
    11  	args := strings.Split(in, ".")
    12  	if len(args) < 2 {
    13  		return NoSource
    14  	}
    15  	if len(args) > 2 {
    16  		// source.type.name
    17  		args = args[1:]
    18  	}
    19  	return SourceRef{
    20  		Type: args[0],
    21  		Name: args[1],
    22  	}
    23  }