-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jlo/fix-relay-restarts #15
Merged
+204
−32
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.22-bookworm as builder | ||
FROM golang:1.22-bookworm AS builder | ||
|
||
WORKDIR /app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
name: supervisor | ||
image: okteto/golang:1 | ||
command: | ||
- bash | ||
workdir: /okteto | ||
volumes: | ||
- /go/pkg/ | ||
- /root/.cache/go-build/ | ||
securityContext: | ||
capabilities: | ||
add: | ||
- SYS_PTRACE | ||
forward: | ||
- 8080:8080 | ||
- 2345:2345 | ||
persistentVolume: | ||
enabled: true | ||
build: | ||
supervisor: | ||
context: . | ||
image: ${REGISTRY_AND_USER:-okteto}/supervisor:${VERSION:-latest} | ||
dev: | ||
supervisor: | ||
image: okteto/golang:1 | ||
command: | ||
- bash | ||
workdir: /okteto | ||
volumes: | ||
- /go/pkg/ | ||
- /root/.cache/go-build/ | ||
securityContext: | ||
capabilities: | ||
add: | ||
- SYS_PTRACE | ||
forward: | ||
- 8080:8080 | ||
- 2345:2345 | ||
persistentVolume: | ||
enabled: true | ||
autocreate: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package setup | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
func copy(src, dst string) error { | ||
log.Default().Printf("copying %s to %s", src, dst) | ||
|
||
fs, err := os.Stat(dst) | ||
if err != nil { | ||
if errors.Is(err, os.ErrNotExist) { | ||
if err := os.MkdirAll(dst, 0755); err != nil { | ||
return fmt.Errorf("failed to create directory: %w", err) | ||
} | ||
} else { | ||
return fmt.Errorf("failed to get file info: %w", err) | ||
} | ||
} | ||
if !fs.IsDir() { | ||
return fmt.Errorf("source is not a directory: %s", dst) | ||
} | ||
|
||
files := []string{ | ||
"cert.pem", | ||
"config.xml", | ||
"key.pem", | ||
} | ||
for _, file := range files { | ||
src := filepath.Join(src, file) | ||
dst := filepath.Join(dst, file) | ||
if _, err := os.Stat(dst); err == nil { | ||
log.Default().Printf("file already exists: %s", dst) | ||
continue | ||
} | ||
log.Default().Printf("copying %s to %s", src, dst) | ||
err := runCommand("cp", src, dst) | ||
if err != nil { | ||
return fmt.Errorf("failed to copy files: %w", err) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func runCommand(name string, args ...string) error { | ||
cmd := exec.Command(name, args...) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
log.Default().Printf("running command: %s", cmd.String()) | ||
if err := cmd.Run(); err != nil { | ||
return fmt.Errorf("failed to run command: %w", err) | ||
} | ||
log.Default().Printf("command executed correctly: %s", cmd.String()) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package setup | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func addPermissions(configPath string) error { | ||
// Define the files to set permissions | ||
files := []string{ | ||
filepath.Join(configPath, "cert.pem"), | ||
filepath.Join(configPath, "config.xml"), | ||
filepath.Join(configPath, "key.pem"), | ||
} | ||
|
||
// Set the permissions to 644 | ||
for _, file := range files { | ||
log.Default().Printf("setting permissions to 644 for %s", file) | ||
err := os.Chmod(file, 0644) | ||
if err != nil { | ||
return fmt.Errorf("failed to change permissions for %s: %w", file, err) | ||
} | ||
log.Default().Printf("permissions set to 644 for %s", file) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package setup | ||
|
||
import "log" | ||
|
||
func Setup(secretPath, configPath string) error { | ||
log.Default().Printf("starting setup") | ||
if err := copy(secretPath, configPath); err != nil { | ||
return err | ||
} | ||
log.Default().Printf("copy done") | ||
if err := addPermissions(configPath); err != nil { | ||
return err | ||
} | ||
log.Default().Printf("permissions done") | ||
return nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think if we use some more conventional env vars?
If we use
OKTETO_NAMESPACE
instead of USER it's replaced out of the box. For the Registry, unfortunatelty it's only injected in the deploy steps, but still we could have a comment as example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With that approach it's difficult to know that you can push to other registries rather than the okteto one, like docker hub.