Skip to content

Commit

Permalink
databse portforward to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-nour-fdc committed Aug 27, 2024
1 parent 6d1b4bf commit 270276e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
26 changes: 13 additions & 13 deletions services/manifest-repo-export-service/pkg/repository/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ func (c *CreateApplicationVersion) Transform(
releaseDir := releasesDirectoryWithVersion(fs, c.Application, version)
appDir := applicationDirectory(fs, c.Application)
if err := fs.MkdirAll(releaseDir, 0777); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("mkdir %s error:%v", releaseDir, err))
return "", GetCreateReleaseGeneralFailure(err)
}

var checkForInvalidCommitId = func(commitId, helperText string) {
Expand All @@ -808,27 +808,27 @@ func (c *CreateApplicationVersion) Transform(
if c.SourceCommitId != "" {
c.SourceCommitId = strings.ToLower(c.SourceCommitId)
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceCommitId), []byte(c.SourceCommitId), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceCommitId, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}

if c.SourceAuthor != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceAuthor), []byte(c.SourceAuthor), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceAuthor, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
if c.SourceMessage != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceMessage), []byte(c.SourceMessage), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceMessage, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
if c.DisplayVersion != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldDisplayVersion), []byte(c.DisplayVersion), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldDisplayVersion, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldCreatedAt), []byte(time2.GetTimeNow(ctx).Format(time.RFC3339)), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldCreatedAt, err))
return "", GetCreateReleaseGeneralFailure(err)
}

if c.Team != "" {
Expand All @@ -839,22 +839,22 @@ func (c *CreateApplicationVersion) Transform(
if _, err := fs.Stat(teamFileLoc); err == nil { //If path to file exists
err := fs.Remove(teamFileLoc)
if err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("remove %s error:%v", teamFileLoc, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
if err := util.WriteFile(fs, teamFileLoc, []byte(c.Team), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", teamFileLoc, err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
isLatest, err := isLatestVersion(state, c.Application, version)
if err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("islatest version error:%v", err))
return "", GetCreateReleaseGeneralFailure(err)
}
if !isLatest {
// check that we can actually backfill this version
oldVersions, err := findOldApplicationVersions(ctx, transaction, state, c.Application)
if err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("findOldApplicationVersions error:%v", err))
return "", GetCreateReleaseGeneralFailure(err)
}
for _, oldVersion := range oldVersions {
if version == oldVersion {
Expand Down Expand Up @@ -906,10 +906,10 @@ func (c *CreateApplicationVersion) Transform(
}

if err = fs.MkdirAll(envDir, 0777); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("mkdir %s error:%v", envDir, err))
return "", GetCreateReleaseGeneralFailure(err)
}
if err := util.WriteFile(fs, fs.Join(envDir, "manifests.yaml"), []byte(man), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", envDir, err))
return "", GetCreateReleaseGeneralFailure(err)
}

teamOwner, err := state.GetApplicationTeamOwner(ctx, transaction, c.Application)
Expand Down Expand Up @@ -939,7 +939,7 @@ func (c *CreateApplicationVersion) Transform(
if ok {
continue // LockedErrors are expected
} else {
return "", GetCreateReleaseGeneralFailure(fmt.Errorf("execute error:%v", err))
return "", GetCreateReleaseGeneralFailure(err)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration-tests/cluster-setup/argocd-kuberpult.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ print "connection to frontend service successful"
waitForDeployment "default" "app=kuberpult-rollout-service"
waitForDeployment "default" "app=kuberpult-manifest-repo-export-service"

portForwardAndWait "default" deploy/postgres "5432" "5432"

kubectl get deployment
kubectl get pods

Expand Down
16 changes: 0 additions & 16 deletions tests/integration-tests/cluster-setup/setup-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@ function waitForDeployment() {
done
}

function portForwardAndWait() {
ns="$1"
deployment="$2"
portHere="$3"
portThere="$4"
ports="$portHere:$portThere"
print "portForwardAndWait for $ns/$deployment $ports"
kubectl -n "$ns" port-forward "$deployment" "$ports" &
print "portForwardAndWait: waiting until the port forward works..."
until nc -vz localhost "$portHere"
do
sleep 1s
done
}

kubectl apply -f - <<EOF
---
apiVersion: v1
Expand Down Expand Up @@ -87,5 +72,4 @@ spec:
EOF

waitForDeployment default "app=postgres"
portForwardAndWait "default" deploy/postgres "5432" "5432"
echo "done setting up postgres"

0 comments on commit 270276e

Please sign in to comment.