Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into 2665-zarf-connect-options
Browse files Browse the repository at this point in the history
  • Loading branch information
chaospuppy committed Jul 12, 2024
2 parents a638114 + a567687 commit e1394e7
Show file tree
Hide file tree
Showing 54 changed files with 410 additions and 386 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
args:
- "--allow-missing-credentials"
- id: detect-private-key
exclude: "src/test/e2e/30_config_file_test.go"
exclude: "src/test/e2e/29_config_file_test.go"
- id: end-of-file-fixer
exclude: site/src/content/docs/commands/.*
- id: fix-byte-order-marker
Expand Down
28 changes: 27 additions & 1 deletion .github/CONTRIBUTING.md → CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

First off, thanks so much for wanting to help out! :tada:

This document describes the steps and requirements for contributing a bug fix or feature in a Pull Request to Zarf! If you have any questions about the process or the pull request you are working on feel free to reach out in the [Zarf Dev Kubernetes Slack Channel](https://kubernetes.slack.com/archives/C03BP9Z3CMA).
This document describes the steps and requirements for contributing a bug fix or feature in a Pull Request to Zarf! If you have any questions about the process or the pull request you are working on feel free to reach out in the [Zarf Dev Kubernetes Slack Channel](https://kubernetes.slack.com/archives/C03BP9Z3CMA). The doc also details a bit about the governance structure of the project.

## Developer Experience

Expand Down Expand Up @@ -83,3 +83,29 @@ adr new -l "15:Amends:Amended by" Use store-bought butter for all waffle making
# Get full help docs. There are all sorts of other helpful commands that help manage the decision log.
adr help
```

## Governance

### Technical Steering Committee
The Technical Steering Committee (the “TSC”) will be responsible for all technical oversight of the project. The TSC may elect a TSC Chair, who will preside over meetings of the TSC and will serve until their resignation or replacement by the TSC. Current members of the TSC include:

#### Austin Abro
Affiliation: Defense Unicorns
GitHub: @AustinAbro321

#### Danny Gershman
Affiliation: Radius Method
GitHub: @dgershman

#### Jeff McCoy (TSC Chair)
Affiliation: Defense Unicorns
GitHub: @jeff-mccoy

#### Sarah Christoff
Affiliation: Defense Unicorns
GitHub: @schristoff-du

#### Wayne Starr
Affiliation: Defense Unicorns
GitHub: @Racer159

2 changes: 1 addition & 1 deletion site/src/content/docs/contribute/contributor-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tableOfContents: false
---

import StripH1 from "@components/StripH1.astro";
import Contributing from "../../../../../.github/CONTRIBUTING.md";
import Contributing from "../../../../../CONTRIBUTING.md";

<StripH1>
<Contributing />
Expand Down
151 changes: 75 additions & 76 deletions src/cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,104 +5,103 @@
package cmd

import (
"context"
"fmt"

"github.com/spf13/cobra"

"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/defenseunicorns/zarf/src/pkg/utils/exec"
"github.com/spf13/cobra"
)

var (
cliOnly bool
zt cluster.TunnelInfo
)

connectCmd = &cobra.Command{
Use: "connect { REGISTRY | GIT | connect-name }",
Aliases: []string{"c"},
Short: lang.CmdConnectShort,
Long: lang.CmdConnectLong,
RunE: func(cmd *cobra.Command, args []string) error {
var target string
if len(args) > 0 {
target = args[0]
}
spinner := message.NewProgressSpinner(lang.CmdConnectPreparingTunnel, target)
defer spinner.Stop()
c, err := cluster.NewCluster()
var connectCmd = &cobra.Command{
Use: "connect { REGISTRY | GIT | connect-name }",
Aliases: []string{"c"},
Short: lang.CmdConnectShort,
Long: lang.CmdConnectLong,
RunE: func(cmd *cobra.Command, args []string) error {
var target string

Check warning on line 29 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L29

Added line #L29 was not covered by tests
if len(args) > 0 {
target = args[0]
}
spinner := message.NewProgressSpinner(lang.CmdConnectPreparingTunnel, target)
defer spinner.Stop()
c, err := cluster.NewCluster()
if err != nil {
return err
}

ctx := cmd.Context()

var tunnel *cluster.Tunnel
if target == "" {

Check warning on line 43 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L43

Added line #L43 was not covered by tests
tunnel, err = c.ConnectTunnelInfo(ctx, zt)
} else {
var ti cluster.TunnelInfo
ti, err = c.NewTargetTunnelInfo(ctx, target)
if err != nil {
return err
return fmt.Errorf("unable to create tunnel: %w", err)

Check warning on line 49 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L45-L49

Added lines #L45 - L49 were not covered by tests
}

ctx := cmd.Context()

var tunnel *cluster.Tunnel
if target == "" {
tunnel, err = c.ConnectTunnelInfo(ctx, zt)
} else {
var ti cluster.TunnelInfo
ti, err = c.NewTargetTunnelInfo(ctx, target)
if err != nil {
return fmt.Errorf("unable to create tunnel: %w", err)
}
if zt.LocalPort != 0 {
ti.LocalPort = zt.LocalPort
}
tunnel, err = c.ConnectTunnelInfo(ctx, ti)
if zt.LocalPort != 0 {
ti.LocalPort = zt.LocalPort

Check warning on line 52 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L51-L52

Added lines #L51 - L52 were not covered by tests
}
tunnel, err = c.ConnectTunnelInfo(ctx, ti)

Check warning on line 54 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L54

Added line #L54 was not covered by tests
}

if err != nil {
return fmt.Errorf("unable to connect to the service: %w", err)
}
if err != nil {
return fmt.Errorf("unable to connect to the service: %w", err)
}

defer tunnel.Close()
url := tunnel.FullURL()
defer tunnel.Close()
url := tunnel.FullURL()

Check warning on line 62 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L62

Added line #L62 was not covered by tests

// Dump the tunnel URL to the console for other tools to use.
fmt.Print(url)
// Dump the tunnel URL to the console for other tools to use.
fmt.Print(url)

Check warning on line 65 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L65

Added line #L65 was not covered by tests

if cliOnly {
spinner.Updatef(lang.CmdConnectEstablishedCLI, url)
} else {
spinner.Updatef(lang.CmdConnectEstablishedWeb, url)
if cliOnly {
spinner.Updatef(lang.CmdConnectEstablishedCLI, url)

Check warning on line 68 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L68

Added line #L68 was not covered by tests
} else {
spinner.Updatef(lang.CmdConnectEstablishedWeb, url)

Check warning on line 70 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L70

Added line #L70 was not covered by tests

if err := exec.LaunchURL(url); err != nil {
message.Debug(err)
}
if err := exec.LaunchURL(url); err != nil {

Check warning on line 72 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L72

Added line #L72 was not covered by tests
message.Debug(err)
}
}

// Wait for the interrupt signal or an error.
select {
case <-ctx.Done():
spinner.Successf(lang.CmdConnectTunnelClosed, url)

Check warning on line 80 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L80

Added line #L80 was not covered by tests
case err = <-tunnel.ErrChan():
return fmt.Errorf("lost connection to the service: %w", err)
}
return nil

Check warning on line 84 in src/cmd/connect.go

View check run for this annotation

Codecov / codecov/patch

src/cmd/connect.go#L84

Added line #L84 was not covered by tests
},
}

// Wait for the interrupt signal or an error.
select {
case <-ctx.Done():
spinner.Successf(lang.CmdConnectTunnelClosed, url)
case err = <-tunnel.ErrChan():
return fmt.Errorf("lost connection to the service: %w", err)
}
return nil
},
}

connectListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"l"},
Short: lang.CmdConnectListShort,
RunE: func(cmd *cobra.Command, _ []string) error {
timeoutCtx, cancel := context.WithTimeout(cmd.Context(), cluster.DefaultTimeout)
defer cancel()
c, err := cluster.NewClusterWithWait(timeoutCtx)
if err != nil {
return err
}
err = c.PrintConnectTable(cmd.Context())
if err != nil {
return err
}
return nil
},
}
)
var connectListCmd = &cobra.Command{
Use: "list",
Aliases: []string{"l"},
Short: lang.CmdConnectListShort,
RunE: func(cmd *cobra.Command, _ []string) error {
c, err := cluster.NewCluster()
if err != nil {
return err
}
connections, err := c.ListConnections(cmd.Context())
if err != nil {
return err
}
message.PrintConnectStringTable(connections)
return nil
},
}

func init() {
rootCmd.AddCommand(connectCmd)
Expand Down
7 changes: 6 additions & 1 deletion src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/defenseunicorns/zarf/src/pkg/utils"
"github.com/defenseunicorns/zarf/src/types"
"github.com/mholt/archiver/v3"
"github.com/pterm/pterm"
"github.com/sergi/go-diff/diffmatchpatch"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -110,7 +112,10 @@ var devTransformGitLinksCmd = &cobra.Command{
processedText := transform.MutateGitURLsInText(message.Warnf, pkgConfig.InitOpts.GitServer.Address, text, pkgConfig.InitOpts.GitServer.PushUsername)

// Print the differences
message.PrintDiff(text, processedText)
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(text, processedText, true)
diffs = dmp.DiffCleanupSemantic(diffs)
pterm.Println(dmp.DiffPrettyText(diffs))

// Ask the user before this destructive action
confirm := false
Expand Down
4 changes: 0 additions & 4 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const (

ZarfAgentHost = "agent-hook.zarf.svc"

ZarfConnectLabelName = "zarf.dev/connect-name"
ZarfConnectAnnotationDescription = "zarf.dev/connect-description"
ZarfConnectAnnotationURL = "zarf.dev/connect-url"

ZarfCleanupScriptsPath = "/opt/zarf"

ZarfPackagePrefix = "zarf-package-"
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/argocd-application.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type ApplicationSource struct {

// NewApplicationMutationHook creates a new instance of the ArgoCD Application mutation hook.
func NewApplicationMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewApplicationMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutateApplication(ctx, r, cluster)
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/argocd-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type RepoCreds struct {

// NewRepositorySecretMutationHook creates a new instance of the ArgoCD repository secret mutation hook.
func NewRepositorySecretMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewRepositoryMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutateRepositorySecret(ctx, r, cluster)
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-gitrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const AgentErrTransformGitURL = "unable to transform the git url"

// NewGitRepositoryMutationHook creates a new instance of the git repo mutation hook.
func NewGitRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewGitRepositoryMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutateGitRepo(ctx, r, cluster)
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-helmrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

// NewHelmRepositoryMutationHook creates a new instance of the helm repo mutation hook.
func NewHelmRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewHelmRepositoryMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutateHelmRepo(ctx, r, cluster)
Expand Down
1 change: 0 additions & 1 deletion src/internal/agent/hooks/flux-ocirepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

// NewOCIRepositoryMutationHook creates a new instance of the oci repo mutation hook.
func NewOCIRepositoryMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewOCIRepositoryMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutateOCIRepo(ctx, r, cluster)
Expand Down
4 changes: 0 additions & 4 deletions src/internal/agent/hooks/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

// NewPodMutationHook creates a new instance of pods mutation hook.
func NewPodMutationHook(ctx context.Context, cluster *cluster.Cluster) operations.Hook {
message.Debug("hooks.NewMutationHook()")
return operations.Hook{
Create: func(r *v1.AdmissionRequest) (*operations.Result, error) {
return mutatePod(ctx, r, cluster)
Expand All @@ -34,7 +33,6 @@ func NewPodMutationHook(ctx context.Context, cluster *cluster.Cluster) operation
}

func parsePod(object []byte) (*corev1.Pod, error) {
message.Debugf("pods.parsePod(%s)", string(object))
var pod corev1.Pod
if err := json.Unmarshal(object, &pod); err != nil {
return nil, err
Expand All @@ -43,8 +41,6 @@ func parsePod(object []byte) (*corev1.Pod, error) {
}

func mutatePod(ctx context.Context, r *v1.AdmissionRequest, cluster *cluster.Cluster) (*operations.Result, error) {
message.Debugf("hooks.mutatePod()(*v1.AdmissionRequest) - %#v , %s/%s: %#v", r.Kind, r.Namespace, r.Name, r.Operation)

pod, err := parsePod(r.Object.Raw)
if err != nil {
return nil, fmt.Errorf(lang.AgentErrParsePod, err)
Expand Down
3 changes: 0 additions & 3 deletions src/internal/agent/http/admission/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ func NewHandler() *Handler {

// Serve returns an http.HandlerFunc for an admission webhook.
func (h *Handler) Serve(hook operations.Hook) http.HandlerFunc {
message.Debugf("http.Serve(%#v)", hook)
return func(w http.ResponseWriter, r *http.Request) {
message.Debugf("http.Serve()(writer, %#v)", r.URL)

w.Header().Set("Content-Type", "application/json")
if r.Method != http.MethodPost {
http.Error(w, lang.AgentErrInvalidMethod, http.StatusMethodNotAllowed)
Expand Down
2 changes: 0 additions & 2 deletions src/internal/agent/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const (

// StartWebhook launches the Zarf agent mutating webhook in the cluster.
func StartWebhook(ctx context.Context) error {
message.Debug("agent.StartWebhook()")
srv, err := agentHttp.NewAdmissionServer(ctx, httpPort)
if err != nil {
return err
Expand All @@ -39,7 +38,6 @@ func StartWebhook(ctx context.Context) error {

// StartHTTPProxy launches the zarf agent proxy in the cluster.
func StartHTTPProxy(ctx context.Context) error {
message.Debug("agent.StartHttpProxy()")
return startServer(ctx, agentHttp.NewProxyServer(httpPort))
}

Expand Down
6 changes: 3 additions & 3 deletions src/internal/packager/helm/post-render.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ func (r *renderer) editHelmResources(ctx context.Context, resources []releaseuti
if annotations == nil {
annotations = map[string]string{}
}
if key, keyExists := labels[config.ZarfConnectLabelName]; keyExists {
if key, keyExists := labels[cluster.ZarfConnectLabelName]; keyExists {
// If there is a zarf-connect label
message.Debugf("Match helm service %s for zarf connection %s", rawData.GetName(), key)

// Add the connectString for processing later in the deployment
r.connectStrings[key] = types.ConnectString{
Description: annotations[config.ZarfConnectAnnotationDescription],
URL: annotations[config.ZarfConnectAnnotationURL],
Description: annotations[cluster.ZarfConnectAnnotationDescription],
URL: annotations[cluster.ZarfConnectAnnotationURL],
}
}
}
Expand Down
Loading

0 comments on commit e1394e7

Please sign in to comment.