Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error if annotation patch path can't be found, update dependencies #99

Merged
merged 2 commits into from
Apr 29, 2024
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
9 changes: 1 addition & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.20.x
- name: Restore Go cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version: 1.22.x
- name: Tests
run: make test
- name: Send go coverage report
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Setup yq
uses: chrisdickinson/setup-yq@3d931309f27270ebbafd53f2daee773a82ea1822 #v1.0.1
with:
yq-version: v4.34.1
- name: Restore Go cache
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: fmt
run: make fmt
- name: vet
Expand All @@ -50,4 +43,4 @@ jobs:
git --no-pager diff
echo 'run <make test> and commit changes'
exit 1
fi
fi
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.20'
go-version: '1.22'
- name: Docker Login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
Expand All @@ -38,4 +38,4 @@ jobs:
args: release --rm-dist --skip-validate
env:
RUNNER_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.DOODLE_OSS_BOT}}
GITHUB_TOKEN: ${{ secrets.DOODLE_OSS_BOT}}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rwildcard=$(foreach d,$(wildcard $(addsuffix *,$(1))),$(call rwildcard,$(d)/,$(2
all: lint test build

tidy:
go mod tidy -compat=1.20
go mod tidy -compat=1.22

fmt:
go fmt ./...
Expand Down
365 changes: 182 additions & 183 deletions go.mod

Large diffs are not rendered by default.

1,639 changes: 514 additions & 1,125 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/build/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (h *Helm) validateCRDsPolicy(policy helmv1.CRDsPolicy, defaultValue helmv1.
// composeValues attempts to resolve all v2beta1.ValuesReference resources
// and merges them as defined. Referenced resources are only retrieved once
// to ensure a single version is taken into account during the merge.
func (h *Helm) composeValues(ctx context.Context, db map[ref]*resource.Resource, hr helmv1.HelmRelease) (chartutil.Values, error) {
func (h *Helm) composeValues(_ context.Context, db map[ref]*resource.Resource, hr helmv1.HelmRelease) (chartutil.Values, error) {
result := chartutil.Values{}

for _, v := range hr.Spec.ValuesFrom {
Expand Down
7 changes: 2 additions & 5 deletions internal/helm/postrenderer/post_renderer_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,8 @@ func buildKustomization(fs filesys.FileSystem, dirPath string) (resmap.ResMap, e
defer kustomizeRenderMutex.Unlock()

buildOptions := &krusty.Options{
DoLegacyResourceSort: true,
LoadRestrictions: kustypes.LoadRestrictionsNone,
AddManagedbyLabel: false,
DoPrune: false,
PluginConfig: kustypes.DisabledPluginConfig(),
LoadRestrictions: kustypes.LoadRestrictionsNone,
PluginConfig: kustypes.DisabledPluginConfig(),
}

k := krusty.MakeKustomizer(buildOptions)
Expand Down
56 changes: 23 additions & 33 deletions internal/helm/postrenderer/post_renderer_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package postrenderer

import (
"bytes"

"sigs.k8s.io/kustomize/api/builtins"
"sigs.k8s.io/kustomize/api/provider"
"sigs.k8s.io/kustomize/api/resmap"
"sigs.k8s.io/kustomize/api/types"
"encoding/json"

v2 "github.com/fluxcd/helm-controller/api/v2beta1"
"sigs.k8s.io/kustomize/api/filesys"
kustypes "sigs.k8s.io/kustomize/api/types"
)

func NewPostRendererNamespace(release *v2.HelmRelease) *postRendererNamespace {
Expand All @@ -27,43 +25,35 @@ type postRendererNamespace struct {
}

func (k *postRendererNamespace) Run(renderedManifests *bytes.Buffer) (modifiedManifests *bytes.Buffer, err error) {
resFactory := provider.NewDefaultDepProvider().GetResourceFactory()
resMapFactory := resmap.NewFactory(resFactory)

resMap, err := resMapFactory.NewResMapFromBytes(renderedManifests.Bytes())
if err != nil {
fs := filesys.MakeFsInMemory()
cfg := kustypes.Kustomization{}
cfg.APIVersion = kustypes.KustomizationVersion
cfg.Kind = kustypes.KustomizationKind
cfg.Namespace = k.namespace

// Add rendered Helm output as input resource to the Kustomization.
const input = "helm-output.yaml"
cfg.Resources = append(cfg.Resources, input)
if err := writeFile(fs, input, renderedManifests); err != nil {
return nil, err
}

resWithNamespace := resmap.New()
resWithoutNamespace := resmap.New()

for _, res := range resMap.Resources() {
if res.GetNamespace() == "" {
_ = resWithoutNamespace.Append(res)
} else {
_ = resWithNamespace.Append(res)
}
}

namespaceTransformer := builtins.NamespaceTransformerPlugin{
ObjectMeta: types.ObjectMeta{
Namespace: k.namespace,
},
// Write kustomization config to file.
kustomization, err := json.Marshal(cfg)
if err != nil {
return nil, err
}

if err := namespaceTransformer.Transform(resWithoutNamespace); err != nil {
if err := writeToFile(fs, "kustomization.yaml", kustomization); err != nil {
return nil, err
}

for _, res := range resWithoutNamespace.Resources() {
_ = resWithNamespace.Append(res)
resMap, err := buildKustomization(fs, ".")
if err != nil {
return nil, err
}

yaml, err := resWithNamespace.AsYaml()
yaml, err := resMap.AsYaml()
if err != nil {
return nil, err
}

return bytes.NewBuffer(yaml), nil

}
Loading