mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
go.mod still declared `module github.com/hanzoai/deploy` after the repo was renamed. A Go module path is not cosmetic — it is the resolvable location. So `go get github.com/hanzoai/cd` could not work, and anything importing this module had to spell a name that no longer exists at that address. The build log of v3.6.0 is where it surfaced: the compiler was still emitting github.com/hanzoai/deploy/cmd/cd/commands. 3541 import paths across 690 .go, 19 .proto, 4 .yaml, 3 .sh, 2 .mod, Procfile and Makefile. Plus the 62 ghcr.io/hanzoai/deploy image references, moved to ghcr.io/hanzoai/cd to match hanzo.yml's build target — a distinct string from the module path, replaced separately so neither could clobber the other. go mod tidy clean, CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... clean. Co-authored-by: Hanzo Dev <[email protected]>
82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
package admin
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/hanzoai/cd/pkg/apis/application/v1alpha1"
|
|
fakeapps "github.com/hanzoai/cd/pkg/client/clientset/versioned/fake"
|
|
cacheutil "github.com/hanzoai/cd/util/cache"
|
|
"github.com/hanzoai/cd/util/cache/appstate"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
corev1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/kubernetes/fake"
|
|
)
|
|
|
|
func Test_loadClusters(t *testing.T) {
|
|
argoCDCM := &corev1.ConfigMap{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "cd-cm",
|
|
Namespace: "cd",
|
|
Labels: map[string]string{
|
|
"app.kubernetes.io/part-of": "cd",
|
|
},
|
|
},
|
|
Data: map[string]string{},
|
|
}
|
|
argoCDSecret := &corev1.Secret{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "cd-secret",
|
|
Namespace: "cd",
|
|
},
|
|
Data: map[string][]byte{
|
|
"server.secretkey": []byte("test"),
|
|
},
|
|
}
|
|
app := &v1alpha1.Application{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "test",
|
|
Namespace: "cd",
|
|
},
|
|
Spec: v1alpha1.ApplicationSpec{
|
|
Project: "default",
|
|
Destination: v1alpha1.ApplicationDestination{
|
|
Server: "https://kubernetes.default.svc",
|
|
Namespace: "test",
|
|
},
|
|
},
|
|
}
|
|
ctx := t.Context()
|
|
kubeClient := fake.NewClientset(argoCDCM, argoCDSecret)
|
|
appClient := fakeapps.NewSimpleClientset(app)
|
|
cacheSrc := func() (*appstate.Cache, error) {
|
|
return appstate.NewCache(cacheutil.NewCache(cacheutil.NewInMemoryCache(time.Minute)), time.Minute), nil
|
|
}
|
|
clusters, err := loadClusters(ctx, kubeClient, appClient, 3, "", "cd", false, cacheSrc, 0, "", "", "")
|
|
require.NoError(t, err)
|
|
for i := range clusters {
|
|
// This changes, nil it to avoid testing it.
|
|
clusters[i].Info.ConnectionState.ModifiedAt = nil
|
|
}
|
|
|
|
expected := []ClusterWithInfo{{
|
|
Cluster: v1alpha1.Cluster{
|
|
ID: "",
|
|
Server: "https://kubernetes.default.svc",
|
|
Name: "in-cluster",
|
|
Info: v1alpha1.ClusterInfo{
|
|
ConnectionState: v1alpha1.ConnectionState{
|
|
Status: "Successful",
|
|
},
|
|
ServerVersion: "0.0.0",
|
|
},
|
|
Shard: new(int64(0)),
|
|
},
|
|
Namespaces: []string{"test"},
|
|
}}
|
|
assert.Equal(t, expected, clusters)
|
|
}
|