From 2b00f2b5e9fbe71057f32e7e905173847f5cf72d Mon Sep 17 00:00:00 2001 From: grace-rehn Date: Mon, 18 Nov 2024 14:43:41 +1000 Subject: [PATCH] feat: Add isDisabled field to tenant (#284) * feat: Add isDisabled field to tenant * feat: Add isDisabled to tenant query --- pkg/tenants/tenant.go | 5 +++++ pkg/tenants/tenant_service.go | 2 +- pkg/tenants/tenants_query.go | 1 + test/e2e/tenant_service_test.go | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/tenants/tenant.go b/pkg/tenants/tenant.go index 24c1b7ab..c13c737e 100644 --- a/pkg/tenants/tenant.go +++ b/pkg/tenants/tenant.go @@ -12,6 +12,7 @@ type Tenant struct { ProjectEnvironments map[string][]string `json:"ProjectEnvironments,omitempty"` SpaceID string `json:"SpaceId"` TenantTags []string `json:"TenantTags,omitempty"` + IsDisabled bool `json:"IsDisabled"` resources.Resource } @@ -29,3 +30,7 @@ func NewTenant(name string) *Tenant { func (t Tenant) Validate() error { return validator.New().Struct(t) } + +func (t *Tenant) GetName() string { + return t.Name +} diff --git a/pkg/tenants/tenant_service.go b/pkg/tenants/tenant_service.go index a0d45f34..54d235ed 100644 --- a/pkg/tenants/tenant_service.go +++ b/pkg/tenants/tenant_service.go @@ -282,7 +282,7 @@ func (s *TenantService) UpdateVariables(tenant *Tenant, tenantVariables *variabl // --- new --- -const template = "/api/{spaceId}/tenants{/id}{?skip,projectId,name,tags,take,ids,clone,partialName,clonedFromTenantId}" +const template = "/api/{spaceId}/tenants{/id}{?skip,projectId,name,tags,take,ids,clone,partialName,isDisabled,clonedFromTenantId}" // Get returns a collection of tenants based on the criteria defined by its // input query parameter. diff --git a/pkg/tenants/tenants_query.go b/pkg/tenants/tenants_query.go index d2a07b55..73209dfb 100644 --- a/pkg/tenants/tenants_query.go +++ b/pkg/tenants/tenants_query.go @@ -4,6 +4,7 @@ type TenantsQuery struct { ClonedFromTenantID string `uri:"clonedFromTenantId,omitempty" url:"clonedFromTenantId,omitempty"` IDs []string `uri:"ids,omitempty" url:"ids,omitempty"` IsClone bool `uri:"clone,omitempty" url:"clone,omitempty"` + IsDisabled bool `uri:"isDisabled,omitempty" url:"isDisabled,omitempty"` Name string `uri:"name,omitempty" url:"name,omitempty"` PartialName string `uri:"partialName,omitempty" url:"partialName,omitempty"` ProjectID string `uri:"projectId,omitempty" url:"projectId,omitempty"` diff --git a/test/e2e/tenant_service_test.go b/test/e2e/tenant_service_test.go index e1bea179..04f6af1c 100644 --- a/test/e2e/tenant_service_test.go +++ b/test/e2e/tenant_service_test.go @@ -32,6 +32,7 @@ func AssertEqualTenants(t *testing.T, expected *tenants.Tenant, actual *tenants. assert.Equal(t, expected.ProjectEnvironments, actual.ProjectEnvironments) assert.Equal(t, expected.SpaceID, actual.SpaceID) assert.Equal(t, expected.TenantTags, actual.TenantTags) + assert.Equal(t, expected.IsDisabled, actual.IsDisabled) } func CreateTestTenant(t *testing.T, octopusClient *client.Client, project *projects.Project, environment *environments.Environment) *tenants.Tenant { @@ -191,6 +192,7 @@ func TestTenantUpdate(t *testing.T) { expected.Name = internal.GetRandomName() expected.Description = internal.GetRandomName() + expected.IsDisabled = true actual, err := octopusClient.Tenants.Update(expected) assert.NoError(t, err)