[lxc-devel] [lxd/master] Renames ContainerArgs to InstanceArgs

tomponline on Github lxc-bot at linuxcontainers.org
Fri Sep 27 11:00:01 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190927/432cc9d6/attachment.bin>
-------------- next part --------------
From d72263a555a44f98cde607e97fdf5658239eef6a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 27 Sep 2019 11:38:20 +0100
Subject: [PATCH 1/4] lxd/db/containers: Renames ContainerArgs to InstanceArgs

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/db/containers.go | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 8c817838e1..4e6c04922b 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -121,9 +121,8 @@ func ContainerToArgs(container *Instance) ContainerArgs {
 	return args
 }
 
-// ContainerArgs is a value object holding all db-related details about a
-// container.
-type ContainerArgs struct {
+// InstanceArgs is a value object holding all db-related details about an instance.
+type InstanceArgs struct {
 	// Don't set manually
 	ID       int
 	Node     string

From 2044b8abf1ca09bdc8a10652849abb20945092a4 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 27 Sep 2019 11:38:40 +0100
Subject: [PATCH 2/4] lxd: Updates usage of ContainerArgs to InstanceArgs

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/api_internal.go          |  4 ++--
 lxd/container.go             | 16 ++++++++--------
 lxd/container_lxc.go         | 12 ++++++------
 lxd/container_patch.go       |  2 +-
 lxd/container_put.go         |  2 +-
 lxd/container_snapshot.go    |  4 ++--
 lxd/container_state.go       |  2 +-
 lxd/container_test.go        | 30 +++++++++++++++---------------
 lxd/containers.go            |  2 +-
 lxd/containers_post.go       |  8 ++++----
 lxd/db/containers.go         |  6 +++---
 lxd/instance_interface.go    |  4 ++--
 lxd/patches.go               |  2 +-
 lxd/profiles_utils.go        |  8 ++++----
 lxd/storage_btrfs.go         |  2 +-
 lxd/storage_ceph.go          |  2 +-
 lxd/storage_migration.go     |  8 ++++----
 lxd/storage_volumes_utils.go |  2 +-
 lxd/storage_zfs.go           |  2 +-
 19 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index 4c87f556e2..48d019b769 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -916,7 +916,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
 	if err != nil {
 		return response.SmartError(err)
 	}
-	_, err = containerCreateInternal(d.State(), db.ContainerArgs{
+	_, err = containerCreateInternal(d.State(), db.InstanceArgs{
 		Project:      projectName,
 		Architecture: arch,
 		BaseImage:    baseImage,
@@ -1022,7 +1022,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
 			snap.Devices[rootDevName] = rootDev
 		}
 
-		_, err = containerCreateInternal(d.State(), db.ContainerArgs{
+		_, err = containerCreateInternal(d.State(), db.InstanceArgs{
 			Project:      projectName,
 			Architecture: arch,
 			BaseImage:    baseImage,
diff --git a/lxd/container.go b/lxd/container.go
index 8489f31152..698aa7acf0 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -240,7 +240,7 @@ type container interface {
 }
 
 // Loader functions
-func containerCreateAsEmpty(d *Daemon, args db.ContainerArgs) (container, error) {
+func containerCreateAsEmpty(d *Daemon, args db.InstanceArgs) (container, error) {
 	// Create the container
 	c, err := containerCreateInternal(d.State(), args)
 	if err != nil {
@@ -327,7 +327,7 @@ func containerCreateFromBackup(s *state.State, info backupInfo, data io.ReadSeek
 	return pool, nil
 }
 
-func containerCreateEmptySnapshot(s *state.State, args db.ContainerArgs) (container, error) {
+func containerCreateEmptySnapshot(s *state.State, args db.InstanceArgs) (container, error) {
 	// Create the snapshot
 	c, err := containerCreateInternal(s, args)
 	if err != nil {
@@ -344,7 +344,7 @@ func containerCreateEmptySnapshot(s *state.State, args db.ContainerArgs) (contai
 	return c, nil
 }
 
-func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string, tracker *ioprogress.ProgressTracker) (container, error) {
+func containerCreateFromImage(d *Daemon, args db.InstanceArgs, hash string, tracker *ioprogress.ProgressTracker) (container, error) {
 	s := d.State()
 
 	// Get the image properties
@@ -429,7 +429,7 @@ func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string, tra
 	return c, nil
 }
 
-func containerCreateAsCopy(s *state.State, args db.ContainerArgs, sourceContainer Instance, containerOnly bool, refresh bool) (Instance, error) {
+func containerCreateAsCopy(s *state.State, args db.InstanceArgs, sourceContainer Instance, containerOnly bool, refresh bool) (Instance, error) {
 	var ct Instance
 	var err error
 
@@ -517,7 +517,7 @@ func containerCreateAsCopy(s *state.State, args db.ContainerArgs, sourceContaine
 			}
 
 			newSnapName := fmt.Sprintf("%s/%s", ct.Name(), fields[1])
-			csArgs := db.ContainerArgs{
+			csArgs := db.InstanceArgs{
 				Architecture: snap.Architecture(),
 				Config:       snap.LocalConfig(),
 				Type:         sourceContainer.Type(),
@@ -598,7 +598,7 @@ func containerCreateAsCopy(s *state.State, args db.ContainerArgs, sourceContaine
 	return ct, nil
 }
 
-func containerCreateAsSnapshot(s *state.State, args db.ContainerArgs, sourceInstance Instance) (Instance, error) {
+func containerCreateAsSnapshot(s *state.State, args db.InstanceArgs, sourceInstance Instance) (Instance, error) {
 	if sourceInstance.Type() != instancetype.Container {
 		return nil, fmt.Errorf("Instance not container type")
 	}
@@ -691,7 +691,7 @@ func containerCreateAsSnapshot(s *state.State, args db.ContainerArgs, sourceInst
 	return c, nil
 }
 
-func containerCreateInternal(s *state.State, args db.ContainerArgs) (container, error) {
+func containerCreateInternal(s *state.State, args db.InstanceArgs) (container, error) {
 	// Set default values
 	if args.Project == "" {
 		args.Project = "default"
@@ -1305,7 +1305,7 @@ func autoCreateContainerSnapshots(ctx context.Context, d *Daemon, instances []In
 				return
 			}
 
-			args := db.ContainerArgs{
+			args := db.InstanceArgs{
 				Architecture: c.Architecture(),
 				Config:       c.LocalConfig(),
 				Type:         c.Type(),
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 0f8fb885a3..8a705bfa59 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -318,7 +318,7 @@ func lxcStatusCode(state lxc.State) api.StatusCode {
 }
 
 // Loader functions
-func containerLXCCreate(s *state.State, args db.ContainerArgs) (container, error) {
+func containerLXCCreate(s *state.State, args db.InstanceArgs) (container, error) {
 	// Create the container struct
 	c := &containerLXC{
 		state:        s,
@@ -524,7 +524,7 @@ func containerLXCCreate(s *state.State, args db.ContainerArgs) (container, error
 	return c, nil
 }
 
-func containerLXCLoad(s *state.State, args db.ContainerArgs, profiles []api.Profile) (container, error) {
+func containerLXCLoad(s *state.State, args db.InstanceArgs, profiles []api.Profile) (container, error) {
 	// Create the container struct
 	c := containerLXCInstantiate(s, args)
 
@@ -555,7 +555,7 @@ func containerLXCUnload(c *containerLXC) {
 }
 
 // Create a container struct without initializing it.
-func containerLXCInstantiate(s *state.State, args db.ContainerArgs) *containerLXC {
+func containerLXCInstantiate(s *state.State, args db.InstanceArgs) *containerLXC {
 	c := &containerLXC{
 		state:        s,
 		id:           args.ID,
@@ -3479,7 +3479,7 @@ func (c *containerLXC) Restore(sourceContainer Instance, stateful bool) error {
 		ephemeral := c.IsEphemeral()
 		if ephemeral {
 			// Unset ephemeral flag
-			args := db.ContainerArgs{
+			args := db.InstanceArgs{
 				Architecture: c.Architecture(),
 				Config:       c.LocalConfig(),
 				Description:  c.Description(),
@@ -3537,7 +3537,7 @@ func (c *containerLXC) Restore(sourceContainer Instance, stateful bool) error {
 	}
 
 	// Restore the configuration
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Architecture: sourceContainer.Architecture(),
 		Config:       sourceContainer.LocalConfig(),
 		Description:  sourceContainer.Description(),
@@ -4110,7 +4110,7 @@ func writeBackupFile(c Instance) error {
 	return nil
 }
 
-func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
+func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
 	// Set sane defaults for unset keys
 	if args.Project == "" {
 		args.Project = "default"
diff --git a/lxd/container_patch.go b/lxd/container_patch.go
index 44824bcc5a..eecc982ced 100644
--- a/lxd/container_patch.go
+++ b/lxd/container_patch.go
@@ -120,7 +120,7 @@ func containerPatch(d *Daemon, r *http.Request) response.Response {
 	}
 
 	// Update container configuration
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Architecture: architecture,
 		Config:       req.Config,
 		Description:  req.Description,
diff --git a/lxd/container_put.go b/lxd/container_put.go
index 18edacba56..b606b6ea8f 100644
--- a/lxd/container_put.go
+++ b/lxd/container_put.go
@@ -68,7 +68,7 @@ func containerPut(d *Daemon, r *http.Request) response.Response {
 	if configRaw.Restore == "" {
 		// Update container configuration
 		do = func(op *operation) error {
-			args := db.ContainerArgs{
+			args := db.InstanceArgs{
 				Architecture: architecture,
 				Config:       configRaw.Config,
 				Description:  configRaw.Description,
diff --git a/lxd/container_snapshot.go b/lxd/container_snapshot.go
index cada540241..9b2cc91482 100644
--- a/lxd/container_snapshot.go
+++ b/lxd/container_snapshot.go
@@ -148,7 +148,7 @@ func containerSnapshotsPost(d *Daemon, r *http.Request) response.Response {
 	}
 
 	snapshot := func(op *operation) error {
-		args := db.ContainerArgs{
+		args := db.InstanceArgs{
 			Project:      inst.Project(),
 			Architecture: inst.Architecture(),
 			Config:       inst.LocalConfig(),
@@ -276,7 +276,7 @@ func snapshotPut(d *Daemon, r *http.Request, sc container, name string) response
 
 		// Update container configuration
 		do = func(op *operation) error {
-			args := db.ContainerArgs{
+			args := db.InstanceArgs{
 				Architecture: sc.Architecture(),
 				Config:       sc.LocalConfig(),
 				Description:  sc.Description(),
diff --git a/lxd/container_state.go b/lxd/container_state.go
index 5dd64ddf0c..911decafc5 100644
--- a/lxd/container_state.go
+++ b/lxd/container_state.go
@@ -140,7 +140,7 @@ func containerStatePut(d *Daemon, r *http.Request) response.Response {
 
 			if ephemeral {
 				// Unset ephemeral flag
-				args := db.ContainerArgs{
+				args := db.InstanceArgs{
 					Architecture: c.Architecture(),
 					Config:       c.LocalConfig(),
 					Description:  c.Description(),
diff --git a/lxd/container_test.go b/lxd/container_test.go
index f7140cc0e7..ba1f0e6e11 100644
--- a/lxd/container_test.go
+++ b/lxd/container_test.go
@@ -20,7 +20,7 @@ type containerTestSuite struct {
 }
 
 func (suite *containerTestSuite) TestContainer_ProfilesDefault() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Name:      "testFoo",
@@ -62,7 +62,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesMulti() {
 		})
 	}()
 
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Profiles:  []string{"default", "unprivileged"},
@@ -85,7 +85,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesMulti() {
 }
 
 func (suite *containerTestSuite) TestContainer_ProfilesOverwriteDefaultNic() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "true"},
@@ -115,7 +115,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesOverwriteDefaultNic() {
 }
 
 func (suite *containerTestSuite) TestContainer_LoadFromDB() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "true"},
@@ -153,7 +153,7 @@ func (suite *containerTestSuite) TestContainer_LoadFromDB() {
 
 func (suite *containerTestSuite) TestContainer_Path_Regular() {
 	// Regular
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Name:      "testFoo",
@@ -169,7 +169,7 @@ func (suite *containerTestSuite) TestContainer_Path_Regular() {
 }
 
 func (suite *containerTestSuite) TestContainer_LogPath() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Name:      "testFoo",
@@ -183,7 +183,7 @@ func (suite *containerTestSuite) TestContainer_LogPath() {
 }
 
 func (suite *containerTestSuite) TestContainer_IsPrivileged_Privileged() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "true"},
@@ -198,7 +198,7 @@ func (suite *containerTestSuite) TestContainer_IsPrivileged_Privileged() {
 }
 
 func (suite *containerTestSuite) TestContainer_IsPrivileged_Unprivileged() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "false"},
@@ -213,7 +213,7 @@ func (suite *containerTestSuite) TestContainer_IsPrivileged_Unprivileged() {
 }
 
 func (suite *containerTestSuite) TestContainer_Rename() {
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Type:      instancetype.Container,
 		Ephemeral: false,
 		Name:      "testFoo",
@@ -228,7 +228,7 @@ func (suite *containerTestSuite) TestContainer_Rename() {
 }
 
 func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
-	c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+	c1, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 		Type: instancetype.Container,
 		Name: "isol-1",
 		Config: map[string]string{
@@ -238,7 +238,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
 	suite.Req.Nil(err)
 	defer c1.Delete()
 
-	c2, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+	c2, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 		Type: instancetype.Container,
 		Name: "isol-2",
 		Config: map[string]string{
@@ -269,7 +269,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
 }
 
 func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
-	c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+	c1, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 		Type: instancetype.Container,
 		Name: "isol-1",
 		Config: map[string]string{
@@ -279,7 +279,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
 	suite.Req.Nil(err)
 	defer c1.Delete()
 
-	c2, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+	c2, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 		Type: instancetype.Container,
 		Name: "isol-2",
 		Config: map[string]string{
@@ -310,7 +310,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
 }
 
 func (suite *containerTestSuite) TestContainer_findIdmap_raw() {
-	c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+	c1, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 		Type: instancetype.Container,
 		Name: "isol-1",
 		Config: map[string]string{
@@ -349,7 +349,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_maxed() {
 	maps := []*idmap.IdmapSet{}
 
 	for i := 0; i < 7; i++ {
-		c, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
+		c, err := containerCreateInternal(suite.d.State(), db.InstanceArgs{
 			Type: instancetype.Container,
 			Name: fmt.Sprintf("isol-%d", i),
 			Config: map[string]string{
diff --git a/lxd/containers.go b/lxd/containers.go
index a340642a00..ab403bf639 100644
--- a/lxd/containers.go
+++ b/lxd/containers.go
@@ -278,7 +278,7 @@ func containersShutdown(s *state.State) error {
 
 		for project, names := range cnames {
 			for _, name := range names {
-				c, err := containerLXCLoad(s, db.ContainerArgs{
+				c, err := containerLXCLoad(s, db.InstanceArgs{
 					Project: project,
 					Name:    name,
 					Config:  make(map[string]string),
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index ed46731abf..1f34163df1 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -100,7 +100,7 @@ func createFromImage(d *Daemon, project string, req *api.InstancesPost) response
 	}
 
 	run := func(op *operation) error {
-		args := db.ContainerArgs{
+		args := db.InstanceArgs{
 			Project:     project,
 			Config:      req.Config,
 			Type:        dbType,
@@ -161,7 +161,7 @@ func createFromNone(d *Daemon, project string, req *api.InstancesPost) response.
 		return response.BadRequest(err)
 	}
 
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Project:     project,
 		Config:      req.Config,
 		Type:        dbType,
@@ -221,7 +221,7 @@ func createFromMigration(d *Daemon, project string, req *api.InstancesPost) resp
 	}
 
 	// Prepare the container creation request
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Project:      project,
 		Architecture: architecture,
 		BaseImage:    req.Source.BaseImage,
@@ -583,7 +583,7 @@ func createFromCopy(d *Daemon, project string, req *api.InstancesPost) response.
 		return response.BadRequest(fmt.Errorf("Instance type should not be specified or should match source type"))
 	}
 
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Project:      targetProject,
 		Architecture: source.Architecture(),
 		BaseImage:    req.Source.BaseImage,
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 4e6c04922b..5416089c18 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -93,9 +93,9 @@ type InstanceFilter struct {
 }
 
 // ContainerToArgs is a convenience to convert the new Container db struct into
-// the legacy ContainerArgs.
-func ContainerToArgs(container *Instance) ContainerArgs {
-	args := ContainerArgs{
+// the legacy InstanceArgs.
+func ContainerToArgs(container *Instance) InstanceArgs {
+	args := InstanceArgs{
 		ID:           container.ID,
 		Project:      container.Project,
 		Name:         container.Name,
diff --git a/lxd/instance_interface.go b/lxd/instance_interface.go
index e228d56e30..4530c8514d 100644
--- a/lxd/instance_interface.go
+++ b/lxd/instance_interface.go
@@ -33,8 +33,8 @@ type Instance interface {
 	// Config handling
 	Rename(newName string) error
 
-	// TODO rename db.ContainerArgs to db.InstanceArgs.
-	Update(newConfig db.ContainerArgs, userRequested bool) error
+	// TODO rename db.InstanceArgs to db.InstanceArgs.
+	Update(newConfig db.InstanceArgs, userRequested bool) error
 
 	Delete() error
 	Export(w io.Writer, properties map[string]string) error
diff --git a/lxd/patches.go b/lxd/patches.go
index e5253902b4..918e8b0ad6 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -1883,7 +1883,7 @@ func updatePoolPropertyForAllObjects(d *Daemon, poolName string, allcontainers [
 			continue
 		}
 
-		args := db.ContainerArgs{
+		args := db.InstanceArgs{
 			Architecture: c.Architecture(),
 			Config:       c.LocalConfig(),
 			Description:  c.Description(),
diff --git a/lxd/profiles_utils.go b/lxd/profiles_utils.go
index de2db4349b..c483af6f5b 100644
--- a/lxd/profiles_utils.go
+++ b/lxd/profiles_utils.go
@@ -187,7 +187,7 @@ func doProfileUpdateCluster(d *Daemon, project, name string, old api.ProfilePut)
 }
 
 // Profile update of a single container.
-func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.ContainerArgs) error {
+func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.InstanceArgs) error {
 	if args.Node != "" && args.Node != nodeName {
 		// No-op, this container does not belong to this node.
 		return nil
@@ -211,7 +211,7 @@ func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeNa
 	c.expandConfig(profiles)
 	c.expandDevices(profiles)
 
-	return c.Update(db.ContainerArgs{
+	return c.Update(db.InstanceArgs{
 		Architecture: c.Architecture(),
 		Config:       c.LocalConfig(),
 		Description:  c.Description(),
@@ -226,7 +226,7 @@ func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeNa
 
 // Query the db for information about containers associated with the given
 // profile.
-func getProfileContainersInfo(cluster *db.Cluster, project, profile string) ([]db.ContainerArgs, error) {
+func getProfileContainersInfo(cluster *db.Cluster, project, profile string) ([]db.InstanceArgs, error) {
 	// Query the db for information about containers associated with the
 	// given profile.
 	names, err := cluster.ProfileContainersGet(project, profile)
@@ -234,7 +234,7 @@ func getProfileContainersInfo(cluster *db.Cluster, project, profile string) ([]d
 		return nil, errors.Wrapf(err, "failed to query containers with profile '%s'", profile)
 	}
 
-	containers := []db.ContainerArgs{}
+	containers := []db.InstanceArgs{}
 	err = cluster.Transaction(func(tx *db.ClusterTx) error {
 		for ctProject, ctNames := range names {
 			for _, ctName := range ctNames {
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index f339b710a3..7e8799ce23 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -2591,7 +2591,7 @@ func (s *storageBtrfs) MigrationSink(conn *websocket.Conn, op *operation, args M
 
 	if !args.InstanceOnly {
 		for _, snap := range args.Snapshots {
-			ctArgs := snapshotProtobufToContainerArgs(args.Instance.Project(), instanceName, snap)
+			ctArgs := snapshotProtobufToInstanceArgs(args.Instance.Project(), instanceName, snap)
 
 			// Ensure that snapshot and parent container have the
 			// same storage pool in their local root disk device.
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index 6a15cfd92e..488048a825 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -2930,7 +2930,7 @@ func (s *storageCeph) MigrationSink(conn *websocket.Conn, op *operation, args Mi
 	recvName := fmt.Sprintf("%s/container_%s", s.OSDPoolName, project.Prefix(args.Instance.Project(), instanceName))
 	for _, snap := range args.Snapshots {
 		curSnapName := snap.GetName()
-		ctArgs := snapshotProtobufToContainerArgs(args.Instance.Project(), instanceName, snap)
+		ctArgs := snapshotProtobufToInstanceArgs(args.Instance.Project(), instanceName, snap)
 
 		// Ensure that snapshot and parent container have the same
 		// storage pool in their local root disk device.  If the root
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index 51b37c68e7..117f8a54c1 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -178,7 +178,7 @@ func rsyncMigrationSource(args MigrationSourceArgs) (MigrationStorageSourceDrive
 	return rsyncStorageSourceDriver{args.Instance, snapshots, args.RsyncFeatures}, nil
 }
 
-func snapshotProtobufToContainerArgs(project string, containerName string, snap *migration.Snapshot) db.ContainerArgs {
+func snapshotProtobufToInstanceArgs(project string, containerName string, snap *migration.Snapshot) db.InstanceArgs {
 	config := map[string]string{}
 
 	for _, ent := range snap.LocalConfig {
@@ -196,7 +196,7 @@ func snapshotProtobufToContainerArgs(project string, containerName string, snap
 	}
 
 	name := containerName + shared.SnapshotDelimiter + snap.GetName()
-	args := db.ContainerArgs{
+	args := db.InstanceArgs{
 		Architecture: int(snap.GetArchitecture()),
 		Config:       config,
 		Type:         instancetype.Container,
@@ -329,7 +329,7 @@ func rsyncMigrationSink(conn *websocket.Conn, op *operation, args MigrationSinkA
 					continue
 				}
 
-				snapArgs := snapshotProtobufToContainerArgs(args.Instance.Project(), args.Instance.Name(), snap)
+				snapArgs := snapshotProtobufToInstanceArgs(args.Instance.Project(), args.Instance.Name(), snap)
 
 				// Ensure that snapshot and parent container have the
 				// same storage pool in their local root disk device.
@@ -393,7 +393,7 @@ func rsyncMigrationSink(conn *websocket.Conn, op *operation, args MigrationSinkA
 					continue
 				}
 
-				snapArgs := snapshotProtobufToContainerArgs(args.Instance.Project(), args.Instance.Name(), snap)
+				snapArgs := snapshotProtobufToInstanceArgs(args.Instance.Project(), args.Instance.Name(), snap)
 
 				// Ensure that snapshot and parent container have the
 				// same storage pool in their local root disk device.
diff --git a/lxd/storage_volumes_utils.go b/lxd/storage_volumes_utils.go
index b25a1288d9..46eeb2fac8 100644
--- a/lxd/storage_volumes_utils.go
+++ b/lxd/storage_volumes_utils.go
@@ -311,7 +311,7 @@ func storagePoolVolumeUpdateUsers(d *Daemon, oldPoolName string,
 			}
 		}
 
-		args := db.ContainerArgs{
+		args := db.InstanceArgs{
 			Architecture: inst.Architecture(),
 			Description:  inst.Description(),
 			Config:       inst.LocalConfig(),
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index aff449d39a..3116312231 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -2640,7 +2640,7 @@ func (s *storageZfs) MigrationSink(conn *websocket.Conn, op *operation, args Mig
 	}
 
 	for _, snap := range args.Snapshots {
-		ctArgs := snapshotProtobufToContainerArgs(args.Instance.Project(), args.Instance.Name(), snap)
+		ctArgs := snapshotProtobufToInstanceArgs(args.Instance.Project(), args.Instance.Name(), snap)
 
 		// Ensure that snapshot and parent container have the
 		// same storage pool in their local root disk device.

From d21d17957e794362dba1b50444caf385bc44ac0b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 27 Sep 2019 11:42:44 +0100
Subject: [PATCH 3/4] lxd/db/containers: Renames ContainerBackupArgs to
 InstanceBackupArgs

- Renames field ContainerID to InstanceID.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/db/containers.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 5416089c18..41f7d850b0 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -146,13 +146,12 @@ type InstanceArgs struct {
 	ExpiryDate   time.Time
 }
 
-// ContainerBackupArgs is a value object holding all db-related details
-// about a backup.
-type ContainerBackupArgs struct {
+// InstanceBackupArgs is a value object holding all db-related details about a backup.
+type InstanceBackupArgs struct {
 	// Don't set manually
 	ID int
 
-	ContainerID      int
+	InstanceID       int
 	Name             string
 	CreationDate     time.Time
 	ExpiryDate       time.Time

From 9c9eb4de1482916fb96875b540e4f7604e7fac6a Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 27 Sep 2019 11:43:12 +0100
Subject: [PATCH 4/4] lxd: Updates usage of ContainerBackupArgs to
 InstanceBackupArgs

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/backup.go           |  4 ++--
 lxd/container_backup.go |  4 ++--
 lxd/db/containers.go    | 10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lxd/backup.go b/lxd/backup.go
index 16f6b7c9f6..0abe281829 100644
--- a/lxd/backup.go
+++ b/lxd/backup.go
@@ -33,7 +33,7 @@ func backupLoadByName(s *state.State, project, name string) (*backup, error) {
 	}
 
 	// Load the instance it belongs to
-	instance, err := instanceLoadById(s, args.ContainerID)
+	instance, err := instanceLoadById(s, args.InstanceID)
 	if err != nil {
 		return nil, errors.Wrap(err, "Load container from database")
 	}
@@ -52,7 +52,7 @@ func backupLoadByName(s *state.State, project, name string) (*backup, error) {
 }
 
 // Create a new backup
-func backupCreate(s *state.State, args db.ContainerBackupArgs, sourceContainer Instance) error {
+func backupCreate(s *state.State, args db.InstanceBackupArgs, sourceContainer Instance) error {
 	// Create the database entry
 	err := s.Cluster.ContainerBackupCreate(args)
 	if err != nil {
diff --git a/lxd/container_backup.go b/lxd/container_backup.go
index 01a3e8f7b2..bdc1186ed0 100644
--- a/lxd/container_backup.go
+++ b/lxd/container_backup.go
@@ -157,9 +157,9 @@ func containerBackupsPost(d *Daemon, r *http.Request) response.Response {
 	instanceOnly := req.InstanceOnly || req.ContainerOnly
 
 	backup := func(op *operation) error {
-		args := db.ContainerBackupArgs{
+		args := db.InstanceBackupArgs{
 			Name:             fullName,
-			ContainerID:      c.Id(),
+			InstanceID:       c.Id(),
 			CreationDate:     time.Now(),
 			ExpiryDate:       req.ExpiresAt,
 			InstanceOnly:     instanceOnly,
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 41f7d850b0..c1f18ac702 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -1159,8 +1159,8 @@ func (c *Cluster) ContainerBackupID(name string) (int, error) {
 }
 
 // ContainerGetBackup returns the backup with the given name.
-func (c *Cluster) ContainerGetBackup(project, name string) (ContainerBackupArgs, error) {
-	args := ContainerBackupArgs{}
+func (c *Cluster) ContainerGetBackup(project, name string) (InstanceBackupArgs, error) {
+	args := InstanceBackupArgs{}
 	args.Name = name
 
 	instanceOnlyInt := -1
@@ -1175,7 +1175,7 @@ SELECT instances_backups.id, instances_backups.instance_id,
     WHERE projects.name=? AND instances_backups.name=?
 `
 	arg1 := []interface{}{project, name}
-	arg2 := []interface{}{&args.ID, &args.ContainerID, &args.CreationDate,
+	arg2 := []interface{}{&args.ID, &args.InstanceID, &args.CreationDate,
 		&args.ExpiryDate, &instanceOnlyInt, &optimizedStorageInt}
 	err := dbQueryRowScan(c.db, q, arg1, arg2)
 	if err != nil {
@@ -1221,7 +1221,7 @@ WHERE projects.name=? AND instances.name=?`
 }
 
 // ContainerBackupCreate creates a new backup
-func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
+func (c *Cluster) ContainerBackupCreate(args InstanceBackupArgs) error {
 	_, err := c.ContainerBackupID(args.Name)
 	if err == nil {
 		return ErrAlreadyDefined
@@ -1244,7 +1244,7 @@ func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
 			return err
 		}
 		defer stmt.Close()
-		result, err := stmt.Exec(args.ContainerID, args.Name,
+		result, err := stmt.Exec(args.InstanceID, args.Name,
 			args.CreationDate.Unix(), args.ExpiryDate.Unix(), instanceOnlyInt,
 			optimizedStorageInt)
 		if err != nil {


More information about the lxc-devel mailing list