Skip to content

Commit

Permalink
Merge pull request #351 from kthcloud/dev
Browse files Browse the repository at this point in the history
fix vms not visible through teams, bug fixes with auth and cache
  • Loading branch information
saffronjam authored Dec 20, 2023
2 parents 9f51608 + 36bc5a2 commit 367192c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions service/deployment_service/deployment_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *Client) Get(id string, opts *client.GetOptions) (*deploymentModel.Deplo
}

var effectiveUserID string
if c.Auth != nil && c.Auth.IsAdmin {
if c.Auth != nil && !c.Auth.IsAdmin {
effectiveUserID = c.Auth.UserID
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *Client) List(opts *client.ListOptions) ([]deploymentModel.Deployment, e
continue
}

deployment, err := deploymentModel.New().GetByID(resource.ID)
deployment, err := c.Deployment(resource.ID, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -706,7 +706,7 @@ func (c *Client) CheckQuota(id string, opts *client.QuotaOptions) error {
return fmt.Errorf("failed to check quota. details: %w", err)
}

if c.Auth != nil && c.Auth.IsAdmin {
if c.Auth == nil || c.Auth.IsAdmin {
return nil
}

Expand Down
10 changes: 7 additions & 3 deletions service/vm_service/vm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *Client) Get(id string, opts *client.GetOptions) (*vmModel.VM, error) {
}

var effectiveUserID string
if c.Auth != nil && c.Auth.IsAdmin {
if c.Auth != nil && !c.Auth.IsAdmin {
effectiveUserID = c.Auth.UserID
}

Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *Client) List(opts *client.ListOptions) ([]vmModel.VM, error) {

for _, team := range teams {
for _, resource := range team.GetResourceMap() {
if resource.Type != teamModels.ResourceTypeDeployment {
if resource.Type != teamModels.ResourceTypeVM {
continue
}

Expand All @@ -132,7 +132,11 @@ func (c *Client) List(opts *client.ListOptions) ([]vmModel.VM, error) {
}

vm, err := c.VM(resource.ID, nil)
if err != nil && vm != nil {
if err != nil {
return nil, err
}

if vm != nil {
resources = append(resources, *vm)
}
}
Expand Down

0 comments on commit 367192c

Please sign in to comment.