Skip to content

Commit

Permalink
Operator console changes to allow enabling of SFTP for tenant (#1692)
Browse files Browse the repository at this point in the history
* Enable sftp for tenant from operator console

---------

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
  • Loading branch information
shtripat committed Jul 25, 2023
1 parent 41ac8de commit ef09546
Show file tree
Hide file tree
Showing 58 changed files with 737 additions and 9 deletions.
14 changes: 14 additions & 0 deletions api/configuration-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func parseTenantConfiguration(ctx context.Context, k8sClient K8sClientI, minTena
return envVars[i].Key < envVars[j].Key
})
configurationInfo := &models.TenantConfigurationResponse{EnvironmentVariables: envVars}
if minTenant.Spec.Features != nil && minTenant.Spec.Features.EnableSFTP != nil {
configurationInfo.SftpExposed = *minTenant.Spec.Features.EnableSFTP
}
return configurationInfo, nil
}

Expand Down Expand Up @@ -161,12 +164,23 @@ func updateTenantConfigurationFile(ctx context.Context, operatorClient OperatorC
if err != nil {
return err
}

// Update SFTP flag
if tenant.Spec.Features != nil {
tenant.Spec.Features.EnableSFTP = &requestBody.SftpExposed
_, err = operatorClient.TenantUpdate(ctx, tenant, metav1.UpdateOptions{})
if err != nil {
return err
}
}

// Restart all MinIO pods at the same time for they to take the new configuration
err = client.deletePodCollection(ctx, namespace, metav1.DeleteOptions{}, metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", miniov2.TenantLabel, tenant.Name),
})
if err != nil {
return err
}

return nil
}
30 changes: 30 additions & 0 deletions api/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/operations/operator_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions api/tenant-add-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ func createTenant(ctx context.Context, params operator_api.CreateTenantParams, c
}
minInst.Spec.Configuration = &corev1.LocalObjectReference{Name: tenantConfigurationName}

var features miniov2.Features
if tenantReq.Domains != nil {
var features miniov2.Features
var domains miniov2.TenantDomains

// tenant domains
Expand All @@ -284,9 +284,11 @@ func createTenant(ctx context.Context, params operator_api.CreateTenantParams, c
}

features.Domains = &domains

minInst.Spec.Features = &features
}
if tenantReq.ExposeSftp {
features.EnableSFTP = &tenantReq.ExposeSftp
}
minInst.Spec.Features = &features

opClient, err := GetOperatorClient(session.STSSessionToken)
if err != nil {
Expand Down
13 changes: 9 additions & 4 deletions api/tenant-get-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,15 @@ func getTenantDetailsResponse(session *models.Principal, params operator_api.Ten

var domains models.DomainsConfiguration

if minTenant.Spec.Features != nil && minTenant.Spec.Features.Domains != nil {
domains = models.DomainsConfiguration{
Console: minTenant.Spec.Features.Domains.Console,
Minio: minTenant.Spec.Features.Domains.Minio,
if minTenant.Spec.Features != nil {
if minTenant.Spec.Features.EnableSFTP != nil {
info.SftpExposed = *minTenant.Spec.Features.EnableSFTP
}
if minTenant.Spec.Features.Domains != nil {
domains = models.DomainsConfiguration{
Console: minTenant.Spec.Features.Domains.Console,
Minio: minTenant.Spec.Features.Domains.Minio,
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions api/tenant_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func updateTenantAction(ctx context.Context, operatorClient OperatorClientI, cli
}
}

if minInst.Spec.Features != nil {
minInst.Spec.Features.EnableSFTP = &params.Body.SftpExposed
}
payloadBytes, err := json.Marshal(minInst)
if err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions models/allocatable_resources_response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions models/aws_configuration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions models/azure_configuration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions models/container.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions models/create_tenant_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef09546

Please sign in to comment.