Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions docs/source/development/traffic_ops_api/v12/parameter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,47 @@ Parameter
+------------------+---------+--------------------------------------------------------------------------------+
| Parameter | Type | Description |
+==================+=========+================================================================================+
| ``last_updated`` | string | The Time / Date this server entry was last updated |
| ``lastUpdated`` | string | The Time / Date this server entry was last updated |
+------------------+---------+--------------------------------------------------------------------------------+
| ``secure`` | boolean | When true, the parameter is accessible only by admin users. Defaults to false. |
+------------------+---------+--------------------------------------------------------------------------------+
| ``value`` | string | The parameter value, only visible to admin if secure is true |
+------------------+---------+--------------------------------------------------------------------------------+
| ``name`` | string | The parameter name |
+------------------+---------+--------------------------------------------------------------------------------+
| ``config_file`` | string | The parameter config_file |
| ``configFile`` | string | The parameter config_file |
+------------------+---------+--------------------------------------------------------------------------------+
| ``profiles`` | array | An array of profiles attached to this parameter. |
+------------------+---------+--------------------------------------------------------------------------------+

**Response Example** ::

{
"response": [
{
"last_updated": "2012-09-17 21:41:22",
"lastUpdated": "2012-09-17 21:41:22",
"secure": false,
"value": "foo.bar.net",
"name": "domain_name",
"config_file": "FooConfig.xml"
"configFile": "FooConfig.xml",
"profiles": [ "EDGE-FOO, MID-FOO" ]
},
{
"last_updated": "2012-09-17 21:41:22",
"lastUpdated": "2012-09-17 21:41:22",
"secure": false,
"value": "0,1,2,3,4,5,6",
"name": "Drive_Letters",
"config_file": "storage.config"
"configFile": "storage.config",
"profiles": [ "EDGE-FOO, MID-FOO" ]

},
{
"last_updated": "2012-09-17 21:41:22",
"lastUpdated": "2012-09-17 21:41:22",
"secure": true,
"value": "STRING __HOSTNAME__",
"name": "CONFIG proxy.config.proxy_name",
"config_file": "records.config"
"configFile": "records.config"
"profiles": [ ]
}
],
}
Expand Down
15 changes: 9 additions & 6 deletions lib/go-tc/parameters.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tc

