#!/usr/bin/env bash

# Multi-param op with nested object return and markers.

@operation.deploy.service() {
    @in.string image
    @in.string tag
    @in.int port
    @out.string endpoint
    @out.string status
    @out.string config.image
    @out.string config.tag
    @out.int config.port
    @remote
    @dangerous
    @note "Deploys to the active cluster context"

    @do() {
        local image
        local tag
        local port

        image=$(@in image)
        tag=$(@in tag)
        port=$(@in port)

        @out.string endpoint "https://${image}.svc:${port}"
        @out.string status "deployed"
        @out.object config "$({
            @out.string image "$image"
            @out.string tag "$tag"
            @out.int port "$port"
            @return.out
        })"

        @return.out
    }

    @is-done() {
        return 1
    }
}
