Skip to content

Conversation

@caitlynstocker
Copy link
Contributor

@caitlynstocker caitlynstocker commented Nov 4, 2025

Background 🌇

Ephemeral environments allow users to quickly and automatically spin up and tear down environments with consistent settings in Octopus. To make ephemeral environments a first class experience, we want to support interaction with ephemeral environments via the Octopus portal, API, GitHub Actions and the CLI.

What's this? 🌵

This PR adds our first CLI command for ephemeral environments, to enable users to create a new ephemeral environment.

The command requires the following inputs:

  • name - the name of the EE to create (--name)
  • project - the name of the project to associate the EE with (--project)
  • space - the space in which to find the project and create the EE (--space)

When the command is run in non-interactive mode, values for name, space and project must be provided using the flags shown above.

When the command is run in interactive mode, prompts will appear if values are not provided for name and project.

  • The name prompt takes a string input.
  • The project prompt shows a list of projects which are configured for EE's for the user to select from. (I.e. projects with an associated EE type channel.)

❓ In interactive mode, a value for space should be supplied using the OCTOPUS_SPACE environment variable. (Or using the --space flag.) It's not in the spec but would we like to have a prompt to select a space in interactive mode as well??
⬇️
Update: As discussed with @geofflamrock and confirmed with a click around the other create commands, we generally do not prompt for a space input. So no need to do it here 👍

Testing 🧪

The following cases have been tested:
✅ Create an EE with non interactive mode
✅ Create an EE in interactive mode with the OCTOPUS_SPACE environment variable
✅ Create an EE in interactive mode with the --space flag set
✅ Show only EE configured projects in interactive mode if the space contains unconfigured projects
☑️ Throw an informative error in interactive mode if the space contains no configured projects
☑️ Throw server error if an EE of the same name already exists with a different parent environment
☑️ Throw server error if an EE of the same name is already connected to the project

How to review? 🔍

☑️ Code quality - this is my first contribution to the CLI and my first crack at writing in Go, so please check carefully.
❓ Do we want to have a prompt to select the space as well?

  • TODO - update Octopus GO API client to latest version once it exists!

Fixes[sc-123001]

const (
FlagName = "name"
FlagProject = "project"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a --space flag as this is automatically added to the command.

@caitlynstocker caitlynstocker force-pushed the cat/123001/command-to-create-ee branch 2 times, most recently from 676bb4b to 2e51397 Compare November 4, 2025 02:17
@@ -0,0 +1,67 @@
package create_test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are based on the test to create a space.

@caitlynstocker caitlynstocker changed the title Cat/123001/command to create ee Add command to create an ephemeral environment Nov 4, 2025
@caitlynstocker caitlynstocker marked this pull request as ready for review November 4, 2025 02:52
@caitlynstocker caitlynstocker requested review from a team and Copilot November 4, 2025 02:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for managing ephemeral environments in Octopus Deploy through a new ephemeral-environment CLI command with a create subcommand.

  • Introduces a new ephemeral-environment command group with a create subcommand
  • Updates the go-octopusdeploy dependency to version v2.85.2-0.20251102214655-01f4f4d03e21 to support ephemeral environments API
  • Implements interactive prompting and validation for ephemeral environment creation with project association

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/cmd/root/root.go Registers the new ephemeral environment command in the CLI root
pkg/cmd/ephemeralenvironment/ephemeralenvironment.go Defines the ephemeral-environment command group and metadata
pkg/cmd/ephemeralenvironment/create/create.go Implements the create subcommand with flags, prompts, and API integration
pkg/cmd/ephemeralenvironment/create/create_test.go Tests for the create command's interactive prompting behavior
go.mod Updates go-octopusdeploy dependency to support ephemeral environments
go.sum Checksums for the updated dependency
Comments suppressed due to low confidence (1)

go.mod:3

  • Go version 1.23.12 does not exist. The latest Go 1.23.x release as of January 2025 is 1.23.4. This appears to be an invalid version number.
go 1.23.12

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@caitlynstocker caitlynstocker force-pushed the cat/123001/command-to-create-ee branch from 2e51397 to 7c9ed99 Compare November 4, 2025 03:10
@caitlynstocker caitlynstocker force-pushed the cat/123001/command-to-create-ee branch from 188921f to 9bcbe23 Compare November 4, 2025 05:14
}

if opts.Project.Value == "" {
project, err := selectors.Select(opts.Ask, "Select an ephemeral environments configured project to associate with the environment:", opts.GetConfiguredProjectsCallback, func(project *projects.Project) string { return project.GetName() })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording here is a bit awkward, The test sentence feels like the subject is a bit backward (sorry I am not sure how to explain the feeling). Maybe something like "Select a project that has been configured for ephemeral environments, to create your new environment in:"

Or could we take this to the team for input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final version ✨

Image

Copy link
Contributor

@stevencl840 stevencl840 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To code looks good. I have tested both prompted and unprompted

@caitlynstocker caitlynstocker force-pushed the cat/123001/command-to-create-ee branch from 2bb68ee to 73469ed Compare November 5, 2025 05:24
@caitlynstocker caitlynstocker changed the title Add command to create an ephemeral environment feat: Add command to create an ephemeral environment Nov 5, 2025
@caitlynstocker caitlynstocker changed the title feat: Add command to create an ephemeral environment feat: Add ephemeral environment create command Nov 5, 2025
@caitlynstocker caitlynstocker merged commit 0fc0cdd into main Nov 5, 2025
4 checks passed
@caitlynstocker caitlynstocker deleted the cat/123001/command-to-create-ee branch November 5, 2025 05:35
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.

2 participants