| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- // Copyright 2019 Yunion
- //
- // 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.
- package k8s
- import (
- "yunion.io/x/jsonutils"
- "yunion.io/x/onecloud/pkg/mcclient/options"
- )
- type RepoListOptions struct {
- options.BaseListOptions
- Type string `help:"Helm repostitory type" json:"type" choices:"internal|external"`
- }
- func (o *RepoListOptions) Params() (jsonutils.JSONObject, error) {
- params, err := o.BaseListOptions.Params()
- if err != nil {
- return nil, err
- }
- if o.Type != "" {
- params.Add(jsonutils.NewString(o.Type), "type")
- }
- return params, nil
- }
- type RepoGetOptions struct {
- NAME string `help:"ID or name of the repo"`
- }
- func (o *RepoGetOptions) GetId() string {
- return o.NAME
- }
- func (o *RepoGetOptions) Params() (jsonutils.JSONObject, error) {
- return nil, nil
- }
- type RepoCreateOptions struct {
- RepoGetOptions
- Type string `help:"Repository type" choices:"internal|external"`
- URL string `help:"Repository url"`
- Public bool `help:"Make repostitory public"`
- Backend string `help:"Repository backend" choices:"common|nexus"`
- Username string `help:"Repository auth username"`
- Password string `help:"Repository auth password"`
- }
- func (o RepoCreateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.NewDict()
- params.Add(jsonutils.NewString(o.NAME), "name")
- params.Add(jsonutils.NewString(o.URL), "url")
- if o.Type != "" {
- params.Add(jsonutils.NewString(o.Type), "type")
- }
- if o.Public {
- params.Add(jsonutils.JSONTrue, "is_public")
- }
- if o.Backend != "" {
- params.Add(jsonutils.NewString(o.Backend), "backend")
- }
- if o.Username != "" {
- params.Add(jsonutils.NewString(o.Username), "username")
- }
- if o.Password != "" {
- params.Add(jsonutils.NewString(o.Password), "password")
- }
- return params, nil
- }
- type RepoUpdateOptions struct {
- RepoGetOptions
- Name string `help:"Repository name to change"`
- Url string `help:"Repository url to change"`
- Username string `help:"Repository auth username"`
- Password string `help:"Repository auth password"`
- }
- func (o RepoUpdateOptions) GetId() string {
- return o.NAME
- }
- func (o RepoUpdateOptions) Params() (jsonutils.JSONObject, error) {
- params := jsonutils.NewDict()
- if o.Name != "" {
- params.Add(jsonutils.NewString(o.Name), "name")
- }
- if o.Url != "" {
- params.Add(jsonutils.NewString(o.Url), "url")
- }
- if o.Username != "" {
- params.Add(jsonutils.NewString(o.Username), "username")
- }
- if o.Password != "" {
- params.Add(jsonutils.NewString(o.Password), "password")
- }
- return params, nil
- }
- type RepoPublicOptions struct {
- ID string `help:"ID or name of repo" json:"-"`
- Scope string `help:"sharing scope" choices:"system|domain"`
- SharedDomains []string `help:"share to domains"`
- }
- func (o *RepoPublicOptions) GetId() string {
- return o.ID
- }
- func (o *RepoPublicOptions) Params() (jsonutils.JSONObject, error) {
- return jsonutils.Marshal(o), nil
- }
|