You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/07/23 15:56:57 UTC
[trafficcontrol] branch master updated (2c56bdc -> fe38436)
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.
from 2c56bdc Fix TO Go cachegroups PUT/POST API endpoints
new d6728b0 if user has no tenant, check if tenancy is on and respond accordingly
new fe38436 protect against nil
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
traffic_ops/traffic_ops_golang/tenant/tenant.go | 26 ++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
[trafficcontrol] 02/02: protect against nil
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit fe3843694fa3c6e77381eb8c7aa775e5344da976
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jul 23 09:50:16 2018 -0600
protect against nil
---
traffic_ops/traffic_ops_golang/tenant/tenant.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/traffic_ops/traffic_ops_golang/tenant/tenant.go b/traffic_ops/traffic_ops_golang/tenant/tenant.go
index b6d4ec0..8bc9e0c 100644
--- a/traffic_ops/traffic_ops_golang/tenant/tenant.go
+++ b/traffic_ops/traffic_ops_golang/tenant/tenant.go
@@ -159,6 +159,11 @@ func (ten *TOTenant) Create() (error, tc.ApiErrorType) {
func (ten *TOTenant) Read(parameters map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
var rows *sqlx.Rows
+ if ten.ReqInfo == nil || ten.ReqInfo.User == nil {
+ // should never happen
+ return nil, []error{errors.New("missing request info")}, tc.SystemError
+ }
+
tenantID := ten.ReqInfo.User.TenantID
if tenantID == auth.TenantIDInvalid {
// NOTE: work around issue where user has no tenancy assigned. If tenancy turned off, there
[trafficcontrol] 01/02: if user has no tenant,
check if tenancy is on and respond accordingly
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit d6728b08b7d40c432fc142d978ddca63fb59ac81
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jul 19 17:15:17 2018 -0600
if user has no tenant, check if tenancy is on and respond accordingly
---
traffic_ops/traffic_ops_golang/tenant/tenant.go | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/traffic_ops/traffic_ops_golang/tenant/tenant.go b/traffic_ops/traffic_ops_golang/tenant/tenant.go
index 24dbf7f..b6d4ec0 100644
--- a/traffic_ops/traffic_ops_golang/tenant/tenant.go
+++ b/traffic_ops/traffic_ops_golang/tenant/tenant.go
@@ -159,6 +159,25 @@ func (ten *TOTenant) Create() (error, tc.ApiErrorType) {
func (ten *TOTenant) Read(parameters map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
var rows *sqlx.Rows
+ tenantID := ten.ReqInfo.User.TenantID
+ if tenantID == auth.TenantIDInvalid {
+ // NOTE: work around issue where user has no tenancy assigned. If tenancy turned off, there
+ // should be no tenancy restrictions. This should be removed once tenant_id NOT NULL constraints
+ // are in place
+ enabled, err := IsTenancyEnabledTx(ten.ReqInfo.Tx.Tx)
+ if err != nil {
+ log.Infof("error checking tenancy: %v", err)
+ return nil, nil, tc.SystemError
+ }
+
+ if enabled {
+ // tenancy enabled, but user doesn't belong to one -- return empty list
+ return nil, nil, tc.NoError
+ }
+ // give it the root tenant -- since tenancy turned off, does not matter what it is
+ tenantID = 1
+ }
+
// Query Parameters to Database Query column mappings
// see the fields mapped in the SQL query
queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
@@ -173,7 +192,7 @@ func (ten *TOTenant) Read(parameters map[string]string) ([]interface{}, []error,
return nil, errs, tc.DataConflictError
}
- query := selectQuery(ten.ReqInfo.User.TenantID) + where + orderBy
+ query := selectQuery(tenantID) + where + orderBy
log.Debugln("Query is ", query)
rows, err := ten.ReqInfo.Tx.NamedQuery(query, queryValues)