Skip to content

Commit

Permalink
test(sealos): images fix
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <[email protected]>
  • Loading branch information
cuisongliu committed Oct 3, 2024
1 parent 6f3a279 commit 0af9f9b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ RUN go mod download
# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/controller/ internal/controller/

COPY internal/ internal/
COPY defaults defaults
# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
Expand Down
4 changes: 3 additions & 1 deletion api/v1beta1/automq_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package v1beta1

import (
"fmt"

"github.com/cuisongliu/automq-operator/defaults"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand All @@ -42,7 +44,7 @@ var _ webhook.Defaulter = &AutoMQ{}
func (r *AutoMQ) Default() {
automqlog.Info("default", "name", r.Name)
if r.Spec.Image == "" {
r.Spec.Image = DefaultImageName
r.Spec.Image = defaults.DefaultImageName
}
if r.Spec.S3.Region == "" {
r.Spec.S3.Region = "us-east-1"
Expand Down
6 changes: 4 additions & 2 deletions api/v1beta1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import (
"context"
"crypto/tls"
"fmt"
"k8s.io/apimachinery/pkg/api/errors"
"net"
"path/filepath"
"runtime"
"testing"
"time"

"github.com/cuisongliu/automq-operator/defaults"
"k8s.io/apimachinery/pkg/api/errors"

v1 "k8s.io/api/admissionregistration/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

Expand Down Expand Up @@ -89,7 +91,7 @@ var _ = Describe("Default", func() {
Expect(err).To(BeNil())
err = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(aq), aq)
Expect(err).To(BeNil())
Expect(aq.Spec.Image).To(Equal(DefaultImageName))
Expect(aq.Spec.Image).To(Equal(defaults.DefaultImageName))
})
It("Default Region", func() {
aq := initAutoMQ()
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/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/v1beta1/images.go → defaults/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package defaults

const (
DefaultImageName = "automqinc/automq:1.2.0-rc1"
Expand Down
4 changes: 2 additions & 2 deletions gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
"fmt"
"github.com/cuisongliu/automq-operator/api/v1beta1"
"github.com/cuisongliu/automq-operator/defaults"
"os"
"os/exec"
"strings"
Expand All @@ -32,7 +32,7 @@ func main() {
imageName := os.Args[1]
fmt.Printf("image name is %s", imageName)
_ = os.MkdirAll("deploy/images/shim", 0755)
_ = os.WriteFile("deploy/images/shim/image.txt", []byte(v1beta1.DefaultImageName), 0755)
_ = os.WriteFile("deploy/images/shim/image.txt", []byte(defaults.DefaultImageName), 0755)
cmd1 := fmt.Sprintf("sed -i '/#replace_by_makefile/!b;n;c\\image: %s' deploy/charts/automq-operator/values.yaml", imageName)
if err := execCmd("bash", "-c", cmd1); err != nil {
fmt.Printf("execCmd error %v", err)
Expand Down

0 comments on commit 0af9f9b

Please sign in to comment.