Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7d49091

Browse files
committed
cleanup
1 parent 64b62ee commit 7d49091

File tree

4 files changed

+10
-53
lines changed

4 files changed

+10
-53
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ CAPI_KIND_CLUSTER_NAME ?= capi-test
231231
# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
232232

233233
# Next release is: v0.3.2
234-
TAG ?= v0.3.2-preview.24
234+
TAG ?= v0.3.2-preview.26
235235
ARCH ?= $(shell go env GOARCH)
236236
ALL_ARCH = amd64 arm arm64
237237

config/default/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
template:
88
spec:
99
containers:
10-
- image: ghcr.io/patricklaabs/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v0.3.2-preview.24
10+
- image: ghcr.io/patricklaabs/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v0.3.2-preview.26
1111
name: manager

config/default/manager_image_patch.yaml-e

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ spec:
77
template:
88
spec:
99
containers:
10-
- image: ghcr.io/patricklaabs/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v0.3.2-preview.24
10+
- image: ghcr.io/patricklaabs/cluster-api-addon-provider-cdk8s/cluster-api-cdk8s-controller:v0.3.2-preview.26
1111
name: manager

controllers/cdk8sappproxy/cdk8sappproxy_controller.go

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -48,40 +48,6 @@ import (
4848
"sigs.k8s.io/controller-runtime/pkg/log"
4949
)
5050

51-
// CommandExecutor defines an interface for running external commands.
52-
type CommandExecutor interface {
53-
CombinedOutput() ([]byte, error)
54-
SetDir(dir string)
55-
}
56-
57-
// RealCmdRunner is a concrete implementation of CommandExecutor that runs actual commands.
58-
type RealCmdRunner struct {
59-
Name string
60-
Args []string
61-
Dir string
62-
CommanderFunc func(command string, args ...string) ([]byte, error)
63-
}
64-
65-
func (rcr *RealCmdRunner) SetDir(dir string) {
66-
rcr.Dir = dir
67-
}
68-
69-
func (rcr *RealCmdRunner) CombinedOutput() ([]byte, error) {
70-
if rcr.CommanderFunc != nil {
71-
return rcr.CommanderFunc(rcr.Name, rcr.Args...)
72-
}
73-
cmd := exec.Command(rcr.Name, rcr.Args...)
74-
if rcr.Dir != "" {
75-
cmd.Dir = rcr.Dir
76-
}
77-
78-
return cmd.CombinedOutput()
79-
}
80-
81-
var cmdRunnerFactory = func(name string, args ...string) CommandExecutor {
82-
return &RealCmdRunner{Name: name, Args: args}
83-
}
84-
8551
func (r *Reconciler) getCdk8sAppProxyForPolling(ctx context.Context, proxyName types.NamespacedName) (*addonsv1alpha1.Cdk8sAppProxy, error) {
8652
cdk8sAppProxy := &addonsv1alpha1.Cdk8sAppProxy{}
8753
if err := r.Get(ctx, proxyName, cdk8sAppProxy); err != nil {
@@ -137,7 +103,7 @@ func (r *Reconciler) synthesizeAndParseResources(appSourcePath string, logger lo
137103
}
138104

139105
func (r *Reconciler) synthesizeCdk8sApp(appSourcePath string, logger logr.Logger, operation string) error {
140-
logger.Info("Synthesizing cdk8s application", "effectiveSourcePath", appSourcePath, "operation", OperationSynthesize)
106+
logger.Info("Synthesizing cdk8s application", "effectiveSourcePath", appSourcePath, "operation", operation)
141107

142108
// npmInstall := cmdRunnerFactory("npm", "install")
143109
// npmInstall.SetDir(appSourcePath)
@@ -146,16 +112,15 @@ func (r *Reconciler) synthesizeCdk8sApp(appSourcePath string, logger logr.Logger
146112
// logger.Error(err, "npm installation failed", "output", string(output), "operation:", OperationNpmInstall)
147113
// }
148114

149-
synthCmd := cmdRunnerFactory("cdk8s", "synth")
150-
synthCmd.SetDir(appSourcePath)
151-
output, synthErr := synthCmd.CombinedOutput()
152-
if synthErr != nil {
153-
logger.Error(synthErr, "cdk8s synth failed", "output", string(output), "operation", OperationSynthesize)
115+
synth := exec.Command("cdk8s", "synth")
116+
synth.Dir = appSourcePath
117+
if err := synth.Run(); err != nil {
118+
logger.Error(err, "Failed to synth cdk8s application", "effectiveSourcePath", appSourcePath)
154119

155-
return synthErr
120+
return err
156121
}
157122

158-
logger.Info("cdk8s synth successful", "outputSummary", truncateString(string(output), 200), "operation", operation)
123+
logger.Info("Synthesized cdk8s application", "effectiveSourcePath", appSourcePath, "operation", operation)
159124

160125
return nil
161126
}
@@ -382,14 +347,6 @@ func (r *Reconciler) updateStatusWithError(ctx context.Context, cdk8sAppProxy *a
382347
return err
383348
}
384349

385-
func truncateString(str string, num int) string {
386-
if len(str) > num {
387-
return str[0:num] + "..."
388-
}
389-
390-
return str
391-
}
392-
393350
// TODO: This is a naive pluralization and might not work for all kinds.
394351
// A more robust solution would use discovery client or a predefined map.
395352
func getPluralFromKind(kind string) string {

0 commit comments

Comments
 (0)