Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
YrrepNoj committed Mar 26, 2022
1 parent a83d3f1 commit f3bd8e9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
11 changes: 7 additions & 4 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ const (
ZarfRegistryPullUser = "zarf-pull"
ZarfRegistry = IPV4Localhost + ":45001"

ZarfSeedTypeCLIInject = "cli-inject"
ZarfSeedTypeInClusterRegistry = "in-cluster-registry"

ZarfConnectLabelName = "zarf.dev/connect-name"
ZarfConnectAnnotationDescription = "zarf.dev/connect-description"
ZarfConnectAnnotationUrl = "zarf.dev/connect-url"
Expand Down Expand Up @@ -61,6 +58,11 @@ func IsZarfInitConfig() bool {
}

func GetArch() string {
// If user-overridden then reflect that
if DeployOptions.Architecture != "" {
return DeployOptions.Architecture
}

// If CLI-orverriden then reflect that
if CliArch != "" {
return CliArch
Expand Down Expand Up @@ -148,8 +150,9 @@ func GetState() types.ZarfState {
return state
}

// @JPERRY I'm a little confused why this is called GetRegistry.. what is using this?
func GetRegistry() string {
return fmt.Sprintf("%s:%s", IPV4Localhost, state.Registry.NodePort)
return fmt.Sprintf("%s:%s", IPV4Localhost, state.NodePort)
}

func LoadConfig(path string) error {
Expand Down
5 changes: 5 additions & 0 deletions cli/internal/k8s/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"regexp"

"github.com/defenseunicorns/zarf/cli/config"
"github.com/defenseunicorns/zarf/cli/internal/message"
)

Expand All @@ -26,6 +27,10 @@ const (
func DetectDistro() (string, error) {
message.Debugf("k8s.DetectDistro()")

if config.DeployOptions.Distro != "" {
return config.DeployOptions.Distro, nil
}

kindNodeRegex := regexp.MustCompile(`^kind://`)
k3dNodeRegex := regexp.MustCompile(`^k3s://k3d-`)
eksNodeRegex := regexp.MustCompile(`^aws:///`)
Expand Down
12 changes: 11 additions & 1 deletion cli/internal/packager/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func preSeedRegistry(tempPath tempPaths) {
}

// Defaults
state.Registry.NodePort = "31999"
state.NodePort = "31999"
state.Secret = utils.RandomString(120)
state.Distro = distro
state.Architecture = config.GetArch()
Expand All @@ -76,7 +76,17 @@ func preSeedRegistry(tempPath tempPaths) {

case k8s.DistroIsDockerDesktop:
state.StorageClass = "hostpath"
}

// CLI provided overrides that haven't been processed already
if config.DeployOptions.NodePort != "" {
state.NodePort = config.DeployOptions.NodePort
}
if config.DeployOptions.Secret != "" {
state.Secret = config.DeployOptions.Secret
}
if config.DeployOptions.StorageClass != "" {
state.StorageClass = config.DeployOptions.StorageClass
}

spinner.Success()
Expand Down
4 changes: 2 additions & 2 deletions cli/internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func (values Values) Apply(path string) {
mappings := map[string]string{
"STORAGE_CLASS": values.state.StorageClass,
"SEED_REGISTRY": values.seedRegistry,
"REGISTRY": values.registry,
"REGISTRY_NODEPORT": values.state.Registry.NodePort,
"REGISTRY": values.registry, //@JPERRY when is registry used?
"NODEPORT": values.state.NodePort,
"REGISTRY_SECRET": values.secret.registrySecret,
"REGISTRY_AUTH_PUSH": values.secret.registryPush,
"REGISTRY_AUTH_PULL": values.secret.registryPull,
Expand Down
15 changes: 9 additions & 6 deletions cli/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ type ZarfState struct {
Architecture string `json:"architecture"`
StorageClass string `json:"storageClass"`
Secret string `json:"secret"`
Registry struct {
SeedType string `json:"seedType"`
NodePort string `json:"nodePort"`
} `json:"registry"`
NodePort string `json:"nodePort"`
}

// TLSConfig tracks the user-defined options for TLS cert generation
Expand All @@ -142,8 +139,14 @@ type ZarfDeployOptions struct {
PackagePath string
Confirm bool
Components string
// Zarf init is installing the k3s component
ApplianceMode bool

// Zarf init options
ApplianceMode bool // Zarf init is installing the k3s component
Distro string
StorageClass string
Secret string
NodePort string
Architecture string
}

// ZarfImport structure for including imported zarf components
Expand Down
2 changes: 1 addition & 1 deletion packages/zarf-registry/registry-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ secrets:
# tlsSecretName: tls-pem
service:
type: NodePort
nodePort: "###ZARF_REGISTRY_NODEPORT###"
nodePort: "###ZARF_NODEPORT###"
resources:
requests:
cpu: "500m"
Expand Down

0 comments on commit f3bd8e9

Please sign in to comment.