github.com/jonaz/heapster@v1.3.0-beta.0.0.20170208112634-cd3c15ca3d29/metrics/sinks/monasca/config.go (about) 1 // Copyright 2015 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package monasca 16 17 import ( 18 "net/url" 19 20 "github.com/rackspace/gophercloud" 21 ) 22 23 // Config represents the configuration of the Monasca sink. 24 type Config struct { 25 gophercloud.AuthOptions 26 MonascaURL string 27 } 28 29 // NewConfig builds a configuration object from the parameters of the monasca sink. 30 func NewConfig(opts url.Values) Config { 31 config := Config{} 32 if len(opts["keystone-url"]) >= 1 { 33 config.IdentityEndpoint = opts["keystone-url"][0] 34 } 35 if len(opts["tenant-id"]) >= 1 { 36 config.TenantID = opts["tenant-id"][0] 37 } 38 if len(opts["username"]) >= 1 { 39 config.Username = opts["username"][0] 40 } 41 if len(opts["user-id"]) >= 1 { 42 config.UserID = opts["user-id"][0] 43 } 44 if len(opts["password"]) >= 1 { 45 config.Password = opts["password"][0] 46 } 47 if len(opts["api-key"]) >= 1 { 48 config.APIKey = opts["api-key"][0] 49 } 50 if len(opts["domain-id"]) >= 1 { 51 config.DomainID = opts["domain-id"][0] 52 } 53 if len(opts["domain-name"]) >= 1 { 54 config.DomainName = opts["domain-name"][0] 55 } 56 if len(opts["monasca-url"]) >= 1 { 57 config.MonascaURL = opts["monasca-url"][0] 58 } 59 return config 60 }