import "encoding/json"

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -26,10 +28,11 @@ type ParametersResponse struct {

// Parameter ...
type Parameter struct {
ConfigFile string `json:"configFile" db:"config_file"`
ID int `json:"id" db:"id"`
LastUpdated Time `json:"lastUpdated" db:"last_updated"`
Name string `json:"name" db:"name"`
Secure bool `json:"secure" db:"secure"`
Value string `json:"value" db:"value"`
ConfigFile string `json:"configFile" db:"config_file"`
ID int `json:"id" db:"id"`
LastUpdated Time `json:"lastUpdated" db:"last_updated"`
Name string `json:"name" db:"name"`
Profiles json.RawMessage `json:"profiles" db:"profiles"`
Secure bool `json:"secure" db:"secure"`
Value string `json:"value" db:"value"`
}
19 changes: 11 additions & 8 deletions traffic_ops/traffic_ops_golang/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ func getParameters(v url.Values, db *sqlx.DB, privLevel int) ([]tc.Parameter, er
func selectParametersQuery() string {

query := `SELECT
config_file,
id,
last_updated,
name,
value,
secure

FROM parameter p`
p.config_file,
p.id,
p.last_updated,
p.name,
p.value,
p.secure,
COALESCE(array_to_json(array_agg(pr.name) FILTER (WHERE pr.name IS NOT NULL)), '[]') AS profiles
FROM parameter p
LEFT JOIN profile_parameter pp ON p.id = pp.parameter
LEFT JOIN profile pr ON pp.profile = pr.id
GROUP BY p.config_file, p.id, p.last_updated, p.name, p.value, p.secure`
return query
}
4 changes: 4 additions & 0 deletions traffic_ops/traffic_ops_golang/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/jmoiron/sqlx"

sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1"
"encoding/json"
)

func getTestParameters() []tc.Parameter {
Expand All @@ -39,6 +40,7 @@ func getTestParameters() []tc.Parameter {
ID: 1,
LastUpdated: tc.Time{Time: time.Now()},
Name: "paramname1",
Profiles: json.RawMessage(`["foo","bar"]`),
Secure: false,
Value: "val1",
}
Expand All @@ -48,6 +50,7 @@ func getTestParameters() []tc.Parameter {
testParameter2.Name = "paramname2"
testParameter2.Value = "val2"
testParameter2.ConfigFile = "some.config"
testParameter2.Profiles = json.RawMessage(`["foo","baz"]`)
parameters = append(parameters, testParameter2)

return parameters
Expand Down Expand Up @@ -75,6 +78,7 @@ func TestGetParameters(t *testing.T) {
ts.ID,
ts.LastUpdated,
ts.Name,
ts.Profiles,
ts.Secure,
ts.Value,
)
Expand Down
2 changes: 1 addition & 1 deletion traffic_ops/traffic_ops_golang/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func Routes(d ServerData) ([]Route, http.Handler, error) {
//HwInfo
{1.2, http.MethodGet, `hwinfo-wip/?(\.json)?$`, hwInfoHandler(d.DB), HWInfoPrivLevel, Authenticated, nil},
//Parameters
{1.2, http.MethodGet, `parameters/?(\.json)?$`, parametersHandler(d.DB), ParametersPrivLevel, Authenticated, nil},
{1.3, http.MethodGet, `parameters/?(\.json)?$`, parametersHandler(d.DB), ParametersPrivLevel, Authenticated, nil},
//Regions
{1.2, http.MethodGet, `regions/?(\.json)?$`, regionsHandler(d.DB), RegionsPrivLevel, Authenticated, nil},
{1.2, http.MethodGet, `regions/{id}$`, regionsHandler(d.DB), RegionsPrivLevel, Authenticated, nil},
Expand Down
4 changes: 4 additions & 0 deletions traffic_ops/traffic_ops_golang/system_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/auth"
"github.com/apache/incubator-trafficcontrol/traffic_ops/traffic_ops_golang/test"
"github.com/jmoiron/sqlx"
"encoding/json"
)

var sysInfoParameters = []tc.Parameter{
Expand All @@ -38,6 +39,7 @@ var sysInfoParameters = []tc.Parameter{
ID: 1,
LastUpdated: tc.Time{Time: time.Now()},
Name: "paramname1",
Profiles: json.RawMessage(`["foo","bar"]`),
Secure: false,
Value: "val1",
},
Expand All @@ -47,6 +49,7 @@ var sysInfoParameters = []tc.Parameter{
ID: 2,
LastUpdated: tc.Time{Time: time.Now()},
Name: "paramname2",
Profiles: json.RawMessage(`["foo","bar"]`),
Secure: false,
Value: "val2",
},
Expand All @@ -73,6 +76,7 @@ func TestGetSystemInfo(t *testing.T) {
ts.ID,
ts.LastUpdated,
ts.Name,
ts.Profiles,
ts.Secure,
ts.Value,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

.param-value {
max-width: 300px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
margin-bottom: -5px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<th>Config File</th>
<th>Value</th>
<th>Secure</th>
<th>Profiles</th>
</tr>
</thead>
<tbody>
Expand All @@ -45,6 +46,7 @@
<td data-search="^{{::p.configFile}}$">{{::p.configFile}}</td>
<td data-search="^{{::p.value}}$">{{::p.value}}</td>
<td data-search="^{{::p.secure}}$">{{::p.secure}}</td>
<td data-search="{{::p.profiles}}" uib-popover="{{::p.profiles.sort().join(',\n')}}" popover-title="Profiles" popover-trigger="mouseenter" popover-placement="left" popover-append-to-body="true">{{p.profiles.length}}</td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions traffic_portal/app/src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ $fa-font-path: "../assets/fonts";
@import "../common/modules/message/message";
@import "../common/modules/navigation/navigation";
@import "../common/modules/table/table";
@import "../common/modules/table/parameters/table.parameters";
@import "../common/modules/release/release";
@import "../common/modules/widget/capacity/widget.capacity";
@import "../common/modules/widget/cacheGroups/widget.cacheGroups";
Expand Down