Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for virtual file system storages #347

Merged
merged 8 commits into from
Dec 17, 2024

Conversation

optik-aper
Copy link
Member

@optik-aper optik-aper commented Dec 11, 2024

Description

This adds support for managing VFS storages.

Checklist:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you linted your code locally prior to submission?
  • Have you successfully ran tests with your changes locally?

Testing instructions

You can emulate these test funcs to check each route available through the govultr library:

func vfsList(ctx context.Context, client *govultr.Client) {
	vfss, _, _, err := client.VirtualFileSystemStorage.List(ctx, nil)
	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", vfss)
}

func vfsGet(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	vfs, _, err := client.VirtualFileSystemStorage.Get(ctx, id)
	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", vfs)
}

func vfsCreate(ctx context.Context, client *govultr.Client) {
	vfs, _, err := client.VirtualFileSystemStorage.Create(ctx, &govultr.VirtualFileSystemStorageReq{
		Region: "ewr",
		Label:  "govultr-test",
		StorageSize: govultr.VirtualFileSystemStorageSize{
			SizeGB: 10,
		},
		DiskType: "nvme",
		Tags: []string{
			"test-vfs",
			"delete-after-testing",
		},
	})

	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", vfs)
}

func vfsUpdate(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	vfs, _, err := client.VirtualFileSystemStorage.Update(ctx, id, &govultr.VirtualFileSystemStorageUpdateReq{
		Label: "govultr-test-upd",
		StorageSize: govultr.VirtualFileSystemStorageSize{
			SizeGB: 20,
		},
	})

	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", vfs)
}

func vfsDelete(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	if err := client.VirtualFileSystemStorage.Delete(ctx, id); err != nil {
		fmt.Println(err)
		panic(err.Error())
	}
}

func vfsAttach(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	targetID := "4f05ab05-a560-4bce-8158-7088aaf5de78"
	att, _, err := client.VirtualFileSystemStorage.Attach(ctx, id, targetID)
	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", att)
}

func vfsAttachmentList(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	atts, _, err := client.VirtualFileSystemStorage.AttachmentList(ctx, id)
	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", atts)
}

func vfsAttachmentGet(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	targetID := "4f05ab05-a560-4bce-8158-7088aaf5de78"
	att, _, err := client.VirtualFileSystemStorage.AttachmentGet(ctx, id, targetID)
	if err != nil {
		fmt.Println(err)
		panic(err.Error())
	}

	fmt.Printf("%+v", att)
}

func vfsDetach(ctx context.Context, client *govultr.Client) {
	id := "0ae69c69-0c46-4ab3-8601-c86a39b1026e"
	targetID := "4f05ab05-a560-4bce-8158-7088aaf5de78"
	if err := client.VirtualFileSystemStorage.Detach(ctx, id, targetID); err != nil {
		fmt.Println(err)
		panic(err.Error())
	}
}

@optik-aper optik-aper added the enhancement New feature or request label Dec 11, 2024
@optik-aper optik-aper self-assigned this Dec 11, 2024
@optik-aper optik-aper changed the title DRAFT: Add support for the virtual file system storage option Add support for virtual file system storages Dec 17, 2024
Copy link
Contributor

@christhemorse christhemorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@optik-aper optik-aper merged commit 73933bd into vultr:master Dec 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants