The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5698

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From 9fa2d7dba6e17e39ae7e04a54137424f43d3aaa6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 24 Apr 2019 16:49:08 -0400
Subject: [PATCH 1/3] lxd/api: Rename alias* commands to imageAlias*
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/api_1.0.go |  4 ++--
 lxd/images.go  | 32 ++++++++++++++++----------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index 7390ddf5c1..2d0163833c 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -30,8 +30,6 @@ var api10Cmd = Command{
 }
 
 var api10 = []Command{
-       aliasCmd,
-       aliasesCmd,
        api10Cmd,
        api10ResourcesCmd,
        certificateFingerprintCmd,
@@ -55,6 +53,8 @@ var api10 = []Command{
        containerSnapshotsCmd,
        containerStateCmd,
        eventsCmd,
+       imageAliasCmd,
+       imageAliasesCmd,
        imageCmd,
        imageExportCmd,
        imageRefreshCmd,
diff --git a/lxd/images.go b/lxd/images.go
index bdd29c9583..746904a49b 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -74,20 +74,20 @@ var imageRefreshCmd = Command{
        post: imageRefresh,
 }
 
-var aliasesCmd = Command{
+var imageAliasesCmd = Command{
        name: "images/aliases",
-       post: aliasesPost,
-       get:  aliasesGet,
+       post: imageAliasesPost,
+       get:  imageAliasesGet,
 }
 
-var aliasCmd = Command{
+var imageAliasCmd = Command{
        name:         "images/aliases/{name:.*}",
        untrustedGet: true,
-       get:          aliasGet,
-       delete:       aliasDelete,
-       put:          aliasPut,
-       post:         aliasPost,
-       patch:        aliasPatch,
+       get:          imageAliasGet,
+       delete:       imageAliasDelete,
+       put:          imageAliasPut,
+       post:         imageAliasPost,
+       patch:        imageAliasPatch,
 }
 
 /* We only want a single publish running at any one time.
@@ -1596,7 +1596,7 @@ func imagePatch(d *Daemon, r *http.Request) Response {
        return EmptySyncResponse
 }
 
-func aliasesPost(d *Daemon, r *http.Request) Response {
+func imageAliasesPost(d *Daemon, r *http.Request) Response {
        project := projectParam(r)
        req := api.ImageAliasesPost{}
        if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
@@ -1630,7 +1630,7 @@ func aliasesPost(d *Daemon, r *http.Request) Response {
        return SyncResponseLocation(true, nil, 
fmt.Sprintf("/%s/images/aliases/%s", version.APIVersion, req.Name))
 }
 
-func aliasesGet(d *Daemon, r *http.Request) Response {
+func imageAliasesGet(d *Daemon, r *http.Request) Response {
        project := projectParam(r)
        recursion := util.IsRecursionRequest(r)
 
@@ -1661,7 +1661,7 @@ func aliasesGet(d *Daemon, r *http.Request) Response {
        return SyncResponse(true, responseMap)
 }
 
-func aliasGet(d *Daemon, r *http.Request) Response {
+func imageAliasGet(d *Daemon, r *http.Request) Response {
        project := projectParam(r)
        name := mux.Vars(r)["name"]
 
@@ -1673,7 +1673,7 @@ func aliasGet(d *Daemon, r *http.Request) Response {
        return SyncResponseETag(true, alias, alias)
 }
 
-func aliasDelete(d *Daemon, r *http.Request) Response {
+func imageAliasDelete(d *Daemon, r *http.Request) Response {
        project := projectParam(r)
        name := mux.Vars(r)["name"]
        _, _, err := d.cluster.ImageAliasGet(project, name, true)
@@ -1689,7 +1689,7 @@ func aliasDelete(d *Daemon, r *http.Request) Response {
        return EmptySyncResponse
 }
 
-func aliasPut(d *Daemon, r *http.Request) Response {
+func imageAliasPut(d *Daemon, r *http.Request) Response {
        // Get current value
        project := projectParam(r)
        name := mux.Vars(r)["name"]
@@ -1726,7 +1726,7 @@ func aliasPut(d *Daemon, r *http.Request) Response {
        return EmptySyncResponse
 }
 
-func aliasPatch(d *Daemon, r *http.Request) Response {
+func imageAliasPatch(d *Daemon, r *http.Request) Response {
        // Get current value
        project := projectParam(r)
        name := mux.Vars(r)["name"]
@@ -1779,7 +1779,7 @@ func aliasPatch(d *Daemon, r *http.Request) Response {
        return EmptySyncResponse
 }
 
-func aliasPost(d *Daemon, r *http.Request) Response {
+func imageAliasPost(d *Daemon, r *http.Request) Response {
        project := projectParam(r)
        name := mux.Vars(r)["name"]
 

From 11fda24b1e308baec75df8139547fa6ca2781e17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 24 Apr 2019 16:51:40 -0400
Subject: [PATCH 2/3] lxd/api: Rename certificateFingerprint* to certficate*
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/api_1.0.go      |  2 +-
 lxd/certificates.go | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index 2d0163833c..056d60d5b7 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -32,7 +32,7 @@ var api10Cmd = Command{
 var api10 = []Command{
        api10Cmd,
        api10ResourcesCmd,
-       certificateFingerprintCmd,
+       certificateCmd,
        certificatesCmd,
        clusterCmd,
        clusterNodeCmd,
diff --git a/lxd/certificates.go b/lxd/certificates.go
index 2e4e190ef3..8c0b8bcc2b 100644
--- a/lxd/certificates.go
+++ b/lxd/certificates.go
@@ -31,12 +31,12 @@ var certificatesCmd = Command{
        post:          certificatesPost,
 }
 
-var certificateFingerprintCmd = Command{
+var certificateCmd = Command{
        name:   "certificates/{fingerprint}",
-       get:    certificateFingerprintGet,
-       delete: certificateFingerprintDelete,
-       put:    certificateFingerprintPut,
-       patch:  certificateFingerprintPatch,
+       get:    certificateGet,
+       delete: certificateDelete,
+       put:    certificatePut,
+       patch:  certificatePatch,
 }
 
 func certificatesGet(d *Daemon, r *http.Request) Response {
@@ -211,7 +211,7 @@ func certificatesPost(d *Daemon, r *http.Request) Response {
        return SyncResponseLocation(true, nil, 
fmt.Sprintf("/%s/certificates/%s", version.APIVersion, fingerprint))
 }
 
-func certificateFingerprintGet(d *Daemon, r *http.Request) Response {
+func certificateGet(d *Daemon, r *http.Request) Response {
        fingerprint := mux.Vars(r)["fingerprint"]
 
        cert, err := doCertificateGet(d.cluster, fingerprint)
@@ -242,7 +242,7 @@ func doCertificateGet(db *db.Cluster, fingerprint string) 
(api.Certificate, erro
        return resp, nil
 }
 
-func certificateFingerprintPut(d *Daemon, r *http.Request) Response {
+func certificatePut(d *Daemon, r *http.Request) Response {
        fingerprint := mux.Vars(r)["fingerprint"]
 
        oldEntry, err := doCertificateGet(d.cluster, fingerprint)
@@ -264,7 +264,7 @@ func certificateFingerprintPut(d *Daemon, r *http.Request) 
Response {
        return doCertificateUpdate(d, fingerprint, req)
 }
 
-func certificateFingerprintPatch(d *Daemon, r *http.Request) Response {
+func certificatePatch(d *Daemon, r *http.Request) Response {
        fingerprint := mux.Vars(r)["fingerprint"]
 
        oldEntry, err := doCertificateGet(d.cluster, fingerprint)
@@ -312,7 +312,7 @@ func doCertificateUpdate(d *Daemon, fingerprint string, req 
api.CertificatePut)
        return EmptySyncResponse
 }
 
-func certificateFingerprintDelete(d *Daemon, r *http.Request) Response {
+func certificateDelete(d *Daemon, r *http.Request) Response {
        fingerprint := mux.Vars(r)["fingerprint"]
 
        certInfo, err := d.cluster.CertificateGet(fingerprint)

From 494038f96e6c9f8a63ff8e1458364b01fa7db4f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 24 Apr 2019 16:55:06 -0400
Subject: [PATCH 3/3] lxd/api: Rename apiProject* to project*
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/api_project.go | 48 +++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/lxd/api_project.go b/lxd/api_project.go
index 0ae5a7fe17..814a021d51 100644
--- a/lxd/api_project.go
+++ b/lxd/api_project.go
@@ -21,20 +21,20 @@ import (
 
 var projectsCmd = Command{
        name: "projects",
-       get:  apiProjectsGet,
-       post: apiProjectsPost,
+       get:  projectsGet,
+       post: projectsPost,
 }
 
 var projectCmd = Command{
        name:   "projects/{name}",
-       get:    apiProjectGet,
-       post:   apiProjectPost,
-       put:    apiProjectPut,
-       patch:  apiProjectPatch,
-       delete: apiProjectDelete,
+       get:    projectGet,
+       post:   projectPost,
+       put:    projectPut,
+       patch:  projectPatch,
+       delete: projectDelete,
 }
 
-func apiProjectsGet(d *Daemon, r *http.Request) Response {
+func projectsGet(d *Daemon, r *http.Request) Response {
        recursion := util.IsRecursionRequest(r)
 
        var result interface{}
@@ -55,7 +55,7 @@ func apiProjectsGet(d *Daemon, r *http.Request) Response {
        return SyncResponse(true, result)
 }
 
-func apiProjectsPost(d *Daemon, r *http.Request) Response {
+func projectsPost(d *Daemon, r *http.Request) Response {
        // Parse the request
        project := api.ProjectsPost{}
 
@@ -105,7 +105,7 @@ func apiProjectsPost(d *Daemon, r *http.Request) Response {
                }
 
                if project.Config["features.profiles"] == "true" {
-                       err = apiProjectCreateDefaultProfile(tx, project.Name)
+                       err = projectCreateDefaultProfile(tx, project.Name)
                        if err != nil {
                                return err
                        }
@@ -121,7 +121,7 @@ func apiProjectsPost(d *Daemon, r *http.Request) Response {
 }
 
 // Create the default profile of a project.
-func apiProjectCreateDefaultProfile(tx *db.ClusterTx, project string) error {
+func projectCreateDefaultProfile(tx *db.ClusterTx, project string) error {
        // Create a default profile
        profile := db.Profile{}
        profile.Project = project
@@ -137,7 +137,7 @@ func apiProjectCreateDefaultProfile(tx *db.ClusterTx, 
project string) error {
        return nil
 }
 
-func apiProjectGet(d *Daemon, r *http.Request) Response {
+func projectGet(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
        // Get the database entry
@@ -160,7 +160,7 @@ func apiProjectGet(d *Daemon, r *http.Request) Response {
        return SyncResponseETag(true, project, etag)
 }
 
-func apiProjectPut(d *Daemon, r *http.Request) Response {
+func projectPut(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
        // Get the current data
@@ -193,10 +193,10 @@ func apiProjectPut(d *Daemon, r *http.Request) Response {
                return BadRequest(err)
        }
 
-       return apiProjectChange(d, project, req)
+       return projectChange(d, project, req)
 }
 
-func apiProjectPatch(d *Daemon, r *http.Request) Response {
+func projectPatch(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
        // Get the current data
@@ -255,11 +255,11 @@ func apiProjectPatch(d *Daemon, r *http.Request) Response 
{
                req.Config["features.images"] = 
project.Config["features.profiles"]
        }
 
-       return apiProjectChange(d, project, req)
+       return projectChange(d, project, req)
 }
 
 // Common logic between PUT and PATCH.
-func apiProjectChange(d *Daemon, project *api.Project, req api.ProjectPut) 
Response {
+func projectChange(d *Daemon, project *api.Project, req api.ProjectPut) 
Response {
        // Flag indicating if any feature has changed.
        featuresChanged := req.Config["features.images"] != 
project.Config["features.images"] || req.Config["features.profiles"] != 
project.Config["features.profiles"]
 
@@ -268,7 +268,7 @@ func apiProjectChange(d *Daemon, project *api.Project, req 
api.ProjectPut) Respo
                return BadRequest(fmt.Errorf("You can't change the features of 
the default project"))
        }
 
-       if !apiProjectIsEmpty(project) && featuresChanged {
+       if !projectIsEmpty(project) && featuresChanged {
                return BadRequest(fmt.Errorf("Features can only be changed on 
empty projects"))
        }
 
@@ -287,7 +287,7 @@ func apiProjectChange(d *Daemon, project *api.Project, req 
api.ProjectPut) Respo
 
                if req.Config["features.profiles"] != 
project.Config["features.profiles"] {
                        if req.Config["features.profiles"] == "true" {
-                               err = apiProjectCreateDefaultProfile(tx, 
project.Name)
+                               err = projectCreateDefaultProfile(tx, 
project.Name)
                                if err != nil {
                                        return err
                                }
@@ -311,7 +311,7 @@ func apiProjectChange(d *Daemon, project *api.Project, req 
api.ProjectPut) Respo
        return EmptySyncResponse
 }
 
-func apiProjectPost(d *Daemon, r *http.Request) Response {
+func projectPost(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
        // Parse the request
@@ -344,7 +344,7 @@ func apiProjectPost(d *Daemon, r *http.Request) Response {
                                return errors.Wrapf(err, "Fetch project %q", 
name)
                        }
 
-                       if !apiProjectIsEmpty(project) {
+                       if !projectIsEmpty(project) {
                                return fmt.Errorf("Only empty projects can be 
renamed")
                        }
 
@@ -362,7 +362,7 @@ func apiProjectPost(d *Daemon, r *http.Request) Response {
        return OperationResponse(op)
 }
 
-func apiProjectDelete(d *Daemon, r *http.Request) Response {
+func projectDelete(d *Daemon, r *http.Request) Response {
        name := mux.Vars(r)["name"]
 
        // Sanity checks
@@ -375,7 +375,7 @@ func apiProjectDelete(d *Daemon, r *http.Request) Response {
                if err != nil {
                        return errors.Wrapf(err, "Fetch project %q", name)
                }
-               if !apiProjectIsEmpty(project) {
+               if !projectIsEmpty(project) {
                        return fmt.Errorf("Only empty projects can be removed")
                }
 
@@ -390,7 +390,7 @@ func apiProjectDelete(d *Daemon, r *http.Request) Response {
 }
 
 // Check if a project is empty.
-func apiProjectIsEmpty(project *api.Project) bool {
+func projectIsEmpty(project *api.Project) bool {
        if len(project.UsedBy) > 0 {
                // Check if the only entity is the default profile.
                if len(project.UsedBy) == 1 && 
strings.Contains(project.UsedBy[0], "/profiles/default") {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to