nullstone-io / nullstone

Nullstone is a customizable developer platform launched on your cloud accounts.
https://nullstone.io
MIT License
39 stars 1 forks source link

291+290 Built outputs retriever using struct tags #6

Closed BSick7 closed 3 years ago

BSick7 commented 3 years ago

This PR introduces outputs.Retriever. The goal of this struct is to provide a simple, contract-based method for defining outputs in nullstone modules. This is done through the use of struct tags on Outputs struct for each category+module type.

Since the Retriever is heavily tested, there is less likelihood of issues introduced when building for other app patterns and module types.

NOTE: I could see this going in another repo some day, but I left in the CLI until it becomes an issue.

As an example, the following structs define the outputs needed for performing actions on aws-fargate-service.

// contracts/aws-fargate-service

type Outputs struct {
    ServiceName  string          `ns:"service_name"`
    ImageRepoUrl docker.ImageUrl `ns:"image_repo_url,optional"`
    ImagePusher  aws.User        `ns:"image_pusher,optional"`

    Cluster aws_fargate.Outputs `ns:",connectionType:cluster/aws-fargate"`
}

// contracts/aws-fargate

type Outputs struct {
    ClusterArn string   `ns:"cluster_arn"`
    Deployer   aws.User `ns:"deployer"`
}