container_registry.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 k8s
  15. import (
  16. "yunion.io/x/jsonutils"
  17. "yunion.io/x/onecloud/pkg/mcclient/options"
  18. )
  19. type RegistryListOptions struct {
  20. options.BaseListOptions
  21. Type string `help:"Container registry type" json:"type" choices:"harbor"`
  22. }
  23. func (o *RegistryListOptions) Params() (jsonutils.JSONObject, error) {
  24. params, err := o.BaseListOptions.Params()
  25. if err != nil {
  26. return nil, err
  27. }
  28. if o.Type != "" {
  29. params.Add(jsonutils.NewString(o.Type), "type")
  30. }
  31. return params, nil
  32. }
  33. type RegistryGetOptions struct {
  34. NAME string `help:"ID or name of the repo" json:"name"`
  35. }
  36. func (o *RegistryGetOptions) GetId() string {
  37. return o.NAME
  38. }
  39. func (o *RegistryGetOptions) Params() (jsonutils.JSONObject, error) {
  40. return nil, nil
  41. }
  42. type RegistryCreateCommonOptions struct {
  43. Username string `json:"username"`
  44. Password string `json:"password"`
  45. }
  46. type RegistryCreateHarborOptions struct {
  47. RegistryCreateCommonOptions
  48. }
  49. type RegistryCreateConfigOptions struct {
  50. Common RegistryCreateHarborOptions `json:"common"`
  51. Harbor RegistryCreateHarborOptions `json:"harbor"`
  52. }
  53. type RegistryCreateOptions struct {
  54. RegistryGetOptions
  55. TYPE string `help:"Repository type" choices:"common|harbor" json:"type"`
  56. URL string `help:"Repository url" json:"url"`
  57. Config RegistryCreateConfigOptions `json:"config"`
  58. }
  59. func (o RegistryCreateOptions) Params() (jsonutils.JSONObject, error) {
  60. return jsonutils.Marshal(o), nil
  61. }
  62. type RegistryGetImagesOptions struct {
  63. RegistryGetOptions
  64. }
  65. func (o RegistryGetImagesOptions) Params() (jsonutils.JSONObject, error) {
  66. return nil, nil
  67. }
  68. type RegistryGetImageTagsOptions struct {
  69. RegistryGetOptions
  70. REPOSITORY string `help:"image repository, e.g. 'yunion/region'"`
  71. }
  72. func (o RegistryGetImageTagsOptions) Params() (jsonutils.JSONObject, error) {
  73. return jsonutils.Marshal(map[string]interface{}{
  74. "repository": o.REPOSITORY,
  75. }), nil
  76. }
  77. type RegistryPublicOptions struct {
  78. ID []string `help:"ID or name of image" json:"-"`
  79. Scope string `help:"sharing scope" choices:"system|domain|project" json:"scope"`
  80. SharedProjects []string `help:"Share to projects" json:"shared_projects"`
  81. SharedDomains []string `help:"Share to domains" json:"shared_domains"`
  82. }
  83. func (o RegistryPublicOptions) Params() (jsonutils.JSONObject, error) {
  84. return jsonutils.Marshal(o), nil
  85. }
  86. func (o RegistryPublicOptions) GetIds() []string {
  87. return o.ID
  88. }