config.go
1 // Copyright 2016 The Prometheus Authors 2 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // you may not use this file except in compliance with the License. 4 // You may obtain a copy of the License at 5 // 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 // This package no longer handles safe yaml parsing. In order to 15 // ensure correct yaml unmarshalling, use "yaml.UnmarshalStrict()". 16 17 package config 18 19 // Secret special type for storing secrets. 20 type Secret string 21 22 // MarshalYAML implements the yaml.Marshaler interface for Secrets. 23 func (s Secret) MarshalYAML() (interface{}, error) { 24 if s != "" { 25 return "<secret>", nil 26 } 27 return nil, nil 28 } 29 30 //UnmarshalYAML implements the yaml.Unmarshaler interface for Secrets. 31 func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error { 32 type plain Secret 33 return unmarshal((*plain)(s)) 34 }