Skip to content

Commit

Permalink
Improve API
Browse files Browse the repository at this point in the history
- REST API URI for Marathon ID does not require encoding
- Fix UI related API changes
- Fix Napa angular reference
  • Loading branch information
j1n6 committed Apr 18, 2015
1 parent f0b7e3c commit 2c2370b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"napa": {
"angular-strap": "mgcrea/angular-strap#v2.0.5",
"angular": "angular/bower-angular#v1.2.22-build.376+sha.93b0c2d",
"angular": "angular/bower-angular#v1.2.22",
"angular-animate": "angular/bower-angular-animate#v1.2.22-build.376+sha.93b0c2d",
"angular-resource": "angular/bower-angular-resource#v1.2.22-build.376+sha.93b0c2d",
"angular-ui-router": "angular-ui/ui-router#0.2.10"
Expand Down
2 changes: 1 addition & 1 deletion services/event_bus/event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func handleHAPUpdate(conf *configuration.Configuration, conn *zk.Conn) bool {

err = execCommand(conf.HAProxy.ReloadCommand)
if err != nil {
log.Println("HAProxy: update failed\n")
log.Fatalf("HAProxy: update failed\n")
} else {
conf.StatsD.Increment(1.0, "reload.marathon", 1)
log.Println("HAProxy: Configuration updated")
Expand Down
16 changes: 12 additions & 4 deletions services/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package service

import (
"net/url"

"strings"
"github.com/QubitProducts/bamboo/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk"
conf "github.com/QubitProducts/bamboo/configuration"
)
Expand Down Expand Up @@ -43,7 +43,7 @@ func All(conn *zk.Conn, zkConf conf.Zookeeper) (map[string]Service, error) {
http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#sc_ACLPermissions
*/
func Create(conn *zk.Conn, zkConf conf.Zookeeper, appId string, domainValue string) (string, error) {
path := concatPath(zkConf.Path, appId)
path := concatPath(zkConf.Path, validateAppId(appId))
resPath, err := conn.Create(path, []byte(domainValue), 0, defaultACL())
if err != nil {
return "", err
Expand All @@ -53,7 +53,7 @@ func Create(conn *zk.Conn, zkConf conf.Zookeeper, appId string, domainValue stri
}

func Put(conn *zk.Conn, zkConf conf.Zookeeper, appId string, domainValue string) (*zk.Stat, error) {
path := concatPath(zkConf.Path, appId)
path := concatPath(zkConf.Path, validateAppId(appId))
err := ensurePathExists(conn, path)
if err != nil {
return nil, err
Expand All @@ -71,7 +71,7 @@ func Put(conn *zk.Conn, zkConf conf.Zookeeper, appId string, domainValue string)
}

func Delete(conn *zk.Conn, zkConf conf.Zookeeper, appId string) error {
path := concatPath(zkConf.Path, appId)
path := concatPath(zkConf.Path, validateAppId(appId))
return conn.Delete(path, -1)
}

Expand All @@ -97,6 +97,14 @@ func defaultACL() []zk.ACL {
return []zk.ACL{zk.ACL{Perms: zk.PermAll, Scheme: "world", ID: "anyone"}}
}

func validateAppId(appId string) string {
if strings.HasPrefix(appId, "/") {
return appId
} else {
return "/" + appId
}
}

func escapeSlashes(id string) string {
return url.QueryEscape(id)
}
Expand Down
11 changes: 3 additions & 8 deletions webapp/app/components/resources/service-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ module.exports = ["$resource", function ($resource) {
destroy: { method: "DELETE", params: { id: "@id"} }
});

var encodeId = function (params) {
params.id = encodeURIComponent(params.id);
return params;
};

return {
all: function () {
return index.get().$promise;
Expand All @@ -24,13 +19,13 @@ module.exports = ["$resource", function ($resource) {
create: function (params) {
return index.create(params).$promise;
},

update: function (params) {
return entity.update(encodeId(params)).$promise;
return entity.update(params).$promise;
},

destroy: function (params) {
return entity.destroy(encodeId(params)).$promise;
return entity.destroy(params).$promise;
}
}
}];
8 changes: 4 additions & 4 deletions webapp/dist/main-app.js

Large diffs are not rendered by default.

0 comments on commit 2c2370b

Please sign in to comment.