Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
build:
runs-on: ubuntu-24.04
env:
HUGO_VERSION: 0.111.2
HUGO_VERSION: 0.142.0

steps:
- name: Install Hugo
Expand Down
12 changes: 8 additions & 4 deletions clm/internal/manifests/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,28 @@ func Generate(manifestSources []string, valuesSources []string, reconcilerName s

var generator manifests.Generator
if _, err = fs.Stat(fsys, "Chart.yaml"); err == nil {
generator, err = helm.NewHelmGenerator(fsys, "", clnt)
generator, err = helm.NewHelmGenerator(fsys, "", nil)
if err != nil {
return nil, err
}
} else if errors.Is(err, fs.ErrNotExist) {
generator, err = kustomize.NewKustomizeGenerator(fsys, "", clnt, kustomize.KustomizeGeneratorOptions{})
generator, err = kustomize.NewKustomizeGenerator(fsys, "", nil, kustomize.KustomizeGeneratorOptions{})
if err != nil {
return nil, err
}
} else {
return nil, err
}

// TODO: what about component and component digest
releaseComponent := componentFromRelease(release, allValues)
// TODO: what about component digest
generateCtx := component.NewContext(context.TODO()).
WithReconcilerName(reconcilerName).
WithLocalClient(clnt).
WithClient(clnt).
WithComponent(componentFromRelease(release, allValues)).
WithComponent(releaseComponent).
WithComponentName(releaseComponent.GetName()).
WithComponentNamespace(releaseComponent.GetNamespace()).
WithComponentDigest("")
objects, err := generator.Generate(generateCtx, release.GetNamespace(), release.GetName(), types.UnstructurableMap(allValues))
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ func (s *PolicySpec) GetDeletePolicy() reconciler.DeletePolicy {
return s.DeletePolicy
}

func (s *PolicySpec) GetMissingNamespacesPolicy() reconciler.MissingNamespacesPolicy {
return s.MissingNamespacesPolicy
}

// Check if state is Ready.
func (s *Status) IsReady() bool {
// caveat: this operates only on the status, so it does not check that observedGeneration == generation
Expand Down
59 changes: 51 additions & 8 deletions pkg/component/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,33 @@ import (
)

type (
reconcilerNameContextKeyType struct{}
clientContextKeyType struct{}
componentContextKeyType struct{}
componentDigestContextKeyType struct{}
reconcilerNameContextKeyType struct{}
localClientContextKeyType struct{}
clientContextKeyType struct{}
componentContextKeyType struct{}
componentNameContextKeyType struct{}
componentNamespaceContextKeyType struct{}
componentDigestContextKeyType struct{}
)

var (
reconcilerNameContextKey = reconcilerNameContextKeyType{}
clientContextKey = clientContextKeyType{}
componentContextKey = componentContextKeyType{}
componentDigestContextKey = componentDigestContextKeyType{}
reconcilerNameContextKey = reconcilerNameContextKeyType{}
localClientContextKey = localClientContextKeyType{}
clientContextKey = clientContextKeyType{}
componentContextKey = componentContextKeyType{}
componentNameContextKey = componentNameContextKeyType{}
componentNamespaceContextKey = componentNamespaceContextKeyType{}
componentDigestContextKey = componentDigestContextKeyType{}
)

type Context interface {
context.Context
WithReconcilerName(reconcilerName string) Context
WithLocalClient(clnt cluster.Client) Context
WithClient(clnt cluster.Client) Context
WithComponent(component Component) Context
WithComponentName(componentName string) Context
WithComponentNamespace(componentNamespace string) Context
WithComponentDigest(componentDigest string) Context
}

Expand All @@ -46,6 +55,10 @@ func (c *contextImpl) WithReconcilerName(reconcilerName string) Context {
return &contextImpl{Context: context.WithValue(c, reconcilerNameContextKey, reconcilerName)}
}

func (c *contextImpl) WithLocalClient(clnt cluster.Client) Context {
return &contextImpl{Context: context.WithValue(c, localClientContextKey, clnt)}
}

func (c *contextImpl) WithClient(clnt cluster.Client) Context {
return &contextImpl{Context: context.WithValue(c, clientContextKey, clnt)}
}
Expand All @@ -54,6 +67,14 @@ func (c *contextImpl) WithComponent(component Component) Context {
return &contextImpl{Context: context.WithValue(c, componentContextKey, component)}
}

func (c *contextImpl) WithComponentName(componentName string) Context {
return &contextImpl{Context: context.WithValue(c, componentNameContextKey, componentName)}
}

func (c *contextImpl) WithComponentNamespace(componentNamespace string) Context {
return &contextImpl{Context: context.WithValue(c, componentNamespaceContextKey, componentNamespace)}
}

func (c *contextImpl) WithComponentDigest(componentDigest string) Context {
return &contextImpl{Context: context.WithValue(c, componentDigestContextKey, componentDigest)}
}
Expand All @@ -65,20 +86,42 @@ func ReconcilerNameFromContext(ctx context.Context) (string, error) {
return "", fmt.Errorf("reconciler name not found in context")
}

func LocalClientFromContext(ctx context.Context) (cluster.Client, error) {
if clnt, ok := ctx.Value(localClientContextKey).(cluster.Client); ok {
return clnt, nil
}
return nil, fmt.Errorf("local client not found in context")
}

func ClientFromContext(ctx context.Context) (cluster.Client, error) {
if clnt, ok := ctx.Value(clientContextKey).(cluster.Client); ok {
return clnt, nil
}
return nil, fmt.Errorf("client not found in context")
}

// TODO: should this method be parameterized?
func ComponentFromContext(ctx context.Context) (Component, error) {
if component, ok := ctx.Value(componentContextKey).(Component); ok {
return component, nil
}
return nil, fmt.Errorf("component not found in context")
}

func ComponentNameFromContext(ctx context.Context) (string, error) {
if componentName, ok := ctx.Value(componentNameContextKey).(string); ok {
return componentName, nil
}
return "", fmt.Errorf("component name not found in context")
}

func ComponentNamespaceFromContext(ctx context.Context) (string, error) {
if componentNamespace, ok := ctx.Value(componentNamespaceContextKey).(string); ok {
return componentNamespace, nil
}
return "", fmt.Errorf("component namespace not found in context")
}

func ComponentDigestFromContext(ctx context.Context) (string, error) {
if componentDigest, ok := ctx.Value(componentDigestContextKey).(string); ok {
return componentDigest, nil
Expand Down
Loading