Skip to content

Commit

Permalink
Remove all references to GCP projects, artifact registries, repositor…
Browse files Browse the repository at this point in the history
…ies that should no longer be used as part of development (#85)
  • Loading branch information
jlewi committed Apr 4, 2024
1 parent 145eb1d commit fdce4ef
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 12 additions & 10 deletions cmd/commands/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
},
}

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/continuous_delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion image-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -23,5 +23,5 @@ spec:
strip: app
builder:
gcb:
project: dev-sailplane
bucket : builds-sailplane
project: foyle-public
bucket : builds-foyle-public
4 changes: 3 additions & 1 deletion pkg/gcp/artifactregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions pkg/github/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/gitutil/gitutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pkg/images/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/images/pull_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
Expand Down

0 comments on commit fdce4ef

Please sign in to comment.