Skip to content
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
5 changes: 3 additions & 2 deletions api/core/v1alpha1/br_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,10 @@ package v1alpha1

import (
fmt "fmt"
"time"

"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions api/core/v1alpha1/bucketclaim_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,11 +18,12 @@ import (
"context"
"crypto/sha1"
"fmt"
"strings"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"strings"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/bucketclaim_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/cnclaim_helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/cnclaim_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/cnpool_helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/cnpool_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions api/core/v1alpha1/cnset_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,11 @@
package v1alpha1

import (
"time"

recon "github.com/matrixorigin/controller-runtime/pkg/reconciler"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)

type CNRole string
Expand Down
14 changes: 9 additions & 5 deletions api/core/v1alpha1/common_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -289,10 +289,7 @@ func (p *PodSet) GetSemVer() (*semver.Version, bool) {
if p.SemanticVersion != nil {
s = *p.SemanticVersion
} else {
ss := strings.Split(p.Image, ":")
if len(ss) == 2 {
s = ss[1]
}
s = getImageTag(p.Image)
}
v, err := semver.ParseTolerant(s)
if err != nil {
Expand All @@ -301,6 +298,13 @@ func (p *PodSet) GetSemVer() (*semver.Version, bool) {
return &v, true
}

func getImageTag(image string) string {
if idx := strings.LastIndex(image, ":"); idx >= 0 {
return image[idx+1:]
}
return ""
}

func (p *PodSet) GetOperatorVersion() semver.Version {
if p.OperatorVersion == nil {
return FirstOpVersion
Expand Down
47 changes: 45 additions & 2 deletions api/core/v1alpha1/common_helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,10 +15,11 @@
package v1alpha1

import (
"testing"

. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
)

func TestGetCNPodUUID(t *testing.T) {
Expand Down Expand Up @@ -50,3 +51,45 @@ func TestGetCNPodUUID(t *testing.T) {
})
}
}

func TestGetImageTag(t *testing.T) {
tests := []struct {
name string
image string
want string
}{
{
name: "Regular image with tag",
image: "matrixorigin/matrixone:1.1.1",
want: "1.1.1",
},
{
name: "Image with registry and tag",
image: "registry.example.com/matrixorigin/matrixone:latest",
want: "latest",
},
{
name: "Image without tag",
image: "matrixorigin/matrixone",
want: "",
},
{
name: "Image with multiple colons",
image: "registry.example.com:5000/matrixorigin/matrixone:v1.0.0",
want: "v1.0.0",
},
{
name: "Empty string",
image: "",
want: "",
},
}

g := NewGomegaWithT(t)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := getImageTag(tt.image)
g.Expect(got).To(Equal(tt.want))
})
}
}
2 changes: 1 addition & 1 deletion api/core/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/dnset_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/logset_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions api/core/v1alpha1/logset_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,9 @@ package v1alpha1

import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions api/core/v1alpha1/logset_types_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,9 @@
package v1alpha1

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestSetDefaultRetentionPolicy(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/matrixonecluster_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/matrixonecluster_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/operator_version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/proxy_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/semver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/semver_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/store_helper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/toml_config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/toml_config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/webui_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/features/features.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions cmd/hacli/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,14 +16,15 @@ package main

import (
"context"
"time"

"github.com/matrixorigin/matrixone-operator/api/core/v1alpha1"
"github.com/matrixorigin/matrixone-operator/pkg/controllers/common"
"github.com/matrixorigin/matrixone/pkg/logservice"
logpb "github.com/matrixorigin/matrixone/pkg/pb/logservice"
"github.com/matrixorigin/matrixone/pkg/pb/metadata"
"go.uber.org/zap"
logzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
"time"
)

// TODO(aylei): complete this CLI
Expand Down
6 changes: 4 additions & 2 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,9 @@ package main
import (
"flag"
"fmt"
"k8s.io/kubernetes/pkg/capabilities"
"os"

"k8s.io/kubernetes/pkg/capabilities"
"sigs.k8s.io/controller-runtime/pkg/cache"

"github.com/go-logr/zapr"
Expand Down Expand Up @@ -52,6 +53,7 @@ import (
zaporigin "go.uber.org/zap"
"go.uber.org/zap/zapcore"
controllermetrics "sigs.k8s.io/controller-runtime/pkg/metrics"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down
5 changes: 3 additions & 2 deletions cmd/rpccli/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,10 +16,11 @@ package main

import (
"context"
"time"

"github.com/matrixorigin/matrixone-operator/pkg/querycli"
"go.uber.org/zap"
logzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
"time"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Matrix Origin
// Copyright 2025 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading
Loading