github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/cmd/cluster/errors.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  	appsv1alpha1 "github.com/1aal/kubeblocks/apis/apps/v1alpha1"
    24  	cfgcore "github.com/1aal/kubeblocks/pkg/configuration/core"
    25  )
    26  
    27  var (
    28  	clusterNotExistErrMessage          = "cluster[name=%s] does not exist. Please check that <cluster name> is spelled correctly."
    29  	componentNotExistErrMessage        = "cluster[name=%s] does not have component[name=%s]. Please check that --component is spelled correctly."
    30  	missingClusterArgErrMassage        = "cluster name should be specified, using --help."
    31  	missingUpdatedParametersErrMessage = "missing updated parameters, using --help."
    32  
    33  	multiComponentsErrorMessage     = "when multi components exist, specify a component, using --component"
    34  	multiConfigTemplateErrorMessage = "when multi config templates exist, specify a config template,  using --config-spec"
    35  	multiConfigFileErrorMessage     = "when multi config files exist, specify a config file, using --config-file"
    36  
    37  	notFoundValidConfigTemplateErrorMessage = "cannot find valid config templates for component[name=%s] in the cluster[name=%s]"
    38  
    39  	notFoundConfigSpecErrorMessage = "cannot find config spec[%s] for component[name=%s] in the cluster[name=%s]"
    40  
    41  	notFoundConfigFileErrorMessage   = "cannot find config file[name=%s] in the configspec[name=%s], all configfiles: %v"
    42  	notSupportFileUpdateErrorMessage = "not supported file[%s] for updating, current supported files: %v"
    43  
    44  	notConfigSchemaPrompt         = "The config template[%s] is not defined in schema and parameter explanation info cannot be generated."
    45  	cue2openAPISchemaFailedPrompt = "The cue schema may not satisfy the conversion constraints of openAPISchema and parameter explanation info cannot be generated."
    46  	restartConfirmPrompt          = "The parameter change incurs a cluster restart, which brings the cluster down for a while. Enter to continue...\n, "
    47  	fullRestartConfirmPrompt      = "The config file[%s] change incurs a cluster restart, which brings the cluster down for a while. Enter to continue...\n, "
    48  	confirmApplyReconfigurePrompt = "Are you sure you want to apply these changes?\n"
    49  )
    50  
    51  func makeClusterNotExistErr(clusterName string) error {
    52  	return cfgcore.MakeError(clusterNotExistErrMessage, clusterName)
    53  }
    54  
    55  func makeComponentNotExistErr(clusterName, component string) error {
    56  	return cfgcore.MakeError(componentNotExistErrMessage, clusterName, component)
    57  }
    58  
    59  func makeConfigSpecNotExistErr(clusterName, component, configSpec string) error {
    60  	return cfgcore.MakeError(notFoundConfigSpecErrorMessage, configSpec, component, clusterName)
    61  }
    62  
    63  func makeNotFoundTemplateErr(clusterName, component string) error {
    64  	return cfgcore.MakeError(notFoundValidConfigTemplateErrorMessage, component, clusterName)
    65  }
    66  
    67  func makeNotFoundConfigFileErr(configFile, configSpec string, all []string) error {
    68  	return cfgcore.MakeError(notFoundConfigFileErrorMessage, configFile, configSpec, all)
    69  }
    70  
    71  func makeNotSupportConfigFileUpdateErr(configFile string, configSpec appsv1alpha1.ComponentConfigSpec) error {
    72  	return cfgcore.MakeError(notSupportFileUpdateErrorMessage, configFile, configSpec.Keys)
    73  }
    74  
    75  func makeMissingClusterNameErr() error {
    76  	return cfgcore.MakeError(missingClusterArgErrMassage)
    77  }