[lxc-devel] [lxd/master] Unused code removal
tomponline on Github
lxc-bot at linuxcontainers.org
Wed Mar 18 09:45:02 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 468 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200318/e7bd5ee2/attachment.bin>
-------------- next part --------------
From 6bf871c7ade60ceb680e396c8e70c420bab0e441 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:02:11 +0000
Subject: [PATCH 01/17] lxd/api/cluster/test: Removes unused
DISABLED_TestCluster_Failover
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/api_cluster_test.go | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/lxd/api_cluster_test.go b/lxd/api_cluster_test.go
index 40f4a6e4af..632b6a149e 100644
--- a/lxd/api_cluster_test.go
+++ b/lxd/api_cluster_test.go
@@ -417,33 +417,6 @@ func TestCluster_JoinUnauthorized(t *testing.T) {
assert.EqualError(t, op.Wait(), "failed to request to add node: not authorized")
}
-// In a cluster for 3 nodes, if the leader goes down another one is elected the
-// other two nodes continue to operate fine.
-func DISABLED_TestCluster_Failover(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping cluster failover test in short mode.")
- }
- daemons, cleanup := newDaemons(t, 3)
- defer cleanup()
-
- f := clusterFixture{t: t}
- f.FormCluster(daemons)
-
- require.NoError(t, daemons[0].Stop())
-
- for i, daemon := range daemons[1:] {
- t.Logf("Invoking GetServer API against daemon %d", i)
- client := f.ClientUnix(daemon)
- server, _, err := client.GetServer()
- require.NoError(f.t, err)
- serverPut := server.Writable()
- serverPut.Config["core.trust_password"] = fmt.Sprintf("sekret-%d", i)
-
- t.Logf("Invoking UpdateServer API against daemon %d", i)
- require.NoError(f.t, client.UpdateServer(serverPut, ""))
- }
-}
-
// A node can leave a cluster gracefully.
func TestCluster_Leave(t *testing.T) {
t.Skip("issue #6122")
From bb0dcba17503a5e46d5d93d17dee3b8b6754417d Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:02:55 +0000
Subject: [PATCH 02/17] lxd/api/cluster/test: Removes unused
FLAKY_TestCluster_LeaveAndPromote
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/api_cluster_test.go | 36 ------------------------------------
1 file changed, 36 deletions(-)
diff --git a/lxd/api_cluster_test.go b/lxd/api_cluster_test.go
index 632b6a149e..6ce3f45c63 100644
--- a/lxd/api_cluster_test.go
+++ b/lxd/api_cluster_test.go
@@ -504,42 +504,6 @@ func TestCluster_LeaveForce(t *testing.T) {
assert.Equal(t, []string{}, images)
}
-// If a spare non-database node is available after a nodes leaves, it gets
-// promoted as database node.
-func FLAKY_TestCluster_LeaveAndPromote(t *testing.T) {
- if testing.Short() {
- t.Skip("skipping cluster promote test in short mode.")
- }
- daemons, cleanup := newDaemons(t, 4)
- defer cleanup()
-
- f := clusterFixture{t: t}
- f.FormCluster(daemons)
-
- // The first three nodes are database nodes, the fourth is not.
- client := f.ClientUnix(f.Leader())
- nodes, err := client.GetClusterMembers()
- require.NoError(t, err)
- assert.Len(t, nodes, 4)
- assert.True(t, nodes[0].Database)
- assert.True(t, nodes[1].Database)
- assert.True(t, nodes[2].Database)
- assert.False(t, nodes[3].Database)
-
- client = f.ClientUnix(daemons[1])
- err = client.DeleteClusterMember("rusp-0", false)
- require.NoError(t, err)
-
- // Only three nodes are left, and they are all database nodes.
- client = f.ClientUnix(f.Leader())
- nodes, err = client.GetClusterMembers()
- require.NoError(t, err)
- assert.Len(t, nodes, 3)
- assert.True(t, nodes[0].Database)
- assert.True(t, nodes[1].Database)
- assert.True(t, nodes[2].Database)
-}
-
// A LXD node can be renamed.
func TestCluster_NodeRename(t *testing.T) {
t.Skip("issue #6122")
From d65f167eb353c9395bc1b436bc9e3b2b3fc1282a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:05:11 +0000
Subject: [PATCH 03/17] lxd/cluster/gateway: Removes unused cachedRaftNodes
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/cluster/gateway.go | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/lxd/cluster/gateway.go b/lxd/cluster/gateway.go
index 7cda19b60c..656f1e5061 100644
--- a/lxd/cluster/gateway.go
+++ b/lxd/cluster/gateway.go
@@ -777,24 +777,6 @@ func (g *Gateway) currentRaftNodes() ([]db.RaftNode, error) {
return servers, nil
}
-// Return the addresses of the raft nodes as stored in the node-level
-// database.
-//
-// These values might leg behind the actual values, and are refreshed
-// periodically during heartbeats.
-func (g *Gateway) cachedRaftNodes() ([]string, error) {
- var addresses []string
- err := g.db.Transaction(func(tx *db.NodeTx) error {
- var err error
- addresses, err = tx.RaftNodeAddresses()
- return err
- })
- if err != nil {
- return nil, errors.Wrap(err, "Failed to fetch raft nodes")
- }
- return addresses, nil
-}
-
// Look up a server address in the raft_nodes table.
func (g *Gateway) raftAddress(databaseID uint64) (string, error) {
var address string
From 4c94240d86f637488370d03733989c478104b4f0 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:06:37 +0000
Subject: [PATCH 04/17] lxd/cluster/heartbeat/test: Removes unused
DISABLE_TestHeartbeat_MarkAsDown
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/cluster/heartbeat_test.go | 49 -----------------------------------
1 file changed, 49 deletions(-)
diff --git a/lxd/cluster/heartbeat_test.go b/lxd/cluster/heartbeat_test.go
index 8c86cf16e7..74bd601589 100644
--- a/lxd/cluster/heartbeat_test.go
+++ b/lxd/cluster/heartbeat_test.go
@@ -65,55 +65,6 @@ func TestHeartbeat(t *testing.T) {
require.NoError(t, err)
}
-// If a certain node does not successfully respond to the heartbeat, its
-// timestamp does not get updated.
-func DISABLE_TestHeartbeat_MarkAsDown(t *testing.T) {
- f := heartbeatFixture{t: t}
- defer f.Cleanup()
-
- f.Bootstrap()
- f.Grow()
-
- leader := f.Leader()
- leaderState := f.State(leader)
-
- // Artificially mark all nodes as down
- t.Logf("marking all nodes as down")
- err := leaderState.Cluster.Transaction(func(tx *db.ClusterTx) error {
- nodes, err := tx.Nodes()
- require.NoError(t, err)
- for _, node := range nodes {
- err := tx.NodeHeartbeat(node.Address, time.Now().Add(-time.Minute))
- require.NoError(t, err)
- }
- return nil
- })
- require.NoError(t, err)
-
- follower := f.Follower()
-
- // Shutdown the follower node and perform the heartbeat requests.
- f.Server(follower).Close()
- leader.Cluster = leaderState.Cluster
- heartbeat, _ := cluster.HeartbeatTask(leader)
- ctx := context.Background()
- heartbeat(ctx)
-
- // The heartbeat timestamp of the second node did not get updated
- err = leaderState.Cluster.Transaction(func(tx *db.ClusterTx) error {
- nodes, err := tx.Nodes()
- require.NoError(t, err)
-
- offlineThreshold, err := tx.NodeOfflineThreshold()
- require.NoError(t, err)
-
- i := f.Index(follower)
- assert.True(t, nodes[i].IsOffline(offlineThreshold))
- return nil
- })
- require.NoError(t, err)
-}
-
// Helper for testing heartbeat-related code.
type heartbeatFixture struct {
t *testing.T
From f2610ad5e57e069ab4f760e6b22c31660bcb3d96 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:08:11 +0000
Subject: [PATCH 05/17] lxd/cluster/membership/test: Removes unused
FLAKY_TestPromote
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/cluster/membership_test.go | 78 ----------------------------------
1 file changed, 78 deletions(-)
diff --git a/lxd/cluster/membership_test.go b/lxd/cluster/membership_test.go
index cd1d8109d1..35aa6360e1 100644
--- a/lxd/cluster/membership_test.go
+++ b/lxd/cluster/membership_test.go
@@ -362,84 +362,6 @@ func TestJoin(t *testing.T) {
assert.Len(t, members, 1)
}
-func FLAKY_TestPromote(t *testing.T) {
- // Setup a target node running as leader of a cluster.
- targetCert := shared.TestingKeyPair()
- targetMux := http.NewServeMux()
- targetServer := newServer(targetCert, targetMux)
- defer targetServer.Close()
-
- targetState, cleanup := state.NewTestState(t)
- defer cleanup()
-
- targetGateway := newGateway(t, targetState.Node, targetCert)
- defer targetGateway.Shutdown()
-
- for path, handler := range targetGateway.HandlerFuncs(nil) {
- targetMux.HandleFunc(path, handler)
- }
-
- targetAddress := targetServer.Listener.Addr().String()
- var err error
- require.NoError(t, targetState.Cluster.Close())
- store := targetGateway.NodeStore()
- dialFunc := targetGateway.DialFunc()
- targetState.Cluster, err = db.OpenCluster(
- "db.bin", store, targetAddress, "/unused/db/dir", 5*time.Second, nil,
- driver.WithDialFunc(dialFunc))
- require.NoError(t, err)
- targetF := &membershipFixtures{t: t, state: targetState}
- targetF.ClusterAddress(targetAddress)
-
- err = cluster.Bootstrap(targetState, targetGateway, "buzz")
- require.NoError(t, err)
-
- // Setup a node to be promoted.
- mux := http.NewServeMux()
- server := newServer(targetCert, mux) // Use the same cert, as we're already part of the cluster
- defer server.Close()
-
- state, cleanup := state.NewTestState(t)
- defer cleanup()
-
- address := server.Listener.Addr().String()
- targetF.ClusterNode(address) // Add the non database node to the cluster database
- f := &membershipFixtures{t: t, state: state}
- f.ClusterAddress(address)
- f.RaftNode(targetAddress) // Insert the leader in our local list of database nodes
-
- gateway := newGateway(t, state.Node, targetCert)
- defer gateway.Shutdown()
-
- for path, handler := range gateway.HandlerFuncs(nil) {
- mux.HandleFunc(path, handler)
- }
-
- // Promote the node.
- targetF.RaftNode(address) // Add the address of the node to be promoted in the leader's db
- raftNodes := targetF.RaftNodes()
- err = cluster.Assign(state, gateway, raftNodes)
- require.NoError(t, err)
-
- // The leader now returns an updated list of raft nodes.
- raftNodes, err = targetGateway.RaftNodes()
- require.NoError(t, err)
- assert.Len(t, raftNodes, 2)
- assert.Equal(t, int64(1), raftNodes[0].ID)
- assert.Equal(t, targetAddress, raftNodes[0].Address)
- assert.Equal(t, int64(2), raftNodes[1].ID)
- assert.Equal(t, address, raftNodes[1].Address)
-
- // The List function returns all nodes in the cluster.
- nodes, err := cluster.List(state)
- require.NoError(t, err)
- assert.Len(t, nodes, 2)
- assert.Equal(t, "Online", nodes[0].Status)
- assert.Equal(t, "Online", nodes[1].Status)
- assert.True(t, nodes[0].Database)
- assert.True(t, nodes[1].Database)
-}
-
// Helper for setting fixtures for Bootstrap tests.
type membershipFixtures struct {
t *testing.T
From d6062ee3776e7eae69197201c5e19acb602de5ce Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:13:40 +0000
Subject: [PATCH 06/17] lxd/db/containers: Removes unused snapshotIDsAndNames
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/db/containers.go | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 99a4abadb9..89bc4aad43 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -439,25 +439,6 @@ SELECT instances.name, nodes.name
return result, nil
}
-// Returns a map of snapshot IDs to snapshot names for the
-// container with the given name.
-func (c *ClusterTx) snapshotIDsAndNames(project, name string) (map[int]string, error) {
- filter := InstanceSnapshotFilter{
- Project: project,
- Instance: name,
- }
- objects, err := c.InstanceSnapshotList(filter)
- if err != nil {
- return nil, err
- }
-
- result := make(map[int]string)
- for i := range objects {
- result[objects[i].ID] = objects[i].Name
- }
- return result, nil
-}
-
// ContainerNodeMove changes the node associated with a container.
//
// It's meant to be used when moving a non-running container backed by ceph
From 3648cfebef562a002caff25a5f2a7acf053d5b1f Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:14:46 +0000
Subject: [PATCH 07/17] lxd/db/db/internal/test: Removes unused dir var
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/db/db_internal_test.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/lxd/db/db_internal_test.go b/lxd/db/db_internal_test.go
index 13c28f7069..faec44a409 100644
--- a/lxd/db/db_internal_test.go
+++ b/lxd/db/db_internal_test.go
@@ -34,7 +34,6 @@ const fixtures string = `
type dbTestSuite struct {
suite.Suite
- dir string
db *Cluster
cleanup func()
}
From 57bca88344099e67f0e2eaef453c2db7920bea4f Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:15:14 +0000
Subject: [PATCH 08/17] lxd/db/testing: Removes unused var
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/db/testing.go | 2 --
1 file changed, 2 deletions(-)
diff --git a/lxd/db/testing.go b/lxd/db/testing.go
index f6ca45c705..c9614916fc 100644
--- a/lxd/db/testing.go
+++ b/lxd/db/testing.go
@@ -137,8 +137,6 @@ func NewTestDqliteServer(t *testing.T) (string, driver.NodeStore, func()) {
return dir, store, cleanup
}
-var dqliteSerial = 0
-
// Return a new temporary directory.
func newDir(t *testing.T) (string, func()) {
t.Helper()
From bdd2e4fffbae300e9e32c874c676e85b4b31ec23 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:16:50 +0000
Subject: [PATCH 09/17] lxd/device/device/utils/unix: Removes unused
unixDeviceInstanceAttributes
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/device_utils_unix.go | 47 ---------------------------------
1 file changed, 47 deletions(-)
diff --git a/lxd/device/device_utils_unix.go b/lxd/device/device_utils_unix.go
index 0fe80873a7..74302669e3 100644
--- a/lxd/device/device_utils_unix.go
+++ b/lxd/device/device_utils_unix.go
@@ -20,53 +20,6 @@ import (
// unixDefaultMode default mode to create unix devices with if not specified in device config.
const unixDefaultMode = 0660
-// unixDeviceInstanceAttributes returns the UNIX device attributes for an instance device.
-// Uses supplied device config for device properties, and if they haven't been set, falls back to
-// using UnixGetDeviceAttributes() to directly query an existing device file.
-func unixDeviceInstanceAttributes(devicesPath string, prefix string, config deviceConfig.Device) (string, uint32, uint32, error) {
- // Check if we've been passed major and minor numbers already.
- var err error
- var dMajor, dMinor uint32
-
- if config["major"] != "" {
- tmp, err := strconv.ParseUint(config["major"], 10, 32)
- if err != nil {
- return "", 0, 0, err
- }
- dMajor = uint32(tmp)
- }
-
- if config["minor"] != "" {
- tmp, err := strconv.ParseUint(config["minor"], 10, 32)
- if err != nil {
- return "", 0, 0, err
- }
- dMinor = uint32(tmp)
- }
-
- dType := ""
- if config["type"] == "unix-char" {
- dType = "c"
- } else if config["type"] == "unix-block" {
- dType = "b"
- }
-
- destPath := unixDeviceDestPath(config)
- relativeDestPath := strings.TrimPrefix(destPath, "/")
- devName := fmt.Sprintf("%s.%s", strings.Replace(prefix, "/", "-", -1), strings.Replace(relativeDestPath, "/", "-", -1))
- devPath := filepath.Join(devicesPath, devName)
-
- // If any config options missing then retrieve all the needed set of attributes from device.
- if dType == "" || config["major"] == "" || config["minor"] == "" {
- dType, dMajor, dMinor, err = unixDeviceAttributes(devPath)
- if err != nil {
- return dType, dMajor, dMinor, err
- }
- }
-
- return dType, dMajor, dMinor, err
-}
-
// unixDeviceAttributes returns the decice type, major and minor numbers for a device.
func unixDeviceAttributes(path string) (string, uint32, uint32, error) {
// Get a stat struct from the provided path
From bb1ad81bbc360d1ebc356a6f0e2eacc5d0f7792a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:23:43 +0000
Subject: [PATCH 10/17] lxd/device/nic/bridged: Removes unused dhcpAllocation
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/device/nic_bridged.go | 8 --------
1 file changed, 8 deletions(-)
diff --git a/lxd/device/nic_bridged.go b/lxd/device/nic_bridged.go
index 24233f95ef..fde4ba269c 100644
--- a/lxd/device/nic_bridged.go
+++ b/lxd/device/nic_bridged.go
@@ -29,14 +29,6 @@ import (
"github.com/lxc/lxd/shared/logger"
)
-// dhcpAllocation represents an IP allocation from dnsmasq used for IP filtering.
-type dhcpAllocation struct {
- IP net.IP
- Name string
- MAC net.HardwareAddr
- Static bool
-}
-
type nicBridged struct {
deviceCommon
}
From e92e34fe201750ea23ecdeff7c1cbb9cd3fb5117 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:33:11 +0000
Subject: [PATCH 11/17] lxd/firewall: Removes unused constants
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/firewall/firewall_load.go | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lxd/firewall/firewall_load.go b/lxd/firewall/firewall_load.go
index 1a17a79d43..367a4ec0d2 100644
--- a/lxd/firewall/firewall_load.go
+++ b/lxd/firewall/firewall_load.go
@@ -4,9 +4,6 @@ import (
"github.com/lxc/lxd/lxd/firewall/drivers"
)
-const driverXtables = "xtables"
-const driverNftables = "nftables"
-
// New returns an appropriate firewall implementation.
// Uses xtables if nftables isn't compatible or isn't in use already, otherwise uses nftables.
func New() Firewall {
From d16869ad409d2fa68ec9a914d2ecacf38f115d4c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:34:42 +0000
Subject: [PATCH 12/17] lxd/instance/drivers/driver/lxc: Removes unused cgroup2
var
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/instance/drivers/driver_lxc.go | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go
index b9bf587897..0507b5be8a 100644
--- a/lxd/instance/drivers/driver_lxc.go
+++ b/lxd/instance/drivers/driver_lxc.go
@@ -6836,9 +6836,8 @@ func (c *lxc) cgroup(cc *liblxc.Container) (*cgroup.CGroup, error) {
}
type lxcCgroupReadWriter struct {
- cc *liblxc.Container
- conf bool
- cgroup2 bool
+ cc *liblxc.Container
+ conf bool
}
func (rw *lxcCgroupReadWriter) Get(version cgroup.Backend, controller string, key string) (string, error) {
From 90b8d298c760a3f9a5f5bdc2c5a9ada3d10009a8 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:35:46 +0000
Subject: [PATCH 13/17] lxd/main/forkproxy: Removes unused udpConn var
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/main_forkproxy.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index a720b928a3..6c1735b94c 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -423,7 +423,6 @@ func listenerInstance(epFd C.int, lAddr *deviceConfig.ProxyAddress, cAddr *devic
type lStruct struct {
f *os.File
lConn *net.Listener
- udpConn *net.Conn
lAddrIndex int
}
From 756f8e878ddae7f19c0969017153c277e6b18667 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:36:47 +0000
Subject: [PATCH 14/17] lxd/storage/drivers/driver/common: Removes unused load
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/drivers/driver_common.go | 4 ----
1 file changed, 4 deletions(-)
diff --git a/lxd/storage/drivers/driver_common.go b/lxd/storage/drivers/driver_common.go
index 051eb73033..7f4b9daa4e 100644
--- a/lxd/storage/drivers/driver_common.go
+++ b/lxd/storage/drivers/driver_common.go
@@ -34,10 +34,6 @@ func (d *common) init(state *state.State, name string, config map[string]string,
d.logger = logger
}
-func (d *common) load() error {
- return nil
-}
-
// validatePool validates a pool config against common rules and optional driver specific rules.
func (d *common) validatePool(config map[string]string, driverRules map[string]func(value string) error) error {
checkedFields := map[string]struct{}{}
From fddfa172fbd6bc175d77aa850d10527be1ed9401 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:37:50 +0000
Subject: [PATCH 15/17] shared/generate/file/buffer: Removes unused
varDeclSliceToString
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
shared/generate/file/buffer.go | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/shared/generate/file/buffer.go b/shared/generate/file/buffer.go
index 78285af8ed..1b9be16251 100644
--- a/shared/generate/file/buffer.go
+++ b/shared/generate/file/buffer.go
@@ -4,9 +4,7 @@ import (
"bytes"
"fmt"
"go/format"
- "strings"
- "github.com/lxc/lxd/shared/generate/lex"
"github.com/pkg/errors"
)
@@ -41,13 +39,3 @@ func (b *Buffer) code() ([]byte, error) {
}
return code, nil
}
-
-func varDeclSliceToString(decls []lex.VarDecl) string {
- parts := []string{}
-
- for _, decl := range decls {
- parts = append(parts, decl.String())
- }
-
- return strings.Join(parts, ", ")
-}
From 653df0d91368255bba4cad25b27054a471f184a2 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:38:36 +0000
Subject: [PATCH 16/17] shared/generate/db/parse: Removes unused
simpleTypeNames
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
shared/generate/db/parse.go | 6 ------
1 file changed, 6 deletions(-)
diff --git a/shared/generate/db/parse.go b/shared/generate/db/parse.go
index d9f34346de..7b38733a9b 100644
--- a/shared/generate/db/parse.go
+++ b/shared/generate/db/parse.go
@@ -276,9 +276,3 @@ func parseType(x ast.Expr) string {
return ""
}
}
-
-var simpleTypeNames = []string{
- "bool",
- "string",
- "int",
-}
From a44d33646c9dea96ba379427a69dfa7777ace3e3 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 18 Mar 2020 09:39:27 +0000
Subject: [PATCH 17/17] shared/generated/file/path: Removes unused absPath
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
shared/generate/file/path.go | 28 ----------------------------
1 file changed, 28 deletions(-)
delete mode 100644 shared/generate/file/path.go
diff --git a/shared/generate/file/path.go b/shared/generate/file/path.go
deleted file mode 100644
index ef4533990a..0000000000
--- a/shared/generate/file/path.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package file
-
-import (
- "log"
- "path/filepath"
- "runtime"
- "strings"
-)
-
-// Given its relative path with respect to the LXD surce tree, return the full
-// path of a file.
-func absPath(path string) string {
- // We expect to be called by code within the lxd package itself.
- _, filename, _, _ := runtime.Caller(1)
-
- elems := strings.Split(filename, string(filepath.Separator))
- for i := len(elems) - 1; i >= 0; i-- {
- if elems[i] == "lxd" {
- elems = append([]string{string(filepath.Separator)}, elems[:i]...)
- elems = append(elems, path)
- return filepath.Join(elems...)
- }
- }
-
- log.Fatalf("Could not found root dir of LXD tree source tree")
-
- return ""
-}
More information about the lxc-devel
mailing list