Skip to content
Open
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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250729184643-f055e67a064d
github.com/replicatedhq/kotskinds v0.0.0-20251106194120-8ae701787e22
github.com/replicatedhq/kotskinds v0.0.0-20251125152515-acc84923a4f5
github.com/replicatedhq/kurlkinds v1.5.0
github.com/replicatedhq/troubleshoot v0.122.0
github.com/robfig/cron v1.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,8 @@ github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250729184643-f055e67a
github.com/replicatedhq/embedded-cluster/kinds v1.15.1-0.20250729184643-f055e67a064d/go.mod h1:gZdtXCAVJt0a5Ry64Jlaeph7qh+IGsAkq4P0PE6XiZI=
github.com/replicatedhq/kotskinds v0.0.0-20251106194120-8ae701787e22 h1:WXzSYpKmNtTHk7W1nQXYVYWIv6pRtjs2rarVVJZ9cfw=
github.com/replicatedhq/kotskinds v0.0.0-20251106194120-8ae701787e22/go.mod h1:+k4PHo2wukoU9kdiKrqqgi89Wmj+9AiwppYGVK11zig=
github.com/replicatedhq/kotskinds v0.0.0-20251125152515-acc84923a4f5 h1:NaLh1hQbIrjU/hIppLGEnOWm6FvFdOwNrQP101K7H9g=
github.com/replicatedhq/kotskinds v0.0.0-20251125152515-acc84923a4f5/go.mod h1:+k4PHo2wukoU9kdiKrqqgi89Wmj+9AiwppYGVK11zig=
github.com/replicatedhq/kurlkinds v1.5.0 h1:zZ0PKNeh4kXvSzVGkn62DKTo314GxhXg1TSB3azURMc=
github.com/replicatedhq/kurlkinds v1.5.0/go.mod h1:rUpBMdC81IhmJNCWMU/uRsMETv9P0xFoMvdSP/TAr5A=
github.com/replicatedhq/termui/v3 v3.1.1-0.20200811145416-f40076d26851 h1:eRlNDHxGfVkPCRXbA4BfQJvt5DHjFiTtWy3R/t4djyY=
Expand Down
2 changes: 2 additions & 0 deletions pkg/base/replicated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,7 @@ spec:
appSlug: my-app
channelName: stable
endpoint: https://example.com
customerID: customer-id
Comment on lines 2027 to +2028
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Suggested change
endpoint: https://example.com
customerID: customer-id
endpoint: https://example.com
customerID: customer-id

customerName: My Customer
customerEmail:
licenseID: "1234"
Expand Down Expand Up @@ -2086,6 +2087,7 @@ spec:
AppSlug: "my-app",
ChannelName: "stable",
Endpoint: "https://example.com",
CustomerID: "customer-id",
Comment on lines 2089 to +2090
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would this pass with wrong indentation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or does yaml parse just not care about tabs vs spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't :), was trying to figure out why it's failing. thanks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah!

