Skip to content

Add FromExternal to BackupVaultIdentity #6068

@justinsb

Description

@justinsb

Please add the FromExternal method to BackupVaultIdentity in apis/netapp/v1alpha1/backupvault_identity.go.
This requires refactoring the struct to support gcpurls.

var BackupVaultIdentityFormat = gcpurls.Template[BackupVaultIdentity]("netapp.googleapis.com", "projects/{project}/locations/{location}/backupVaults/{backupVault}")

type BackupVaultIdentity struct {
	Project     string
	Location    string
	BackupVault string
}

func (i *BackupVaultIdentity) FromExternal(ref string) error {
	parsed, match, err := BackupVaultIdentityFormat.Parse(ref)
	if err != nil {
		return fmt.Errorf("format of BackupVault external=%q was not known (use %s): %w", ref, BackupVaultIdentityFormat.CanonicalFormat(), err)
	}
	if !match {
		return fmt.Errorf("format of BackupVault external=%q was not known (use %s)", ref, BackupVaultIdentityFormat.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