Skip to content

Commit

Permalink
make DIRECT proxysettting default share to system
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Apr 26, 2020
1 parent 1e81c79 commit 6faa4d9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/cloudcommon/db/proxy/proxysetting.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/httputils"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)

type SProxySettingManager struct {
Expand Down Expand Up @@ -198,8 +199,19 @@ func (man *SProxySettingManager) PerformTest(ctx context.Context, userCred mccli
}

func (man *SProxySettingManager) InitializeData() error {
_, err := man.FetchById(proxyapi.ProxySettingId_DIRECT)
psObj, err := man.FetchById(proxyapi.ProxySettingId_DIRECT)
if err == nil {
ps := psObj.(*SProxySetting)
if !ps.IsPublic || ps.PublicScope != string(rbacutils.ScopeSystem) {
_, err = db.Update(ps, func() error {
ps.IsPublic = true
ps.PublicScope = string(rbacutils.ScopeSystem)
return nil
})
if err != nil {
return errors.Wrap(err, "Update")
}
}
return nil
}
if err != sql.ErrNoRows {
Expand All @@ -214,6 +226,8 @@ func (man *SProxySettingManager) InitializeData() error {
ps.Id = proxyapi.ProxySettingId_DIRECT
ps.Name = proxyapi.ProxySettingId_DIRECT
ps.Description = "Connect directly"
ps.IsPublic = true
ps.PublicScope = string(rbacutils.ScopeSystem)
if err := man.TableSpec().Insert(ps); err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/mcclient/modules/mod_proxysettings.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func init() {
"http_proxy",
"https_proxy",
"no_proxy",
"is_public",
"public_scope",
},
[]string{})}
registerCompute(&ProxySettings)
Expand Down

0 comments on commit 6faa4d9

Please sign in to comment.