mirror of
https://github.com/hashicorp/terraform.git
synced 2026-03-21 18:10:30 -04:00
36 lines
873 B
Go
36 lines
873 B
Go
// Copyright IBM Corp. 2014, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package statekeys
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/internal/stacks/stackaddrs"
|
|
)
|
|
|
|
type ComponentInstance struct {
|
|
ComponentInstanceAddr stackaddrs.AbsComponentInstance
|
|
}
|
|
|
|
func parseComponentInstance(s string) (Key, error) {
|
|
addrRaw, ok := finalKeyField(s)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unsupported extra field in component instance key")
|
|
}
|
|
addr, diags := stackaddrs.ParseAbsComponentInstanceStr(addrRaw)
|
|
if diags.HasErrors() {
|
|
return nil, fmt.Errorf("component instance key has invalid component instance address %q", addrRaw)
|
|
}
|
|
return ComponentInstance{
|
|
ComponentInstanceAddr: addr,
|
|
}, nil
|
|
}
|
|
|
|
func (k ComponentInstance) KeyType() KeyType {
|
|
return ComponentInstanceType
|
|
}
|
|
|
|
func (k ComponentInstance) rawSuffix() string {
|
|
return k.ComponentInstanceAddr.String()
|
|
}
|