Add support for base, fed and automation partial provisioning
This commit is contained in:
parent
ef28b1a4af
commit
a05c8ce34f
@ -82,26 +82,29 @@ func canImportConfig(ctx context.Context, s store.Storer) (bool, error) {
|
||||
func collectUnimportedConfigs(ctx context.Context, log *zap.Logger, s store.Storer, sources []string, dec directory.Decoder) (nn []resource.Interface, err error) {
|
||||
var (
|
||||
searchPartialDirectories = []uConfig{
|
||||
{dir: "000_base", fn: nil},
|
||||
{dir: "002_templates", fn: provisionPartialTemplates},
|
||||
{dir: "003_auth", fn: provisionPartialAuthClients},
|
||||
{dir: "200_federation", fn: nil},
|
||||
{dir: "300_automation", fn: nil},
|
||||
}
|
||||
)
|
||||
|
||||
return nn, store.Tx(ctx, s, func(ctx context.Context, s store.Storer) (err error) {
|
||||
for _, d := range searchPartialDirectories {
|
||||
// first, check if we need to import at all
|
||||
if !d.fn(ctx, s, log) {
|
||||
log.Debug("skipping partial config import, changes detected", zap.String("dir", d.dir))
|
||||
if d.fn != nil && !d.fn(ctx, s, log) {
|
||||
log.Debug("skipping partial config import, no changes", zap.String("dir", d.dir))
|
||||
continue
|
||||
}
|
||||
|
||||
if list, e := decodeDirectory(ctx, sources, d.dir, dec); e != nil {
|
||||
return fmt.Errorf("failed to decode template configs: %w", err)
|
||||
return fmt.Errorf("failed to decode configs: %w", err)
|
||||
} else if len(list) == 0 {
|
||||
log.Error("failed to execute partial config import for templates, directory not found or no configs", zap.Any("dir", d))
|
||||
log.Error("failed to execute partial config import, directory not found or no configs", zap.String("dir", d.dir))
|
||||
return
|
||||
} else {
|
||||
log.Debug("partial import", zap.String("dir", d.dir))
|
||||
log.Debug("partial import ready", zap.String("dir", d.dir))
|
||||
nn = append(nn, list...)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user