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

Ustin/reducing config download size #459

Closed
wants to merge 5 commits into from

Conversation

dselans
Copy link
Contributor

@dselans dselans commented May 22, 2024

No description provided.

@dselans
Copy link
Contributor Author

dselans commented May 22, 2024

Two things:

  1. Need to remove elements that have integer set to 0 - and also if the object above is empty as a result of 0 removal - remove the parent object as well. For example, this is the resulting configs on my machine (using your branch):
{
  "audiences": [
    {
      "serviceName": "dedupe-svc",
      "componentName": "logs",
      "operationType": 2,
      "operationName": "processor"
    },
    {
      "serviceName": "memory-svc",
      "componentName": "logs",
      "operationType": 2,
      "operationName": "processor"
    }
  ],
  "pipelines": [
    {
      "id": "b414d483-7b84-45b7-abfd-545915c97745",
      "name": "Conditional: Inject Metadata if Field Empty",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 1000,
              "path": "emptyField"
            }
          },
          "onTrue": {
            "abort": 0,
            "metadata": {
              "fieldIsEmpty": "true"
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "6e886878-7368-4769-8e74-81008104e952",
      "name": "Basic: Mask Field Value",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 4,
              "options": {
                "oneofKind": "maskOptions",
                "maskOptions": {
                  "path": "object"
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "baa3869a-0579-4e4d-b2f7-04747469dc2d",
      "name": "Basic: Find & Replace",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 1,
              "options": {
                "oneofKind": "replaceValueOptions",
                "replaceValueOptions": {
                  "path": "product.id",
                  "value": "\"---REPLACED---\""
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "32847f22-46b5-49d2-834b-5fc799d157e1",
      "name": "test",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 2037
            }
          },
          "onFalse": {
            "abort": 1
          }
        },
        {
          "name": "Step #2",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 4
            }
          }
        }
      ],
      "dataFormat": 2,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "91fce4a0-0045-43af-9da3-7a9879f7f3c4",
      "name": "PII: Detect in JSON and Inject Metadata",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 2036,
              "piiKeywordMode": 0
            }
          },
          "onTrue": {
            "abort": 0,
            "metadata": {
              "found_pii": "true"
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "16dc37c0-6841-4c09-af6f-65015eee4826",
      "name": "PII: Detect & Mask in JSON",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 2036,
              "piiKeywordMode": 2
            }
          },
          "onFalse": {
            "abort": 1
          }
        },
        {
          "name": "Step #2",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 4
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "fbf62af9-69d7-45e6-9362-eaa7637ba570",
      "name": "Basic: Truncate Large Field",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 5,
              "options": {
                "oneofKind": "truncateOptions",
                "truncateOptions": {
                  "type": 1,
                  "path": "largeField",
                  "value": 40
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "cccafbe7-2cb8-49d7-a683-c3025cc9497a",
      "name": "Basic: Delete Field",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 2,
              "options": {
                "oneofKind": "deleteFieldOptions",
                "deleteFieldOptions": {
                  "paths": [
                    "product_name"
                  ]
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "880b46ac-afc4-4c24-a983-33560b3dd5ab",
      "name": "PII: Detect & Mask in Plaintext",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 2037
            }
          },
          "onTrue": {
            "abort": 0
          },
          "onFalse": {
            "abort": 1
          },
          "onError": {
            "abort": 0
          }
        },
        {
          "name": "Step #2",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 4,
              "options": {
                "oneofKind": "maskOptions"
              }
            }
          },
          "onTrue": {
            "abort": 0
          },
          "onFalse": {
            "abort": 0
          },
          "onError": {
            "abort": 0
          }
        }
      ],
      "dataFormat": 2,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "29992c6a-90eb-4198-af7e-7bdb177ff654",
      "name": "Conditional: Mask Value if Fields exist",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "type": 1001,
              "path": "object.path"
            }
          },
          "onFalse": {
            "abort": 1
          }
        },
        {
          "name": "Step #2",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 4,
              "options": {
                "oneofKind": "maskOptions",
                "maskOptions": {
                  "path": "object.path"
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "e69e886a-0666-41a6-9156-f5564be4e475",
      "name": "Basic: Obfuscate Field Value",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 3,
              "options": {
                "oneofKind": "obfuscateOptions",
                "obfuscateOptions": {
                  "path": "obfuscatedField"
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "44df4060-562f-4451-bee0-4df663df0f6b",
      "name": "Basic: Extract Field",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 6,
              "options": {
                "oneofKind": "extractOptions",
                "extractOptions": {
                  "paths": [
                    "person.id"
                  ]
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    },
    {
      "id": "4e8971f6-9be8-4989-9fc5-bbc2ddcd650f",
      "name": "Conditional: Replace Value if Contains String",
      "steps": [
        {
          "name": "Step #1",
          "step": {
            "oneofKind": "detective",
            "detective": {
              "args": [
                "foo"
              ],
              "type": 1003,
              "path": "object.replaceString"
            }
          },
          "onFalse": {
            "abort": 1
          }
        },
        {
          "name": "Step #2",
          "step": {
            "oneofKind": "transform",
            "transform": {
              "type": 1,
              "options": {
                "oneofKind": "replaceValueOptions",
                "replaceValueOptions": {
                  "path": "object.replaceString",
                  "value": "\"REPLACED-IF-STRING-CONTAINS\""
                }
              }
            }
          }
        }
      ],
      "dataFormat": 1,
      "CreatedBy": "streamdal-operator"
    }
  ],
  "notifications": [
    {
      "name": "Test slack Integration",
      "type": 1,
      "config": {
        "oneofKind": "slack",
        "slack": {
          "botToken": "test-token",
          "channel": "test-channel"
        }
      },
      "id": "c746e19d-171c-4521-9a2d-bb456624acaa-1",
      "CreatedBy": "streamdal-operator"
    }
  ],
  "wasmModules": [
    {
      "id": "c9d93a17-a75d-f958-78e1-82e2d882d471",
      "function": "f",
      "name": "httprequest",
      "Filename": "httprequest.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617796244171"
    },
    {
      "id": "6986c608-2edc-ac1e-205a-92b9392a169c",
      "function": "f",
      "name": "kv",
      "Filename": "kv.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617797271463"
    },
    {
      "id": "c94679b4-2f72-36ca-2151-3cc5bd96e2a3",
      "function": "f",
      "name": "inferschema",
      "Filename": "inferschema.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617778243713"
    },
    {
      "id": "2255cc88-2632-832f-8f98-63516cfadbf2",
      "function": "f",
      "name": "schemavalidation",
      "Filename": "schemavalidation.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617781285796"
    },
    {
      "id": "5b619f6e-3850-2c04-a600-b385565a6a48",
      "function": "f",
      "name": "validjson",
      "Filename": "validjson.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617779909588"
    },
    {
      "id": "9d2a2b90-13e7-a26f-2b4c-9f5eed70777b",
      "function": "f",
      "name": "transform",
      "Filename": "transform.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617795303921"
    },
    {
      "id": "946b1613-8e7b-df9d-f317-286a1ca537d3",
      "function": "f",
      "name": "detective",
      "Filename": "detective.wasm",
      "description": "Bundled Wasm module",
      "url": "https://github.com/streamdal/streamdal/tree/main/libs/wasm",
      "CreatedAtUnixTsNsUtc": "1716328617786579296"
    }
  ],
  "audienceMappings": {
    "dedupe-svc:operation_type_producer:processor:logs": {
      "configs": [
        {
          "id": "880b46ac-afc4-4c24-a983-33560b3dd5ab",
          "createdAtUnixTsUtc": "1716332240"
        }
      ]
    },
    "memory-svc:operation_type_producer:processor:logs": {
      "configs": [
        {
          "id": "880b46ac-afc4-4c24-a983-33560b3dd5ab",
          "createdAtUnixTsUtc": "1716329457"
        }
      ]
    }
  }
}

In this, the onTrue.abort is 0 - should be removed.

Also, PII: Detect & Mask in Plaintext has an onTrue condition with abort set to 0 - the abort should be removed and because that is removed, the entire onTrue{} block should be removed as well.

  1. Fix lint

Other then that, it looks great and very clean!

@dselans
Copy link
Contributor Author

dselans commented May 22, 2024

cc @uzarubin

@dselans dselans closed this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants