Skip to content

Commit

Permalink
feat: project variables create (#198)
Browse files Browse the repository at this point in the history
feat: project variables update
feat: project variables list
feat: project variables view
feat: project variables delete
  • Loading branch information
benPearce1 authored Jan 6, 2023
1 parent 079759d commit faa3b4c
Show file tree
Hide file tree
Showing 21 changed files with 2,208 additions and 22 deletions.
22 changes: 22 additions & 0 deletions examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,25 @@ octopus project convert --project 'Project 54' \
```

An existing project can be converted to Config As Code using the `convert` command

# View all values for a project variable

```
octopus project variables view BlueGreenTarget
```

# Set project variable prior to creating a release

In this example the `Id` represents the specific value for the variable `BlueGreenTarget` that has been scoped to the production environment.
The Id can be obtained with the `project variables view` command.

```
value=`octopus project variables view BlueGreenTarget --project "Random Quotes" --id d8527596-6fa2-4394-94e1-07942d3d0202 | grep Value`
if [[ $value =~ 'Blue' ]]; then
value="Green"
else
value="Blue"
fi
octopus project variables update BlueGreenTarget --project "Random Quotes" --id d8527596-6fa2-4394-94e1-07942d3d0202 --name "" --value $value --no-prompt
octopus release create --version 1.0.1 --project "Random Quotes" --no-prompt
```
4 changes: 2 additions & 2 deletions pkg/cmd/project/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func NewConvertOptions(flags *ConvertFlags, dependencies *cmd.Dependencies) *Con
return createGetAllGitCredentialsCallback(*dependencies.Client)
},
GetProjectCallback: func(identifier string) (*projects.Project, error) {
return shared.GetProject(*dependencies.Client, identifier)
return shared.GetProject(dependencies.Client, identifier)
},
GetAllProjectsCallback: func() ([]*projects.Project, error) { return shared.GetAllProjects(*dependencies.Client) },
GetAllProjectsCallback: func() ([]*projects.Project, error) { return shared.GetAllProjects(dependencies.Client) },
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
cmdDelete "github.com/OctopusDeploy/cli/pkg/cmd/project/delete"
cmdDisconnect "github.com/OctopusDeploy/cli/pkg/cmd/project/disconnect"
cmdList "github.com/OctopusDeploy/cli/pkg/cmd/project/list"
cmdVariables "github.com/OctopusDeploy/cli/pkg/cmd/project/variables"
cmdView "github.com/OctopusDeploy/cli/pkg/cmd/project/view"
"github.com/OctopusDeploy/cli/pkg/constants"
"github.com/OctopusDeploy/cli/pkg/constants/annotations"
Expand Down Expand Up @@ -37,6 +38,7 @@ func NewCmdProject(f factory.Factory) *cobra.Command {
cmd.AddCommand(cmdConnect.NewCmdConnect(f))
cmd.AddCommand(cmdDisconnect.NewCmdDisconnect(f))
cmd.AddCommand(cmdConvert.NewCmdConvert(f))
cmd.AddCommand(cmdVariables.NewCmdVariables(f))

return cmd
}
Loading

0 comments on commit faa3b4c

Please sign in to comment.