Skip to content

Commit

Permalink
add nodeport override, remove distro and arch override
Browse files Browse the repository at this point in the history
  • Loading branch information
YrrepNoj committed Mar 29, 2022
1 parent a60ee89 commit 73cfe6f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 27 deletions.
7 changes: 1 addition & 6 deletions cli/cmd/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ func init() {
}

// Add flags to override values that will be added to ZarfState during an init
// An options is included to make the overwrite flags hidden
func addZarfStateOverrideFlags(commad *cobra.Command, makeHidden bool) {
commad.Flags().StringVar(&config.DeployOptions.Distro, "distro", "", "Kubernetes distro Zarf is deploying to")
commad.Flags().StringVar(&config.DeployOptions.StorageClass, "storage-class", "", "Describe the StorageClass to be used")
commad.Flags().StringVar(&config.DeployOptions.Secret, "secret", "", "Root secret value that is used to 'seed' other secrets")
commad.Flags().StringVar(&config.DeployOptions.NodePort, "nodeport", "", "Nodeport to access the Zarf container registry")
commad.Flags().StringVar(&config.DeployOptions.Architecture, "architecture", "", "Architecture for OCI images")
commad.Flags().StringVar(&config.DeployOptions.NodePort, "nodeport", "", "Nodeport to access the Zarf container registry. Between [30000-32767]")

if makeHidden {
packageDeployCmd.Flags().MarkHidden("distro")
packageDeployCmd.Flags().MarkHidden("storage-class")
packageDeployCmd.Flags().MarkHidden("secret")
packageDeployCmd.Flags().MarkHidden("nodeport")
packageDeployCmd.Flags().MarkHidden("architecture")
}
}
7 changes: 1 addition & 6 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ 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 @@ -151,7 +146,7 @@ func GetState() types.ZarfState {
}

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: 0 additions & 5 deletions cli/internal/k8s/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"regexp"

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

Expand All @@ -27,10 +26,6 @@ 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
5 changes: 4 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 @@ -79,6 +79,9 @@ func preSeedRegistry(tempPath tempPaths) {
}

// 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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/internal/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (values Values) Apply(path string) {
"STORAGE_CLASS": values.state.StorageClass,
"SEED_REGISTRY": values.seedRegistry,
"REGISTRY": values.registry,
"REGISTRY_NODEPORT": values.state.Registry.NodePort,
"NODEPORT": values.state.NodePort,
"REGISTRY_SECRET": values.secret.registrySecret,
"REGISTRY_AUTH_PUSH": values.secret.registryPush,
"REGISTRY_AUTH_PULL": values.secret.registryPull,
Expand Down
9 changes: 2 additions & 7 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 @@ -146,12 +143,10 @@ type ZarfDeployOptions struct {
// Zarf init is installing the k3s component
ApplianceMode bool

// Zarf init options
Distro string
// Zarf init override options
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 73cfe6f

Please sign in to comment.