Skip to content

Commit

Permalink
update go sdk and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Sep 4, 2024
1 parent 7d2016b commit dd46e44
Show file tree
Hide file tree
Showing 32 changed files with 118 additions and 50 deletions.
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ linters:
- gofmt
- govet
- ineffassign
- megacheck
- gosimple
- staticcheck
- unused
- misspell
- unconvert
enable-all: false
run:
timeout: 20m
skip-dirs:
issues:
exclude-dirs:
- integrationtests
2 changes: 1 addition & 1 deletion docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Read-Only:

Required:

- `disk_name` (String) Name of QSFS or Disk to mount.
- `name` (String) Name of QSFS or Disk to mount.
- `mount_point` (String) Directory to mount the disk on inside the ZMachine.


Expand Down
6 changes: 3 additions & 3 deletions examples/resources/deployment_resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ resource "grid_deployment" "d2" {
memory = 1024
entrypoint = "/sbin/zinit init"
mounts {
disk_name = "mydisk1"
name = "mydisk1"
mount_point = "/opt"
}
mounts {
disk_name = "mydisk2"
name = "mydisk2"
mount_point = "/test"
}
env_vars = {
Expand All @@ -120,7 +120,7 @@ resource "grid_deployment" "d2" {
memory = 1024
entrypoint = "/sbin/zinit init"
mounts {
disk_name = "mydisk2"
name = "mydisk2"
mount_point = "/test"
}
env_vars = {
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/gpu/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "grid_deployment" "d1" {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
mounts {
disk_name = "data"
name = "data"
mount_point = "/app"
}
planetary = true
Expand Down
10 changes: 5 additions & 5 deletions examples/resources/mounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ locals {

resource "grid_scheduler" "sched" {
requests {
name = "node1"
cru = 1
sru = 1024*10
mru = 1024
name = "node1"
cru = 1
sru = 1024 * 10
mru = 1024
}
}

Expand Down Expand Up @@ -47,7 +47,7 @@ resource "grid_deployment" "d1" {
memory = 1024
entrypoint = "/sbin/zinit init"
mounts {
disk_name = "data"
name = "data"
mount_point = "/app"
}
env_vars = {
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/nixos-micro/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "grid_deployment" "d1" {
memory = 2048
entrypoint = "/entrypoint.sh"
mounts {
disk_name = "store"
name = "store"
mount_point = "/nix"
}

Expand Down
2 changes: 1 addition & 1 deletion examples/resources/presearch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ resource "grid_deployment" "d1" {
memory = 1024

mounts {
disk_name = "data"
name = "data"
mount_point = "/var/lib/docker"
}

Expand Down
2 changes: 1 addition & 1 deletion examples/resources/qsfs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ resource "grid_deployment" "qsfs" {
SSH_KEY = file("~/.ssh/id_rsa.pub")
}
mounts {
disk_name = "qsfs"
name = "qsfs"
mount_point = "/qsfs"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/taiga/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ resource "grid_deployment" "node1" {
memory = 8096
rootfs_size = 51200
mounts {
disk_name = "data0"
name = "data0"
mount_point = "/var/lib/docker"
}
env_vars = {
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.11
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.11
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.11
github.com/threefoldtech/zos v0.5.6-0.20240611092312-66184cdeb953
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17-0.20240904122047-8dbb80d1d261
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.16
github.com/threefoldtech/zos v0.5.6-0.20240902110349-172a0a29a6ee
golang.org/x/crypto v0.26.0
golang.org/x/sync v0.8.0
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210803171230-4253848d036c
Expand Down Expand Up @@ -64,8 +64,8 @@ require (
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/gorilla/schema v1.3.0 // indirect
github.com/gorilla/websocket v1.5.2 // indirect
github.com/gorilla/schema v1.4.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
Expand Down Expand Up @@ -118,7 +118,7 @@ require (
github.com/rs/zerolog v1.33.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240416134707-eb36aa90df2d // indirect
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240827163226-d4e15e206974 // indirect
github.com/tmccombs/hcl2json v0.3.3 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vedhavyas/go-subkey v1.0.3 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMd
github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56etFpas=
github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU=
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA=
github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw=
github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30=
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/gruntwork-io/terratest v0.47.0 h1:xIy1pT7NbGVlMLDZEHl3+3iSnvffh8tN2pL6idn448c=
github.com/gruntwork-io/terratest v0.47.0/go.mod h1:oywHw1cFKXSYvKPm27U7quZVzDUlA22H2xUrKCe26xM=
Expand Down Expand Up @@ -670,16 +670,16 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240416134707-eb36aa90df2d h1:vWHR33VfphOahBlo3aGCE/eKPlfb4BCInhKidGkdp5s=
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240416134707-eb36aa90df2d/go.mod h1:dtDKAPiUDxAwIkfHV7xcAFZcOm+xwNIuOI1MLFS+MeQ=
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.11 h1:FmEQplYSZ6pYslmBlUNaUabScOdi6hJialeV/yq0BrY=
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.11/go.mod h1:Obsv0kspgSSwF8jb91Z7CBY2FCQNq6RhiZXIQf26nWY=
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.11 h1:qsSICIj5cvoVBR4GLWmdu2n3FfJG5isJ2ABnNNWykLU=
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.11/go.mod h1:7cKHvKPpfdCpU4a/VCznRDDNMPBPI98cJ0uVJoUGrgg=
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.11 h1:AKDj/GD88UteVWe5RqtmprQCKNy/w2kQz/l8tepfzv0=
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.11/go.mod h1:5238AvoU1LVPQ8zgVFSfrmxMLaPm8bcnVAryo8VyclM=
github.com/threefoldtech/zos v0.5.6-0.20240611092312-66184cdeb953 h1:hzqMY2Ydb+N2TBrTJHpy5n5i5nflfre1dhoNQH/tfhI=
github.com/threefoldtech/zos v0.5.6-0.20240611092312-66184cdeb953/go.mod h1:yH6T43SiHvQBBuLgKGElECsIhqzJ6fy/dJyaxtO/X0M=
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240827163226-d4e15e206974 h1:95Ox9WYNiwm3mVJeVF/lp7iCpVGA28AkU1atN893eDo=
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240827163226-d4e15e206974/go.mod h1:dtDKAPiUDxAwIkfHV7xcAFZcOm+xwNIuOI1MLFS+MeQ=
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17-0.20240904122047-8dbb80d1d261 h1:HyVkauSes4lpRDg0zyDKkb5Tcr8nDeQYt4mqEdlqNuE=
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17-0.20240904122047-8dbb80d1d261/go.mod h1:MwKEEeKN7qApCdabKRBTs18lrJ6JzA2Xx5Hd2/zb4o0=
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16 h1:Bnt9POje9hc9nv1YwAu13ABnl63DBMH0qL4SeVhNsIQ=
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16/go.mod h1:2Z7uJYHeilN7bASpmkcDxtl+3AT8tim6iIvqZ08pwCg=
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.16 h1:xe3LgMdznykz6d6cOFBt2s+sq3XooOVn20aHOZ3gbQE=
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.16/go.mod h1:cDTivSsUl4r1jN+H8/W6yDqByOOliY8HEGuVuL3ixV8=
github.com/threefoldtech/zos v0.5.6-0.20240902110349-172a0a29a6ee h1:pqpYVM0qkXujplHNfH6w5GDqcY5sLJAgOc4/hlR6+Xw=
github.com/threefoldtech/zos v0.5.6-0.20240902110349-172a0a29a6ee/go.mod h1:lut72yYMJhgK0QRvF0Wd/mB3+OfIoXWz04DQuXck3Sw=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/gateway_private_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/gateway_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/k8s_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
6 changes: 5 additions & 1 deletion integrationtests/k8s_using_module_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down Expand Up @@ -42,7 +46,7 @@ func TestModuleK8s(t *testing.T) {
FarmIDs: []uint64{1},
}

nodes, err := deployer.FilterNodes(context.Background(), tfPlugin, f, []uint64{freeSRU}, []uint64{}, []uint64{uint64(1024)})
nodes, err := deployer.FilterNodes(context.Background(), tfPlugin, f, []uint64{freeSRU}, []uint64{}, []uint64{})
require.NoError(t, err)
if len(nodes) < 3 {
t.Skip("couldn't find enough nodes")
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/mattermost_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/nomad_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/peertube_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/presearch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resource "grid_deployment" "d1" {
memory = 1024

mounts {
disk_name = "data"
name = "data"
mount_point = "/var/lib/docker"
}

Expand Down
4 changes: 4 additions & 0 deletions integrationtests/presearch_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/qsfs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resource "grid_deployment" "qsfs" {
SSH_KEY = "${var.public_key}"
}
mounts {
disk_name = "qsfs"
name = "qsfs"
mount_point = "/qsfs"
}
}
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/qsfs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/taiga/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "grid_deployment" "node1" {
memory = 8096
rootfs_size = 51200
mounts {
disk_name = "data0"
name = "data0"
mount_point = "/var/lib/docker"
}
env_vars = {
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/taiga_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
2 changes: 1 addition & 1 deletion integrationtests/vm_mounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ resource "grid_deployment" "d1" {
memory = 1024
entrypoint = "/init.sh"
mounts {
disk_name = "data"
name = "data"
mount_point = "/${var.mount_point}"
}
env_vars = {
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/vm_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/wireguard_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 4 additions & 0 deletions integrationtests/zdb_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build integration
// +build integration

// Package integrationtests includes integration tests for deploying solutions on the tf grid, and some utilities to test these solutions.
package integrationtests

import (
Expand Down
4 changes: 3 additions & 1 deletion internal/provider/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func newDeploymentFromSchema(d *schema.ResourceData) (*workloads.Deployment, err
return nil, errors.Wrap(err, "failed to create workload from vm map")
}

vms = append(vms, *v.(*workloads.VM))
vmWorkload := *v.(*workloads.VM)
vmWorkload.NodeID = nodeID
vms = append(vms, vmWorkload)
}

// TODO: ip_range
Expand Down
Loading

0 comments on commit dd46e44

Please sign in to comment.