New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SCB-1398] add project in uri path, modify related api to support the change #25
Conversation
client/client.go
Outdated
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, APIPathKV, kv.Key) | ||
func (c *Client) Put(ctx context.Context, kv model.KVDoc, project string) (*model.KVDoc, error) { | ||
finalPath := fmt.Sprintf("%s/%s/%s", version, project, APIPathKV) | ||
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, finalPath, kv.Key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Sprintf is graceful, but it has poor performance, never use it in func that handles a lots of data
1. add project field in KVDoc and LabelDoc, add the param for project in backend api 2. all related mongo CRUD should add filter for project
client/client.go
Outdated
@@ -81,8 +82,9 @@ func New(config Config) (*Client, error) { | |||
} | |||
|
|||
//Put create value of a key | |||
func (c *Client) Put(ctx context.Context, kv model.KVDoc) (*model.KVDoc, error) { | |||
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, APIPathKV, kv.Key) | |||
func (c *Client) Put(ctx context.Context, kv model.KVDoc, project string) (*model.KVDoc, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project is an option, default value is "default"
client/client.go
Outdated
@@ -113,12 +115,13 @@ func (c *Client) Put(ctx context.Context, kv model.KVDoc) (*model.KVDoc, error) | |||
} | |||
|
|||
//Get get value of a key | |||
func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*model.KVDoc, error) { | |||
func (c *Client) Get(ctx context.Context, key string, project string, opts ...GetOption) ([]*model.KVDoc, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project is an option, default value is "default"
client/client.go
Outdated
@@ -147,8 +150,9 @@ func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*mod | |||
} | |||
|
|||
//Delete remove kv | |||
func (c *Client) Delete(ctx context.Context, kvID, labelID string) error { | |||
url := fmt.Sprintf("%s/%s/?kvID=%s", c.opts.Endpoint, APIPathKV, kvID) | |||
func (c *Client) Delete(ctx context.Context, kvID, labelID string, project string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project is an delete option, default value is "default"
client/client.go
Outdated
@@ -35,7 +35,7 @@ import ( | |||
|
|||
//const | |||
const ( | |||
APIPathKV = "v1/kv" | |||
APIPathKV = "v1/test/kie/kv" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test is dead code
31a4a60
to
03a9dbc
Compare
@@ -70,6 +71,11 @@ func (r *KVResource) GetByKey(context *restful.Context) { | |||
WriteErrResponse(context, http.StatusForbidden, "key must not be empty", common.ContentTypeText) | |||
return | |||
} | |||
project := context.ReadPathParameter("project") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you read it twice
[SCB-1398]