Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Matovidlo committed Dec 18, 2024
1 parent 1b8582e commit 2dddc86
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
9 changes: 3 additions & 6 deletions internal/pkg/service/templates/api/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ package service
import (
"context"
"fmt"
"github.com/keboola/keboola-as-code/internal/pkg/encoding/jsonnet"
"github.com/keboola/keboola-as-code/internal/pkg/encoding/jsonnet/fsimporter"
"github.com/keboola/keboola-as-code/internal/pkg/filesystem/aferofs/mountfs"
"github.com/keboola/keboola-as-code/internal/pkg/template/jsonnet/function"
"net/http"
"path"
"strconv"
Expand Down Expand Up @@ -261,7 +257,7 @@ func (s *service) UseTemplateVersion(ctx context.Context, d dependencies.Project
}
defer unlockFn(ctx)

s.mapper
/*s.mapper
mountPoint := mountfs.NewMountPoint(repository.CommonDirectoryMountPoint, commonDir)
templateDir, err := aferofs.NewMountFs(templateDir, []mountfs.MountPoint{mountPoint})
if err != nil {
Expand All @@ -277,7 +273,8 @@ func (s *service) UseTemplateVersion(ctx context.Context, d dependencies.Project
}
jsonnetCtx := jsonnet.NewContext().WithCtx(ctx).WithImporter(fsimporter.New(objectsRoot))
jsonnetCtx.NativeFunctionWithAlias(function.SnowflakeWriterComponentID(d.Components()))
jsonnetCtx.NativeFunctionWithAlias(function.SnowflakeWriterComponentID(d.Components()))*/

// Note:
// A very strange code follows.
// Since I did not manage to complete the refactoring - separation of remote and local state.
Expand Down
4 changes: 0 additions & 4 deletions internal/pkg/service/templates/dependencies/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
// apiScope implements APIScope interface.
type apiScope struct {
dependencies.BaseScope
dependencies.ProjectScope
dependencies.PublicScope
dependencies.EtcdClientScope
dependencies.DistributionScope
Expand All @@ -42,7 +41,6 @@ type apiScope struct {

type parentScopes struct {
dependencies.BaseScope
dependencies.ProjectScope
dependencies.PublicScope
dependencies.EtcdClientScope
dependencies.DistributionScope
Expand Down Expand Up @@ -132,8 +130,6 @@ func newAPIScope(ctx context.Context, p *parentScopes, cfg config.Config) (v *ap

d.BaseScope = p.BaseScope

d.ProjectScope = p.ProjectScope

d.PublicScope = p.PublicScope

d.EtcdClientScope = p.EtcdClientScope
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/template/context/load/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ func (c *Context) JsonnetContext() *jsonnet.Context {

func (c *Context) registerJsonnetFunctions() {
c.jsonnetCtx.NativeFunctionWithAlias(function.ComponentIsAvailable(c.components))
//c.jsonnetCtx.NativeFunctionWithAlias(function.SnowflakeWriterComponentID(c.components))
c.jsonnetCtx.NativeFunctionWithAlias(function.SnowflakeWriterComponentID(c.components))
c.jsonnetCtx.NativeFunctionWithAlias(function.HasProjectBackend(c.projectBackends))
}
2 changes: 1 addition & 1 deletion internal/pkg/template/manifest/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (f *file) records() (oms []model.ObjectManifest, err error) {
func (f *file) setRecords(records []model.ObjectManifest) {
// Convert records map to slices
configsMap := make(map[string]*model.ConfigManifestWithRows)
f.Configs = make([]*model.ConfigManifestWithRows, 0)
f.Configs = make([]*model.ConfigManifestWithRows, 0, len(records))

for _, manifest := range records {
// Skip invalid (eg. missing config file)
Expand Down
4 changes: 1 addition & 3 deletions internal/pkg/template/repository/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package manager

import (
"context"
"fmt"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -60,7 +59,6 @@ type dependencies interface {
Telemetry() telemetry.Telemetry
Process() *servicectx.Process
Components() *model.ComponentsMap
ProjectBackends() []string
}

func New(ctx context.Context, d dependencies, defaultRepositories []model.TemplateRepository) (*Manager, error) {
Expand All @@ -74,7 +72,7 @@ func New(ctx context.Context, d dependencies, defaultRepositories []model.Templa
repositoriesInit: &singleflight.Group{},
repositoriesLock: &sync.RWMutex{},
}
fmt.Println("BB: ", d.ProjectBackends())

// Free all repositories on server shutdown
d.Process().OnShutdown(func(ctx context.Context) {
m.Free(ctx)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/template/repository/manager/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (r *CachedRepository) Template(ctx context.Context, reference model.Templat

// Load template
r.d.Logger().Infof(ctx, r.repo.Fs().BasePath())
tmpl, err := loadTemplateOp.Run(ctx, r.d, r.repo, reference, template.Option{ProjectBackend: r.d.ProjectBackends()})
tmpl, err := loadTemplateOp.Run(ctx, r.d, r.repo, reference, template.Option{})
if err != nil {
return nil, errors.Errorf(`cannot load template "%s": %w`, reference.FullName(), err)
}
Expand Down

0 comments on commit 2dddc86

Please sign in to comment.