rtyler / otto

Otto is your friendly continuous delivery companion.
GNU Affero General Public License v3.0
80 stars 5 forks source link

Steps with positional parameters not properly round-tripping through de/serialization #42

Closed rtyler closed 3 years ago

rtyler commented 3 years ago

The following invocation file works just fine for otto-agent

{
    "pipeline": "2265b5d0-1f70-46de-bf50-f1050e9fac9a",
    "steps" : [
        {
            "symbol":  "sh",
            "uuid": "5599cffb-f23a-4e0f-a0b9-f74654641b2b",
            "context": "3ce1f6fb-79ca-4564-a47e-98265f53ef7f",
            "parameters" : {
                "script" : "pwd"
            }
        }
    ]
}

This one however does not.

{"pipeline":"fdbebdcf-ad5c-49e5-890f-aef294b476c5","steps":[{"uuid":"f619073f-4129-4d30-a94f-f61af164a6d8","context":"fdbebdcf-ad5c-49e5-890f-aef294b476c5","symbol":"sh","parameters":["pwd"]}]}

The either/or deserialization just doesn't appear to be working properly.

StepStart { symbol: "sh", uuid: f619073f-4129-4d30-a94f-f61af164a6d8 }
StepOutput { symbol: "sh", uuid: f619073f-4129-4d30-a94f-f61af164a6d8, buffer: "thread \'main\' panicked at \'called `Result::unwrap()` on an `Err` value: Custom { kind: InvalidData, error: Error(\"invalid length 1, expected struct Parameters with 5 elements\", line: 1, column: 340) }\', stdlib/sh/src/main.rs:25:70", stream: Stdout }
StepOutput { symbol: "sh", uuid: f619073f-4129-4d30-a94f-f61af164a6d8, buffer: "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", stream: Stdout }
StepEnd { symbol: "sh", uuid: f619073f-4129-4d30-a94f-f61af164a6d8 }
rtyler commented 3 years ago

This isn't the deserialization/serialization on the otto_models::Step but the deserialization of Parameters from the invocation file that the sh step receives.

Basically I never wrote that code to handle position parameters and mapping them. I'll need to figure out how to make the agent code smarter when creating the invocation file. Basically use the manifest file to map positional arguments into keyword arguments.