Skip to content
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

fix(connect): only dedupe protocol tags on matching name AND value #1059 #1060

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions connect/src/lib/message/upload-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ function buildTagsWith () {
return of(ctx.tags)
.map(defaultTo([]))
.map(removeTagsByNameMaybeValue('Data-Protocol', 'ao'))
.map(removeTagsByNameMaybeValue('Variant'))
.map(removeTagsByNameMaybeValue('Type'))
.map(removeTagsByNameMaybeValue('SDK'))
.map(removeTagsByNameMaybeValue('Variant', 'ao.TN.1'))
.map(removeTagsByNameMaybeValue('Type', 'Message'))
.map(removeTagsByNameMaybeValue('SDK', 'aoconnect'))
.map(concat(__, [
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' },
Expand Down
6 changes: 6 additions & 0 deletions connect/src/lib/message/upload-message.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('upload-message', () => {
assert.ok(data)
assert.equal(processId, 'process-asdf')
assert.deepStrictEqual(tags, [
{ name: 'Data-Protocol', value: 'zone' },
{ name: 'Type', value: 'Profile' },
{ name: 'Variant', value: 'ao.TN.Foo' },
{ name: 'foo', value: 'bar' },
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' },
Expand All @@ -32,6 +35,9 @@ describe('upload-message', () => {
id: 'process-asdf',
signer: () => {},
tags: [
{ name: 'Data-Protocol', value: 'zone' },
{ name: 'Type', value: 'Profile' },
{ name: 'Variant', value: 'ao.TN.Foo' },
{ name: 'foo', value: 'bar' },
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' }
Expand Down
6 changes: 3 additions & 3 deletions connect/src/lib/spawn/upload-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ function buildTagsWith () {
.map(prop('tags'))
.map(defaultTo([]))
.map(removeTagsByNameMaybeValue('Data-Protocol', 'ao'))
.map(removeTagsByNameMaybeValue('Variant'))
.map(removeTagsByNameMaybeValue('Type'))
.map(removeTagsByNameMaybeValue('Variant', 'ao.TN.1'))
.map(removeTagsByNameMaybeValue('Type', 'Message'))
.map(removeTagsByNameMaybeValue('Module'))
.map(removeTagsByNameMaybeValue('Scheduler'))
.map(removeTagsByNameMaybeValue('SDK'))
.map(removeTagsByNameMaybeValue('SDK', 'aoconnect'))
.map(concat(__, [
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' },
Expand Down
6 changes: 6 additions & 0 deletions connect/src/lib/spawn/upload-process.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ describe('upload-process', () => {
deployProcess: async ({ data, tags, signer }) => {
assert.ok(data)
assert.deepStrictEqual(tags, [
{ name: 'Data-Protocol', value: 'zone' },
{ name: 'Type', value: 'Profile' },
{ name: 'Variant', value: 'ao.TN.Foo' },
{ name: 'foo', value: 'bar' },
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' },
Expand Down Expand Up @@ -40,6 +43,9 @@ describe('upload-process', () => {
module: 'module-id-123',
scheduler: 'zVkjFCALjk4xxuCilddKS8ShZ-9HdeqeuYQOgMgWucro',
tags: [
{ name: 'Data-Protocol', value: 'zone' },
{ name: 'Type', value: 'Profile' },
{ name: 'Variant', value: 'ao.TN.Foo' },
{ name: 'foo', value: 'bar' },
{ name: 'Data-Protocol', value: 'ao' },
{ name: 'Variant', value: 'ao.TN.1' }
Expand Down
12 changes: 8 additions & 4 deletions connect/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,19 @@ export function parseTags (rawTags) {
* then only remove tags whose both name and value matches.
*
* @param {string} name - the name of the tags to be removed
* @param {string} [value] - the value of the tags to be removed
* @param {string} [valueOrPred] - the value of the tags to be removed
* OR a predicate function to apply to the value
*/
export function removeTagsByNameMaybeValue (name, value) {
export function removeTagsByNameMaybeValue (name, valueOrPred) {
return (tags) => reject(
allPass([
propEq(name, 'name'),
ifElse(
always(value),
propEq(value, 'value'),
always(valueOrPred),
(tag) => {
if (typeof valueOrPred === 'function') return valueOrPred(tag.value)
return tag.value === valueOrPred
},
T
)
]),
Expand Down