I’ve been working on a little project for a few weeks now, and it’s finally time to share it with the world! Say hello to the Code Stream CLI!
The CLI is built in Golang (my very first project written in Go!) and uses the Cobra and Viper libraries to create a kubectl-like command line interface, and the Go-Resty REST client library to interact with the Code Stream API.
The Code Stream CLI is being released as a Fling, and as an open source project. It’s available as a pre-compiled binary for several platforms, via homebrew, as well as a Docker image. Or you can build it yourself from source!
Why do we need a Code Stream CLI?
Firstly, it opens up Code Stream to more people – it’s another way of consuming Code Stream that might fit a little better into your workflow – and that can’t be a bad thing!
Moving content between instances of Code Stream, or between Projects within Code Stream, is (at present) a manual task, and while all the Content is exportable/importable as YAML, it can be tricky to move a lot of content. Code Stream CLI allows you to export content by Project, ID or Name
This is also useful to bring your content under version control, by exporting the code to a Git repository (or other VCS).
Show me the CLI already!
Each Code Stream instance is added as a “target” configuration for cs-cli – here I’m creating a target for my test vRA 8.2 instance, and my vRA Cloud instance. For vRA Cloud you need to generate an API token first.
To view all the Pipelines in my “Field Demo” project, I use the following:
To migrate content between a Project, or Code Stream instances, you can use the export function of the CLI. Let’s assume I have three pipelines I want to export from my “Field Demo” project, and import into my “Production” project.
You can see this in action here
To import the pipelines to my vRealize Automation Cloud Code Stream I can simply switch to use the correct config betweem the export and import stages
cs-cli config use-target --name vrac-smcg-org
You can view the instructions and download the binary on the Code Stream CLI fling site, or view the README on GitHub for other options. There are also more examples in the README file, so I’d suggest starting there!
If you have a problem, you can log it as an issue in the repository, and if you’re comfortable issue a PR with a fix!
Lastly, if you find this useful and want to let me know, or you want to reach out about the tool you can get hold of me on Twitter @sammcgeown