-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4275 from Kong/feat/core-entity-tags
feat(core) implement entity tagging
- Loading branch information
Showing
35 changed files
with
1,984 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
local endpoints = require "kong.api.endpoints" | ||
|
||
local fmt = string.format | ||
local escape_uri = ngx.escape_uri | ||
|
||
|
||
return { | ||
["/tags/:tags"] = { | ||
GET = function(self, db, helpers, parent) | ||
local data, _, err_t, offset = | ||
endpoints.page_collection(self, db, db.tags.schema, "page_by_tag") | ||
|
||
if err_t then | ||
return endpoints.handle_error(err_t) | ||
end | ||
|
||
local next_page | ||
if offset then | ||
next_page = fmt("/tags/%s?offset=%s", self.params.tags, escape_uri(offset)) | ||
|
||
else | ||
next_page = ngx.null | ||
end | ||
|
||
return kong.response.exit(200, { | ||
data = data, | ||
offset = offset, | ||
next = next_page, | ||
}) | ||
end, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local Tags = {} | ||
|
||
function Tags:page_by_tag(tag, size, offset, options) | ||
local ok, err = self.schema:validate_field(self.schema.fields.tag, tag) | ||
if not ok then | ||
local err_t = self.errors:invalid_unique('tag', err) | ||
return nil, tostring(err_t), err_t | ||
end | ||
|
||
local rows, err_t, offset = self.strategy:page_by_tag(tag, size or 100, offset, options) | ||
if err_t then | ||
return rows, tostring(err_t), err_t | ||
end | ||
return rows, nil, nil, offset | ||
end | ||
|
||
local function noop(self, ...) | ||
local err_t = self.errors:schema_violation({ tags = 'does not support insert/upsert/update/delete operations' }) | ||
return nil, tostring(err_t), err_t | ||
end | ||
|
||
Tags.insert = noop | ||
Tags.delete = noop | ||
Tags.update = noop | ||
Tags.upsert = noop | ||
|
||
return Tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ local CORE_ENTITIES = { | |
"targets", | ||
"plugins", | ||
"cluster_ca", | ||
"tags", | ||
} | ||
|
||
|
||
|
Oops, something went wrong.