CustomerName: "My Customer",
CustomerEmail: "",
LicenseID: "1234",
Expand Down
14 changes: 8 additions & 6 deletions pkg/handlers/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type SyncLicenseRequest struct {

type LicenseResponse struct {
ID string `json:"id"`
CustomerID string `json:"customerID"`
Assignee string `json:"assignee"`
ExpiresAt time.Time `json:"expiresAt"`
ChannelName string `json:"channelName"`
Expand Down Expand Up @@ -224,11 +225,11 @@ func getLicenseEntitlements(license *licensewrapper.LicenseWrapper) ([]Entitleme
// Use wrapper method to get entitlements (works for both v1beta1 and v1beta2)
for key, entitlement := range license.GetEntitlements() {
if key == "expires_at" {
if entitlement.GetValue().StrVal == "" {
if entitlement.GetValue().(string) == "" {
continue
}

expiration, err := time.Parse(time.RFC3339, entitlement.GetValue().StrVal)
expiration, err := time.Parse(time.RFC3339, entitlement.GetValue().(string))
if err != nil {
return nil, time.Time{}, errors.Wrap(err, "failed to parse expiration date")
}
Expand All @@ -241,7 +242,7 @@ func getLicenseEntitlements(license *licensewrapper.LicenseWrapper) ([]Entitleme
EntitlementResponse{
Title: entitlement.GetTitle(),
Label: key,
Value: (&val).Value(),
Value: val,
ValueType: entitlement.GetValueType(),
})
}
Expand Down Expand Up @@ -597,8 +598,8 @@ func (h *Handler) GetPlatformLicenseCompatibility(w http.ResponseWriter, r *http

for k, e := range license.GetEntitlements() {
if k == "expires_at" {
if e.GetValue().StrVal != "" {
platformLicense.ExpirationTime = e.GetValue().StrVal
if e.GetValue().(string) != "" {
platformLicense.ExpirationTime = e.GetValue().(string)
}
continue
}
Expand All @@ -608,7 +609,7 @@ func (h *Handler) GetPlatformLicenseCompatibility(w http.ResponseWriter, r *http
Field: k,
Title: e.GetTitle(),
Type: e.GetValueType(),
Value: (&val).Value(),
Value: val,
HideFromCustomer: e.IsHidden(),
}

Expand Down Expand Up @@ -722,6 +723,7 @@ func licenseResponseFromLicense(license *licensewrapper.LicenseWrapper, app *app

response := LicenseResponse{
ID: license.GetLicenseID(),
CustomerID: license.GetCustomerID(),
Assignee: license.GetCustomerName(),
ChannelName: license.GetChannelName(),
LicenseSequence: license.GetLicenseSequence(),
Expand Down
8 changes: 8 additions & 0 deletions pkg/handlers/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
appSlug: test-app
channelID: test-channel-id
channelName: Stable
customerID: test-customer-id
customerName: Test Customer
endpoint: https://replicated.app
entitlements:
Expand All @@ -59,6 +60,7 @@ spec:

// Verify response fields
assert.Equal(t, "test-license-id", response.ID)
assert.Equal(t, "test-customer-id", response.CustomerID)
assert.Equal(t, "Test Customer", response.Assignee)
assert.Equal(t, "Stable", response.ChannelName)
assert.Equal(t, "trial", response.LicenseType)
Expand Down Expand Up @@ -101,6 +103,7 @@ spec:
appSlug: test-app-v2
channelID: test-channel-id-v2
channelName: Beta
customerID: test-customer-id-v2
customerName: Test Customer V2
endpoint: https://replicated.app
entitlements:
Expand Down Expand Up @@ -128,6 +131,7 @@ spec:

// Verify response fields - should be identical format to v1beta1
assert.Equal(t, "test-license-id-v2", response.ID)
assert.Equal(t, "test-customer-id-v2", response.CustomerID)
assert.Equal(t, "Test Customer V2", response.Assignee)
assert.Equal(t, "Beta", response.ChannelName)
assert.Equal(t, "prod", response.LicenseType)
Expand Down Expand Up @@ -171,6 +175,7 @@ spec:
appSlug: same-app
channelID: same-channel
channelName: Same Channel
customerID: same-customer-id
customerName: Same Customer
endpoint: https://replicated.app
isAirgapSupported: true
Expand All @@ -187,6 +192,7 @@ spec:
appSlug: same-app
channelID: same-channel
channelName: Same Channel
customerID: same-customer-id
customerName: Same Customer
endpoint: https://replicated.app
isAirgapSupported: true
Expand All @@ -207,6 +213,7 @@ spec:

// Compare key fields - they should be identical
assert.Equal(t, v1Response.ID, v2Response.ID, "ID should match")
assert.Equal(t, v1Response.CustomerID, v2Response.CustomerID, "CustomerID should match")
assert.Equal(t, v1Response.Assignee, v2Response.Assignee, "Assignee should match")
assert.Equal(t, v1Response.ChannelName, v2Response.ChannelName, "ChannelName should match")
assert.Equal(t, v1Response.LicenseType, v2Response.LicenseType, "LicenseType should match")
Expand Down Expand Up @@ -374,6 +381,7 @@ func TestGetLicense_V1Beta2(t *testing.T) {
expectSuccess: true,
expectedLicense: func(t *testing.T, license LicenseResponse) {
assert.Equal(t, "test-license-id", license.ID)
assert.Equal(t, "test-customer-id", license.CustomerID)
assert.Equal(t, "Test Customer", license.Assignee)
assert.Equal(t, "Stable", license.ChannelName)
assert.Equal(t, "trial", license.LicenseType)
Expand Down
4 changes: 2 additions & 2 deletions pkg/license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func LicenseIsExpired(license *licensewrapper.LicenseWrapper) (bool, error) {
if val.GetValueType() != "" && val.GetValueType() != "String" {
return false, errors.Errorf("expires_at must be type String: %s", val.GetValueType())
}
if val.GetValue().StrVal == "" {
if val.GetValue().(string) == "" {
return false, nil
}

parsed, err := time.Parse(time.RFC3339, val.GetValue().StrVal)
parsed, err := time.Parse(time.RFC3339, val.GetValue().(string))
if err != nil {
return false, errors.Wrap(err, "failed to parse expiration time")
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/license/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ func verifyLicenseData(outerLicense *kotsv1beta1.License, innerLicense *kotsv1be
if outerLicense.Spec.Endpoint != innerLicense.Spec.Endpoint {
return fmt.Errorf("\"endpoint\" field has changed to %q (license) from %q (within signature)", outerLicense.Spec.Endpoint, innerLicense.Spec.Endpoint)
}
if outerLicense.Spec.ReplicatedProxyDomain != innerLicense.Spec.ReplicatedProxyDomain {
return fmt.Errorf("\"replicatedProxyDomain\" field has changed to %q (license) from %q (within signature)", outerLicense.Spec.ReplicatedProxyDomain, innerLicense.Spec.ReplicatedProxyDomain)
}
if outerLicense.Spec.CustomerName != innerLicense.Spec.CustomerName {
return fmt.Errorf("\"CustomerName\" field has changed to %q (license) from %q (within signature)", outerLicense.Spec.CustomerName, innerLicense.Spec.CustomerName)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/license/testdata/valid-v1beta2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
spec:
licenseID: test-license-id
licenseType: trial
customerID: test-customer-id
customerName: Test Customer
appSlug: test-app
channelID: "1"
Expand Down
4 changes: 3 additions & 1 deletion pkg/template/license_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (ctx licenseCtx) licenseFieldValue(name string) string {
return ctx.License.GetLicenseID()
case "licenseSequence":
return strconv.FormatInt(ctx.License.GetLicenseSequence(), 10)
case "customerID":
return ctx.License.GetCustomerID()
case "customerName":
return ctx.License.GetCustomerName()
case "signature":
Expand Down Expand Up @@ -98,7 +100,7 @@ func (ctx licenseCtx) licenseFieldValue(name string) string {
entitlement, ok := entitlements[name]
if ok {
value := entitlement.GetValue()
return fmt.Sprintf("%v", (&value).Value())
return fmt.Sprintf("%v", value)
}
return ""
}
Expand Down
12 changes: 12 additions & 0 deletions pkg/template/license_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,18 @@ func TestLicenseCtx_licenseFieldValue(t *testing.T) {
fieldName: "channelName",
want: "stable",
},
{
name: "built-in customerID",
License: licensewrapper.LicenseWrapper{
V1: &kotsv1beta1.License{
Spec: kotsv1beta1.LicenseSpec{
CustomerID: "123",
},
},
},
fieldName: "customerID",
want: "123",
},
{
name: "built-in customerName",
License: licensewrapper.LicenseWrapper{
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions pkg/tests/pull/cases/kotskinds/upstream/userdata/license.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions pkg/tests/pull/cases/needsconfig/upstream/userdata/license.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions pkg/tests/pull/cases/subcharts/kotsKinds/license.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions pkg/upstream/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ license: |
appSlug: app-slug
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
endpoint: https://replicated.app
entitlements:
Expand Down Expand Up @@ -489,6 +490,7 @@ global:
replicated:
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
dockerconfigjson: eyJhdXRocyI6eyJjdXN0b20ucHJveHkuY29tIjp7ImF1dGgiOiJURWxEUlU1VFJWOUpSRHBzYVdObGJuTmxMV2xrIn0sImN1c3RvbS5yZWdpc3RyeS5jb20iOnsiYXV0aCI6IlRFbERSVTVUUlY5SlJEcHNhV05sYm5ObExXbGsifX19
licenseFields:
Expand Down Expand Up @@ -729,6 +731,7 @@ image:
appSlug: app-slug
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
endpoint: https://replicated.app
entitlements:
Expand All @@ -747,6 +750,7 @@ global:
replicated:
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
dockerconfigjson: eyJhdXRocyI6eyJjdXN0b20ucHJveHkuY29tIjp7ImF1dGgiOiJURWxEUlU1VFJWOUpSRHBzYVdObGJuTmxMV2xrIn0sImN1c3RvbS5yZWdpc3RyeS5jb20iOnsiYXV0aCI6IlRFbERSVTVUUlY5SlJEcHNhV05sYm5ObExXbGsifX19
licenseFields:
Expand Down Expand Up @@ -996,6 +1000,7 @@ global:
some: value
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
dockerconfigjson: eyJhdXRocyI6eyJjdXN0b20ucHJveHkuY29tIjp7ImF1dGgiOiJURWxEUlU1VFJWOUpSRHBzYVdObGJuTmxMV2xrIn0sImN1c3RvbS5yZWdpc3RyeS5jb20iOnsiYXV0aCI6IlRFbERSVTVUUlY5SlJEcHNhV05sYm5ObExXbGsifX19
licenseFields:
Expand Down Expand Up @@ -1040,6 +1045,7 @@ global:
appSlug: app-slug
channelName: channel-name
customerEmail: customer@example.com
customerID: customer-id
customerName: Customer Name
endpoint: https://replicated.app
entitlements:
Expand Down Expand Up @@ -1301,6 +1307,7 @@ some: value
},
},
},
CustomerID: "customer-id",
CustomerEmail: "customer@example.com",
CustomerName: "Customer Name",
LicenseType: "dev",
Expand Down
Loading