Skip to content

Commit 9cd1437

Browse files
authored
> commit always fail (#8)
1 parent dfaaf7d commit 9cd1437

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ func main() {
184184
CAName: "Webhook",
185185
CAOrganization: "SnapshotPod",
186186
DNSName: fmt.Sprintf("%s.%s.svc", func() string {
187-
return os.Getenv("MUTATE_WEBHOOK_NAME")
187+
return os.Getenv("MUTATE_WEBHOOK_SVC_NAME")
188188
}(), ns),
189189
IsReady: ready,
190190
Webhooks: []rotator.WebhookInfo{
191191
{
192-
Name: "snapshot-pod",
192+
Name: os.Getenv("MUTATE_WEBHOOK_NAME"),
193193
Type: rotator.Mutating,
194194
},
195195
},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ toolchain go1.22.2
66

77
require (
88
github.com/containers/image/v5 v5.31.0
9+
github.com/google/go-cmp v0.6.0
910
github.com/google/uuid v1.6.0
1011
github.com/onsi/ginkgo/v2 v2.19.0
1112
github.com/onsi/gomega v1.33.1
@@ -47,7 +48,6 @@ require (
4748
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
4849
github.com/golang/protobuf v1.5.4 // indirect
4950
github.com/google/gnostic-models v0.6.8 // indirect
50-
github.com/google/go-cmp v0.6.0 // indirect
5151
github.com/google/gofuzz v1.2.0 // indirect
5252
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
5353
github.com/gorilla/mux v1.8.1 // indirect

internal/controller/runtime/docker_compatible.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ func (d *dockerCompatibleRuntime) Commit(ctx context.Context, containerID, image
3131
if author != "" {
3232
args = append(args, "--author", author)
3333
}
34-
err := d.execCommand(ctx, args, nil)
35-
return fmt.Errorf("commit failed: %w", err)
34+
if err := d.execCommand(ctx, args, nil); err != nil {
35+
return fmt.Errorf("commit image: %s", err)
36+
}
37+
return nil
3638
}
3739

3840
func (d *dockerCompatibleRuntime) ImageExists(ctx context.Context, image string) bool {
@@ -67,16 +69,20 @@ func (d *dockerCompatibleRuntime) withLoginContextCommands(ctx context.Context,
6769
if err != nil {
6870
return err
6971
}
70-
err = d.execCommand(ctx, args, stdin)
71-
return fmt.Errorf("encounter error after login: %w", err)
72+
if err = d.execCommand(ctx, args, stdin); err != nil {
73+
return fmt.Errorf("after login: %s", err)
74+
}
75+
return nil
7276
}
7377

7478
func (d *dockerCompatibleRuntime) requireLogin(ctx context.Context, auth *Auth) error {
7579
if auth == nil {
7680
return nil
7781
}
78-
err := d.execCommand(ctx, []string{"login", auth.Registry}, nil)
79-
return fmt.Errorf("login failed for: %w", err)
82+
if err := d.execCommand(ctx, []string{"login", auth.Registry}, nil); err != nil {
83+
return fmt.Errorf("login '%s': %s", auth.Registry, err)
84+
}
85+
return nil
8086
}
8187

8288
func (d *dockerCompatibleRuntime) execCommand(ctx context.Context, args []string, stdin io.Reader) error {

manifests/snapshot-pod/templates/deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ spec:
4545
fieldPath: metadata.namespace
4646
- name: TLS_SECRET_NAME
4747
value: {{ include "snapshot-pod.fullname" . }}-tls
48-
- name: MUTATE_WEBHOOK_NAME
48+
# keep same with MutatingWebhookConfiguration name
49+
- name: MUTATE_WEBHOOK_NAME
50+
value: {{ include "snapshot-pod.fullname" . }}
51+
- name: MUTATE_WEBHOOK_SVC_NAME
4952
value: {{ include "snapshot-pod.fullname" . }}-webhook
5053
ports:
5154
- name: health

0 commit comments

Comments
 (0)