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

Improve Applications More #90

Merged
merged 1 commit into from
Oct 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
4 changes: 2 additions & 2 deletions charts/core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for deploying Unikorn Core

type: application

version: v0.1.78
appVersion: v0.1.78
version: v0.1.79
appVersion: v0.1.79

icon: https://assets.unikorn-cloud.org/images/logos/dark-on-light/icon.svg

Expand Down
9 changes: 4 additions & 5 deletions charts/core/crds/unikorn-cloud.org_helmapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ spec:
documentation:
description: Documentation defines a URL to 3rd party documentation.
type: string
exported:
description: |-
Exported defines whether the application should be exported to
the user visiable application manager.
type: boolean
icon:
description: Icon is a base64 encoded icon for the application.
format: byte
Expand Down Expand Up @@ -122,6 +117,7 @@ spec:
type: array
name:
description: Name of the application to depend on.
minLength: 1
type: string
required:
- name
Expand All @@ -146,9 +142,11 @@ spec:
properties:
name:
description: Name is the name of the parameter.
minLength: 1
type: string
value:
description: Value is the value of the parameter.
minLength: 1
type: string
required:
- name
Expand All @@ -170,6 +168,7 @@ spec:
Name of the application to require.
That recommendation MUST have a dependency with any constraints
on this application.
minLength: 1
type: string
required:
- name
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/unikorn-cloud/core
go 1.23.2

require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/getkin/kin-openapi v0.128.0
github.com/go-logr/logr v1.4.2
github.com/go-openapi/jsonpointer v0.21.0
github.com/masterminds/semver v1.5.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.31.0
Expand All @@ -26,7 +26,6 @@ require (
)

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
Expand Down Expand Up @@ -81,8 +81,6 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/masterminds/semver v1.5.0 h1:hTxJTTY7tjvnWMrl08O6u3G6BLlKVwxSz01lVac9P8U=
github.com/masterminds/semver v1.5.0/go.mod h1:s7KNT9fnd7edGzwwP7RBX4H0v/CYd5qdOLfkL1V75yg=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
18 changes: 15 additions & 3 deletions pkg/apis/unikorn/v1alpha1/helmapplication_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package v1alpha1
import (
"errors"
"fmt"
"iter"
"strings"
)

Expand All @@ -33,10 +34,21 @@ func CompareHelmApplication(a, b HelmApplication) int {
return strings.Compare(a.Name, b.Name)
}

// Versions returns an iterator over versions.
func (a *HelmApplication) Versions() iter.Seq[*HelmApplicationVersion] {
return func(yield func(*HelmApplicationVersion) bool) {
for i := range a.Spec.Versions {
if !yield(&a.Spec.Versions[i]) {
break
}
}
}
}

func (a *HelmApplication) GetVersion(version SemanticVersion) (*HelmApplicationVersion, error) {
for i := range a.Spec.Versions {
if a.Spec.Versions[i].Version.Equal(&version.Version) {
return &a.Spec.Versions[i], nil
for v := range a.Versions() {
if v.Version.Equal(&version) {
return v, nil
}
}

Expand Down
26 changes: 25 additions & 1 deletion pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"errors"
"net"

"github.com/masterminds/semver"
"github.com/Masterminds/semver/v3"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -43,6 +43,30 @@ type SemanticVersion struct {
semver.Version
}

func (v SemanticVersion) Compare(o *SemanticVersion) int {
return v.Version.Compare(&o.Version)
}

func (v SemanticVersion) Equal(o *SemanticVersion) bool {
return v.Version.Equal(&o.Version)
}

func (v SemanticVersion) GreaterThan(o *SemanticVersion) bool {
return v.Version.GreaterThan(&o.Version)
}

func (v SemanticVersion) GreaterThanEqual(o *SemanticVersion) bool {
return v.Version.GreaterThanEqual(&o.Version)
}

func (v SemanticVersion) LessThan(o *SemanticVersion) bool {
return v.Version.LessThan(&o.Version)
}

func (v SemanticVersion) LessThanEqual(o *SemanticVersion) bool {
return v.Version.LessThanEqual(&o.Version)
}

func (v *SemanticVersion) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &v.Version)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provisioners/application/provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"context"
"testing"

"github.com/masterminds/semver"
"github.com/Masterminds/semver/v3"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"

Expand Down
Loading