kubekey/pkg/project/builtin.go
zuoxuesong-worker 79fa0a4d8c
bugfix: fix builtin package empty graph bug (#2726)
Signed-off-by: xuesongzuo@yunify.com <xuesongzuo@yunify.com>
2025-08-26 03:11:56 +00:00

52 lines
1.4 KiB
Go

//go:build builtin
// +build builtin
/*
Copyright 2024 The KubeSphere Authors.
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 project
import (
"path/filepath"
"github.com/cockroachdb/errors"
kkcorev1 "github.com/kubesphere/kubekey/api/core/v1"
kkprojectv1 "github.com/kubesphere/kubekey/api/project/v1"
"github.com/kubesphere/kubekey/v4/builtin/core"
"github.com/kubesphere/kubekey/v4/pkg/utils"
)
func init() {
builtinProjectFunc = func(playbook kkcorev1.Playbook) (Project, error) {
if playbook.Spec.Playbook == "" {
return nil, errors.New("playbook should not be empty")
}
if filepath.IsAbs(playbook.Spec.Playbook) {
return nil, errors.New("playbook should be relative path base on project.addr")
}
return &project{
FS: core.BuiltinPlaybook,
basePlaybook: playbook.Spec.Playbook,
Playbook: &kkprojectv1.Playbook{},
config: playbook.Spec.Config.Value(),
playbookGraph: utils.NewKahnGraph(),
}, nil
}
}