From fdce4efd19c5ec5f75536af98479e5049530a14a Mon Sep 17 00:00:00 2001 From: Jeremy Lewi Date: Thu, 4 Apr 2024 15:36:49 -0700 Subject: [PATCH] Remove all references to GCP projects, artifact registries, repositories that should no longer be used as part of development (#85) --- Makefile | 2 +- api/v1alpha1/images.go | 4 ++-- cmd/commands/clone_test.go | 22 ++++++++++++---------- docs/continuous_delivery.md | 2 +- image-pod.yaml | 2 +- images.yaml | 6 +++--- pkg/gcp/artifactregistry_test.go | 4 +++- pkg/github/clone_test.go | 10 +++++----- pkg/gitutil/gitutil.go | 4 ++-- pkg/images/export_test.go | 4 ++-- pkg/images/pull_push_test.go | 2 +- pkg/util/images_test.go | 4 ++-- 12 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 9240a4c..3d3173e 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ test: # This is much faster # TODO(jeremy): We should add support to image.yaml to use ko build-ko-image: - KO_DOCKER_REPO=us-west1-docker.pkg.dev/dev-sailplane/images/hydros \ + KO_DOCKER_REPO=us-west1-docker.pkg.dev/foyle-public/images/hydros \ ko build --bare github.com/jlewi/hydros/cmd # This builds the image using hydros which uses GCB diff --git a/api/v1alpha1/images.go b/api/v1alpha1/images.go index a7426cf..057180e 100644 --- a/api/v1alpha1/images.go +++ b/api/v1alpha1/images.go @@ -32,7 +32,7 @@ type Image struct { type ImageSpec struct { // Image is the full path of the image to be built - // e.g.us-west1-docker.pkg.dev/dev-sailplane/images/hydros/agent + // e.g.us-west1-docker.pkg.dev/some-project/images/hydros // So it includes the registry and repository but not the tag or digest Image string `yaml:"image,omitempty"` // Source are the source for the image @@ -44,7 +44,7 @@ type ImageSource struct { // URI is the path of the resource to use as a source // This can be a local path or a docker image. If its a local path relative paths will be interpreted // relative to the location of the YAML file containing the resource. - // e.g.us-west1-docker.pkg.dev/dev-sailplane/images/hydros/agent + // e.g.us-west1-docker.pkg.dev/some-project/images/hydros/agent // // Use file:// to specify a local path e.g. file:///path/to/dir. Note the third "/" indicates its an absolute path // If its "//" then its a relative path. I'm not sure it makes sense to support relative paths because what diff --git a/cmd/commands/clone_test.go b/cmd/commands/clone_test.go index 295f9cb..3ccd230 100644 --- a/cmd/commands/clone_test.go +++ b/cmd/commands/clone_test.go @@ -11,8 +11,8 @@ import ( ) const ( - sailplaneHydrosKey = "gcpsecretmanager:///projects/887891891186/secrets/hydros-ghapp-key/versions/latest" - sailplaneHydrosAppID = int64(384797) + hydrosKey = "gcpsecretmanager:///projects/513170322007/secrets/hydros-ghapp-key/versions/latest" + hydrosAppID = int64(384797) ) func Test_CloneConfig(t *testing.T) { @@ -66,18 +66,20 @@ func Test_CloneCmd(t *testing.T) { outDir string } + // TODO(jeremy): As of 2024/04/04 these repo references were updated and may not be valid. The test most likely + // needs to be updated. cases := []testCase{ { - repo: "https://github.com/sailplaneai/roboweb.git", - outDir: "sailplaneai/roboweb", + repo: "https://github.com/jlewi/hydros-hydrated.git", + outDir: "jlewi/roboweb", }, { - repo: "https://github.com/sailplaneai/roboweb.git?ref=jlewi/cicd", - outDir: "sailplaneai/roboweb", + repo: "https://github.com/jlewi/hydros-hydrated.git?ref=jlewi/cicd", + outDir: "jlewi/roboweb", }, { - repo: "https://github.com/sailplaneai/kubepilot?sha=9fa5bc0", - outDir: "sailplaneai/kubepilot", + repo: "https://github.com/jlewi/hydros-hydrated?sha=9fa5bc0", + outDir: "jlewi/kubepilot", }, } @@ -94,8 +96,8 @@ func Test_CloneCmd(t *testing.T) { cmd.SetArgs([]string{ "--repo=" + c.repo, "--work-dir=" + tDir, - "--app-id=" + fmt.Sprintf("%d", sailplaneHydrosAppID), - "--private-key=" + sailplaneHydrosKey, + "--app-id=" + fmt.Sprintf("%d", hydrosAppID), + "--private-key=" + hydrosKey, }) if err := cmd.Execute(); err != nil { t.Fatalf("Failed to run clone; error %v", err) diff --git a/docs/continuous_delivery.md b/docs/continuous_delivery.md index e40bab6..c938b22 100644 --- a/docs/continuous_delivery.md +++ b/docs/continuous_delivery.md @@ -32,7 +32,7 @@ apiVersion: hydros.dev/v1alpha1 kind: RepoConfig metadata: name: repo - namespace: sailplaneai + namespace: hydros spec: repo: https://github.com/yourrepo/code.git gitHubAppConfig: diff --git a/image-pod.yaml b/image-pod.yaml index 09b5fb2..2b89448 100644 --- a/image-pod.yaml +++ b/image-pod.yaml @@ -6,7 +6,7 @@ metadata: name: hydros-image spec: containers: - - image: us-west1-docker.pkg.dev/dev-sailplane/images/hydros/hydros:latest + - image: us-west1-docker.pkg.dev/foyle-public/images/hydros/hydros:latest name: hydros command: - tail diff --git a/images.yaml b/images.yaml index bac0810..647ef22 100644 --- a/images.yaml +++ b/images.yaml @@ -4,7 +4,7 @@ metadata: name: hydros namespace: hydros spec: - image: us-west1-docker.pkg.dev/foyle/images/hydros/hydros + image: us-west1-docker.pkg.dev/foyle-public/images/hydros/hydros source: - uri: https://github.com/jlewi/hydros.git mappings: @@ -23,5 +23,5 @@ spec: strip: app builder: gcb: - project: dev-sailplane - bucket : builds-sailplane + project: foyle-public + bucket : builds-foyle-public diff --git a/pkg/gcp/artifactregistry_test.go b/pkg/gcp/artifactregistry_test.go index 3cdf322..8f95042 100644 --- a/pkg/gcp/artifactregistry_test.go +++ b/pkg/gcp/artifactregistry_test.go @@ -69,9 +69,11 @@ func Test_ResolveImageToSHA(t *testing.T) { r := &ImageResolver{} + // TODO(jeremy): As of 2024/04/04 this is probably not pointing to a valid image. So we probably need to + // upate the test to use a valid image. ref := util.DockerImageRef{ Registry: "us-west1-docker.pkg.dev", - Repo: "dev-sailplane/images/vscode/webserver", + Repo: "foyle-public/images/some/image", Tag: "78eb2ca7-1690-4711-a97e-188d27866635", } expectedSha := "sha256:f2709b8a04f7ee03c7a1b5ce014e480b568661d7383dfbd9578ffca531c9184a" diff --git a/pkg/github/clone_test.go b/pkg/github/clone_test.go index 4b795b3..ad269a0 100644 --- a/pkg/github/clone_test.go +++ b/pkg/github/clone_test.go @@ -10,8 +10,8 @@ import ( ) const ( - sailplaneHydrosKey = "gcpsecretmanager:///projects/887891891186/secrets/hydros-ghapp-key/versions/latest" - sailplaneHydrosAppID = int64(384797) + hydrosKey = "gcpsecretmanager:///projects/513170322007/secrets/hydros-ghapp-key/versions/latest" + hydrosAppID = int64(384797) ) // N.B. there is also a test in cmd/commands/clone_test.go @@ -20,14 +20,14 @@ func Test_ReposCloner(t *testing.T) { t.Skipf("Test is skipped in GitHub actions") } - privateKey, err := files.Read(sailplaneHydrosKey) + privateKey, err := files.Read(hydrosKey) if err != nil { t.Fatalf("Failed to read key; error %v", err) } log := util.SetupLogger("info", true) - manager, err := NewTransportManager(sailplaneHydrosAppID, privateKey, log) + manager, err := NewTransportManager(hydrosAppID, privateKey, log) if err != nil { t.Fatalf("Failed to create transport manager; error %v", err) @@ -41,7 +41,7 @@ func Test_ReposCloner(t *testing.T) { cloner := &ReposCloner{ Manager: manager, BaseDir: tDir, - URIs: []string{"https://github.com/sailplaneai/roboweb.git"}, + URIs: []string{"https://github.com/jlewi/hydros-hydrated.git"}, } if err := cloner.Run(context.TODO()); err != nil { diff --git a/pkg/gitutil/gitutil.go b/pkg/gitutil/gitutil.go index ddf9c63..6ad8961 100644 --- a/pkg/gitutil/gitutil.go +++ b/pkg/gitutil/gitutil.go @@ -134,9 +134,9 @@ func LoadUser(r *git.Repository) (*User, error) { // null op if its clean. // w is the worktree // You should call AddGitIgnore on the worktree before calling this function if you want to ensure files are ignored. -// TODO(jeremy): I'm not sure this is the right API. I did it this way because with kubedr it was really slow +// TODO(jeremy): I'm not sure this is the right API. I did it this way because on some repositories it was really slow // to get the worktree and add .gitignore so I didn't want to do that more than once. -// https://github.com/sailplaneai/code/issues/872 is tracking the slowness. +// https://github.com/jlewi/hydros/issues/84 is tracking the slowness. func CommitAll(r *git.Repository, w *git.Worktree, message string) error { log := zapr.NewLogger(zap.L()) log.Info("Getting git status") diff --git a/pkg/images/export_test.go b/pkg/images/export_test.go index 150c4b9..05a1ab0 100644 --- a/pkg/images/export_test.go +++ b/pkg/images/export_test.go @@ -21,9 +21,9 @@ func Test_DownloadImage(t *testing.T) { defer os.RemoveAll(tDir) util.SetupLogger("info", true) - image := "us-west1-docker.pkg.dev/dev-sailplane/images/kubepilot:latest" + image := "us-west1-docker.pkg.dev/foyle-public/images/foyle-public/foyle-vscode-ext:latest" - tarball := filepath.Join(tDir, "kubepilot.tar") + tarball := filepath.Join(tDir, "foyle.tar") if err := ExportImage(image, tarball); err != nil { t.Fatalf("Error downloading image %v", err) } diff --git a/pkg/images/pull_push_test.go b/pkg/images/pull_push_test.go index fcb580e..2d2032f 100644 --- a/pkg/images/pull_push_test.go +++ b/pkg/images/pull_push_test.go @@ -28,7 +28,7 @@ func Test_ImageDownloader(t *testing.T) { Log: log, ImageList: v1alpha1.ImageList{ Images: []string{ - "us-west1-docker.pkg.dev/dev-sailplane/images/kubepilot", + "us-west1-docker.pkg.dev/foyle-public/images/foyle-vscode-ext", }, }, ImageDir: tDir, diff --git a/pkg/util/images_test.go b/pkg/util/images_test.go index 568e146..cf71aa3 100644 --- a/pkg/util/images_test.go +++ b/pkg/util/images_test.go @@ -42,10 +42,10 @@ func Test_ParseImage(t *testing.T) { }, }, { - In: "docker://us-west1-docker.pkg.dev/dev-sailplane/images/hercules:latest", + In: "docker://us-west1-docker.pkg.dev/acme-public/images/someimage:latest", Expected: &DockerImageRef{ Registry: "us-west1-docker.pkg.dev", - Repo: "dev-sailplane/images/hercules", + Repo: "acme-public/images/someimage", Tag: "latest", }, },