Skip to content

Commit 36e9dee

Browse files
committed
f
1 parent 5e1d5ac commit 36e9dee

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

cmd/installer/cli/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func preRunInstallCommon(cmd *cobra.Command, flags *InstallCmdFlags, rc runtimec
401401
if err != nil {
402402
var notALicenseFileErr helpers.ErrNotALicenseFile
403403
if errors.As(err, &notALicenseFileErr) {
404-
return fmt.Errorf("license file is not a valid license file")
404+
return fmt.Errorf("failed to parse the license file at %q, please ensure it is not corrupt: %w", flags.licenseFile, err)
405405
}
406406

407407
return fmt.Errorf("failed to parse license file: %w", err)

pkg/helpers/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type ErrNotALicenseFile struct {
1414
}
1515

1616
func (e ErrNotALicenseFile) Error() string {
17-
return fmt.Sprintf("not a license file: %v", e.Err)
17+
return e.Err.Error()
1818
}
1919

2020
// ParseEndUserConfig parses the end user configuration from the given file.

pkg/helpers/parse_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,13 @@ func TestParseLicense(t *testing.T) {
132132
wantErr: ErrNotALicenseFile{},
133133
},
134134
{
135-
name: "valid YAML but not a license succeeds (no validation)",
135+
name: "valid YAML but not a license returns ErrNotALicenseFile",
136136
fpath: "not-license.yaml",
137137
fileContent: `apiVersion: v1
138138
kind: ConfigMap
139139
metadata:
140140
name: test`,
141-
expected: &kotsv1beta1.License{
142-
TypeMeta: metav1.TypeMeta{
143-
APIVersion: "v1",
144-
Kind: "ConfigMap",
145-
},
146-
ObjectMeta: metav1.ObjectMeta{
147-
Name: "test",
148-
},
149-
},
141+
wantErr: ErrNotALicenseFile{},
150142
},
151143
{
152144
name: "valid license",
@@ -178,12 +170,17 @@ spec:
178170
name: "minimal valid license",
179171
fpath: "minimal-license.yaml",
180172
fileContent: `apiVersion: kots.io/v1beta1
181-
kind: License`,
173+
kind: License
174+
spec:
175+
licenseID: "test-license-id"`,
182176
expected: &kotsv1beta1.License{
183177
TypeMeta: metav1.TypeMeta{
184178
APIVersion: "kots.io/v1beta1",
185179
Kind: "License",
186180
},
181+
Spec: kotsv1beta1.LicenseSpec{
182+
LicenseID: "test-license-id",
183+
},
187184
},
188185
},
189186
}

0 commit comments

Comments
 (0)