Skip to content

Add FromExternal to InstanceIdentity (Memorystore) #6070

@justinsb

Description

@justinsb

Please add the FromExternal method to InstanceIdentity in apis/memorystore/v1alpha1/instance_identity.go.
This requires refactoring the struct to support gcpurls.

var InstanceIdentityFormat = gcpurls.Template[InstanceIdentity]("memorystore.googleapis.com", "projects/{project}/locations/{location}/instances/{instance}")

type InstanceIdentity struct {
	Project  string
	Location string
	Instance string
}

func (i *InstanceIdentity) FromExternal(ref string) error {
	parsed, match, err := InstanceIdentityFormat.Parse(ref)
	if err != nil {
		return fmt.Errorf("format of Instance external=%q was not known (use %s): %w", ref, InstanceIdentityFormat.CanonicalFormat(), err)
	}
	if !match {
		return fmt.Errorf("format of Instance external=%q was not known (use %s)", ref, InstanceIdentityFormat.CanonicalFormat())
	}

	*i = *parsed
	return nil
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions