-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for new tenant variables endpoints with environment scoping #301
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that getting feature toggles, tenant project variables and tenant common variables are all working as expected.
I'm struggling to use the update commands, have an example?
var vars []variables.TenantCommonVariableCommand
modify := variables.ModifyTenantCommonVariablesCommand{TenantID: tenantID, CommonVariables: vars}
modified, err := tenants.UpdateCommonVariables(client, "Spaces-1", tenantID, &modify)
if err != nil {
_ = fmt.Errorf("error creating API client: %v", err)
return
}
fmt.Println(modified)
SpaceID string `json:"SpaceId"` | ||
} | ||
|
||
type TenantProjectVariablesResource struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our naming needs a bit of work. Resource
has been superseded. TenantProjectVariable
is a read type, whereas TenantProjectVariableCommand
is the write type. Love to establish a convention so it's easy to understand what the types mean and when to use them without having to reason through where and how they are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than TenantProjectVariablesResource
, how about TenantProjectVariableResponse
? This would help to make it a bit clearer what the object is intended to be used for. Within that, we currently have TenantProjectVariable
, which could be renamed to something similar to TenantProjectVariableValueResponse
or TenantProjectVariableDetailsResponse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names updated based on the team discussion
Looks like I'd left some naming issues after a refactor. I've made a few changes and verified that update is now working. Just one tweak for the test code - it looks like
|
Ran into an issue because I used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some naming to address, leaving Resource
in the past.
The methods all work as expected.
I'm wondering about Id
vs ID
and the resource properties on the structs (resources.Resource
), do we need those?
pkg/tenants/tenant_service.go
Outdated
const tenantCommonVariableTemplate = "/api/{spaceId}/tenants/{id}/commonvariables" | ||
|
||
// GetProjectVariables returns all tenant project variables. If an error occurs, it returns nil. | ||
func GetProjectVariables(client newclient.Client, spaceID string, tenantID string) (*variables.TenantProjectVariablesResource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
pkg/tenants/tenant_service.go
Outdated
} | ||
|
||
// GetCommonVariables returns all tenant common variables. If an error occurs, it returns nil. | ||
func GetCommonVariables(client newclient.Client, spaceID string, tenantID string) (*variables.TenantCommonVariablesResource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
pkg/tenants/tenant_service.go
Outdated
} | ||
|
||
// UpdateCommonVariables modifies tenant common variables based on the ones provided as input. | ||
func UpdateCommonVariables(client newclient.Client, spaceID string, tenantID string, commonVariables *variables.ModifyTenantCommonVariablesCommand) (*variables.TenantCommonVariablesResource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
pkg/tenants/tenant_service.go
Outdated
} | ||
|
||
// UpdateProjectVariables modifies tenant project variables based on the ones provided as input. | ||
func UpdateProjectVariables(client newclient.Client, spaceID string, tenantID string, projectVariables *variables.ModifyTenantProjectVariablesCommand) (*variables.TenantProjectVariablesResource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
I've removed the extra IDs and updated the naming |
[SC-93476] [SC-101710]
New tenant variables endpoints have been added to Octopus Server to allow multi-environment scoping for Common and Project Tenant Variables. This PR adds support for the new endpoints, and for the feature toggles endpoint to allow verification of whether the endpoints are available:
/api/{SpaceId}/tenants/{TenantId}/commonvariables
(GET/PUT/POST)/api/{SpaceId}/tenants/{TenantId}/projectvariables
(GET/PUT/POST)Feature toggles can be queried by name - both of the above endpoints are under
CommonVariableScopingFeatureToggle
.