github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/cluster/register.go (about) 1 /* 2 Copyright (C) 2022-2023 ApeCloud Co., Ltd 3 4 This file is part of KubeBlocks project 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU Affero General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 package cluster 21 22 import ( 23 "io" 24 ) 25 26 type ClusterType string 27 28 func (t ClusterType) String() string { 29 return string(t) 30 } 31 32 type chartLoader interface { 33 // loadChart loads the chart content during building sub-command 34 loadChart() (io.ReadCloser, error) 35 // GetChartFileName returns the chart file name, include the extension 36 getChartFileName() string 37 // getAlias returns the chart alias, this alias will be used as the command alias 38 getAlias() string 39 // register registers the cluster type as a sub cmd into create cluster command 40 register(subcmd ClusterType) error 41 } 42 43 // ClusterTypeCharts is the map of the cluster type and the chart config 44 // ClusterType is the type of the cluster, the ClusterType t will be used as sub command name, 45 // chartLoader is the interface for the chart config, implement this interface to register cluster type. 46 var ClusterTypeCharts = map[ClusterType]chartLoader{}