本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/server/api/validation.ValidateNodeConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang ValidateNodeConfig函数的具体用法?Golang ValidateNodeConfig怎么用?Golang ValidateNodeConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidateNodeConfig函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Check
func (d NodeConfigCheck) Check() types.DiagnosticResult {
r := types.NewDiagnosticResult(NodeConfigCheckName)
r.Debug("DH1001", fmt.Sprintf("Looking for node config file at '%s'", d.NodeConfigFile))
nodeConfig, err := configapilatest.ReadAndResolveNodeConfig(d.NodeConfigFile)
if err != nil {
r.Error("DH1002", err, fmt.Sprintf("Could not read node config file '%s':\n(%T) %[2]v", d.NodeConfigFile, err))
return r
}
r.Info("DH1003", fmt.Sprintf("Found a node config file: %[1]s", d.NodeConfigFile))
results := configvalidation.ValidateNodeConfig(nodeConfig, nil)
if len(results.Errors) > 0 {
errText := fmt.Sprintf("Validation of node config file '%s' failed:\n", d.NodeConfigFile)
for _, err := range results.Errors {
errText += fmt.Sprintf("%v\n", err)
}
r.Error("DH1004", nil, errText)
}
if len(results.Warnings) > 0 {
warnText := fmt.Sprintf("Validation of node config file '%s' warned:\n", d.NodeConfigFile)
for _, warn := range results.Warnings {
warnText += fmt.Sprintf("%v\n", warn)
}
r.Warn("DH1005", nil, warnText)
}
return r
}
示例2: Run
// Run runs the node config validation and returns the result of the validation as a boolean as well as any errors
// that occurred trying to validate the file
func (o *ValidateNodeConfigOptions) Run() (ok bool, err error) {
nodeConfig, err := configapilatest.ReadAndResolveNodeConfig(o.NodeConfigFile)
if err != nil {
return true, err
}
results := validation.ValidateNodeConfig(nodeConfig, nil)
writer := tabwriter.NewWriter(o.Out, minColumnWidth, tabWidth, padding, padchar, flags)
err = prettyPrintValidationResults(results, writer)
if err != nil {
return len(results.Errors) == 0, fmt.Errorf("could not print results: %v", err)
}
writer.Flush()
return len(results.Errors) == 0, nil
}
示例3: Check
func (d NodeConfigCheck) Check() types.DiagnosticResult {
r := types.NewDiagnosticResult(NodeConfigCheckName)
r.Debug("DH1001", fmt.Sprintf("Looking for node config file at '%s'", d.NodeConfigFile))
nodeConfig, err := configapilatest.ReadAndResolveNodeConfig(d.NodeConfigFile)
if err != nil {
r.Error("DH1002", err, fmt.Sprintf("Could not read node config file '%s':\n(%T) %[2]v", d.NodeConfigFile, err))
return r
}
r.Info("DH1003", fmt.Sprintf("Found a node config file: %[1]s", d.NodeConfigFile))
for _, err := range configvalidation.ValidateNodeConfig(nodeConfig) {
r.Error("DH1004", err, fmt.Sprintf("Validation of node config file '%s' failed:\n(%T) %[2]v", d.NodeConfigFile, err))
}
return r
}
示例4: RunNode
// RunNode takes the options and:
// 1. Creates certs if needed
// 2. Reads fully specified node config OR builds a fully specified node config from the args
// 3. Writes the fully specified node config and exits if needed
// 4. Starts the node based on the fully specified config
func (o NodeOptions) RunNode() error {
if !o.IsRunFromConfig() || o.IsWriteConfigOnly() {
glog.V(2).Infof("Generating node configuration")
if err := o.CreateNodeConfig(); err != nil {
return err
}
}
if o.IsWriteConfigOnly() {
return nil
}
var nodeConfig *configapi.NodeConfig
var err error
if o.IsRunFromConfig() {
nodeConfig, err = configapilatest.ReadAndResolveNodeConfig(o.ConfigFile)
} else {
nodeConfig, err = o.NodeArgs.BuildSerializeableNodeConfig()
}
if err != nil {
return err
}
validationResults := validation.ValidateNodeConfig(nodeConfig, nil)
if len(validationResults.Warnings) != 0 {
for _, warning := range validationResults.Warnings {
glog.Warningf("%v", warning)
}
}
if len(validationResults.Errors) != 0 {
return kerrors.NewInvalid("NodeConfig", o.ConfigFile, validationResults.Errors)
}
_, kubeClientConfig, err := configapi.GetKubeClient(nodeConfig.MasterKubeConfig)
if err != nil {
return err
}
glog.Infof("Starting a node connected to %s", kubeClientConfig.Host)
if err := StartNode(*nodeConfig); err != nil {
return err
}
return nil
}
示例5: RunNode
// RunNode takes the options and:
// 1. Creates certs if needed
// 2. Reads fully specified node config OR builds a fully specified node config from the args
// 3. Writes the fully specified node config and exits if needed
// 4. Starts the node based on the fully specified config
func (o NodeOptions) RunNode() error {
if !o.IsRunFromConfig() || o.IsWriteConfigOnly() {
glog.V(2).Infof("Generating node configuration")
if err := o.CreateNodeConfig(); err != nil {
return err
}
}
if o.IsWriteConfigOnly() {
return nil
}
var nodeConfig *configapi.NodeConfig
var err error
if o.IsRunFromConfig() {
nodeConfig, err = configapilatest.ReadAndResolveNodeConfig(o.ConfigFile)
} else {
nodeConfig, err = o.NodeArgs.BuildSerializeableNodeConfig()
}
if err != nil {
return err
}
validationResults := validation.ValidateNodeConfig(nodeConfig, nil)
if len(validationResults.Warnings) != 0 {
for _, warning := range validationResults.Warnings {
glog.Warningf("%v", warning)
}
}
if len(validationResults.Errors) != 0 {
return kerrors.NewInvalid(configapi.Kind("NodeConfig"), o.ConfigFile, validationResults.Errors)
}
if err := ValidateRuntime(nodeConfig, o.NodeArgs.Components); err != nil {
return err
}
if err := StartNode(*nodeConfig, o.NodeArgs.Components); err != nil {
return err
}
return nil
}