extraopts.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 Yunion
  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. package sqlchemy
  15. type TableExtraOptions map[string]string
  16. func (opts TableExtraOptions) Get(key string) string {
  17. return opts[key]
  18. }
  19. func (opts TableExtraOptions) Set(key string, val string) TableExtraOptions {
  20. opts[key] = val
  21. return opts
  22. }
  23. func (opts TableExtraOptions) Contains(key string) bool {
  24. if _, ok := opts[key]; ok {
  25. return true
  26. }
  27. return false
  28. }
  29. func (ts *STableSpec) GetExtraOptions() TableExtraOptions {
  30. return ts.extraOptions
  31. }
  32. func (ts *STableSpec) SetExtraOptions(opts TableExtraOptions) {
  33. if ts.extraOptions == nil {
  34. ts.extraOptions = opts
  35. return
  36. }
  37. for k := range opts {
  38. ts.extraOptions[k] = opts[k]
  39. }
  40. }