Skip to content

Environments API delete endpoint bug #7359

@vrushaliwaykole

Description

@vrushaliwaykole
Issue Type
  • Bug Report
Summary

Delete Environments API endpoint allows the deleting environment partially defined in the config repository successfully. This does not delete it from the config repository but deletes the part defined in cruise-config.xml.

So the partial delete should not be allowed or there should be clear separation which part is getting deleted.

Steps to Reproduce
  1. Define the environment dev in config repo.
  2. Check if the dev environment is retrieved in a GET request
  3. Delete dev environment via API.
Expected Results
curl 'http://localhost:8153/go/api/admin/environments/dev' \
      -u 'admin:badger' \
      -H 'Accept: application/vnd.go.cd.v3+json' \
      -X DELETE
{
  "message": "Environment with name 'dev' cannot be deleted as it is partially defined in '[config repo name]' config repository"
}%
Actual Results
curl 'http://localhost:8153/go/api/admin/environments/dev' \
      -u 'admin:badger' \
      -H 'Accept: application/vnd.go.cd.v3+json' \
      -X DELETE
{
  "message": "Environment with name 'dev' was deleted successfully!"
}%
curl 'http://localhost:8153/go/api/admin/internal/environments/merged' \
      -u 'admin:badger' \
      -H 'Accept: application/vnd.go.cd+json' \
      -H 'Content-Type: application/json' \
      -X GET

{
  "_embedded" : {
    "environments" : [ {
      "name" : "dev",
      "can_administer" : true,
      "origins" : [ {
        "_links" : {
          "self" : {
            "href" : "http://localhost:8153/go/api/admin/config_repos/bar"
          },
          "doc" : {
            "href" : "https://api.gocd.org/19.11.0/#config-repos"
          },
          "find" : {
            "href" : "http://localhost:8153/go/api/admin/config_repos/:id"
          }
        },
        "type" : "config_repo",
        "id" : "bar"
      } ],
      "pipelines" : [ ],
      "agents" : [ ],
      "environment_variables" : [ {
        "secure" : false,
        "name" : "key11",
        "value" : "value"{"Failed due to an exception. Please check the logs."%
Basic environment details
  • Go Version: 19.11.0 (10678-94ff598f8ae582d2d8acf9b1f2a3d0a544b6379d).
  • JAVA Version: openjdk 11.0.2 2019-01-15
  • OS: macOS mojave

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions