Skip to content

Commit

Permalink
Revert 55dfc08 for now
Browse files Browse the repository at this point in the history
- Changed deprecated ReadFile and WriteFile calls
  • Loading branch information
loafoe committed Jan 4, 2023
1 parent b6e7605 commit daf0be9
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions cloudfoundry/managers/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
Expand All @@ -14,6 +13,7 @@ import (
"code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/cfnetv1"
netWrapper "code.cloudfoundry.org/cfnetworking-cli-api/cfnetworking/wrapper"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2"
ccv2cons "code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/constant"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
ccWrapper "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper"
"code.cloudfoundry.org/cli/api/router"
Expand Down Expand Up @@ -416,19 +416,12 @@ func (s *Session) loadDeployer() {
}

func (s *Session) loadDefaultQuotaGuid(quotaName string) error {
// quotas, _, err := s.ClientV2.GetQuotas(ccv2cons.OrgQuota, ccv2.FilterByName(quotaName))
// if err != nil {
// return err
// }
quotas, _, err := s.ClientV3.GetOrganizationQuotas(ccv3.Query{
Key: ccv3.NameFilter,
Values: []string{quotaName},
})
quotas, _, err := s.ClientV2.GetQuotas(ccv2cons.OrgQuota, ccv2.FilterByName(quotaName))
if err != nil {
return err
}
if len(quotas) == 0 {
return fmt.Errorf("Can't found default quota '%s'", quotaName)
return fmt.Errorf("can't found default quota '%s'", quotaName)
}
s.defaultQuotaGuid = quotas[0].GUID
return nil
Expand All @@ -438,7 +431,7 @@ func (s *Session) loadTokFromStoreIfNeed(storePath string, refresher func(refres
if storePath == "" {
return CFTokens{}
}
b, err := ioutil.ReadFile(storePath)
b, err := os.ReadFile(storePath)
if err != nil {
return CFTokens{}
}
Expand All @@ -465,7 +458,7 @@ func (s *Session) saveTokToStoreIfNeed(storePath, accessToken, refreshToken stri
AccessToken: accessToken,
RefreshToken: refreshToken,
}, "", " ")
return ioutil.WriteFile(storePath, b, 0644)
return os.WriteFile(storePath, b, 0644)
}

// IsDefaultGroup -
Expand Down

0 comments on commit daf0be9

Please sign in to comment.