-
Notifications
You must be signed in to change notification settings - Fork 5
Installer Experience v2 - Milestone 1 #2187
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
Installer Experience v2 - Milestone 1 #2187
Conversation
This PR has been released (on staging) and is available for download with a embedded-cluster-smoke-test-staging-app license ID. Online Installer:
Airgap Installer (may take a few minutes before the airgap bundle is built):
Happy debugging! |
fcd2925
to
2753604
Compare
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
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.
Missing tests for getInstallStatus
and setInstallStatus
.
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.
Done via #2214
|
||
func NewDiscardLogger() *logrus.Logger { | ||
logger := logrus.New() | ||
logger.SetOutput(io.Discard) | ||
return logger | ||
} |
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.
Thoughts on having a "debug" logger or something along those lines that writes to stdout
with a well known format that allows us to distinguish between the cli logs and the API logs? This could be setup whenever the --debug
flag is passed to the cli (or an env var is setup in our local dev envs for easier local dev).
type MemoryStore struct { | ||
mu sync.RWMutex | ||
config *types.InstallationConfig | ||
status *types.InstallationStatus | ||
} |
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.
We should add tests to this store.
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.
Done via - #2226
func ValidateCIDR(cidr string) error { | ||
if err := netutils.ValidateCIDR(cidr, 16, true); err != nil { | ||
return fmt.Errorf("unable to validate cidr flag: %w", err) | ||
} | ||
return nil | ||
} | ||
|
||
type CIDRConfig struct { | ||
PodCIDR string | ||
ServiceCIDR string | ||
GlobalCIDR *string | ||
} | ||
|
||
// SplitCIDR takes a CIDR string and splits it into pod and service CIDRs | ||
// to be used for the cluster. It returns a CIDRConfig containing the split CIDRs | ||
// and the original global CIDR. | ||
func SplitCIDR(cidr string) (string, string, error) { | ||
podCIDR, serviceCIDR, err := netutils.SplitNetworkCIDR(cidr) | ||
if err != nil { | ||
return "", "", fmt.Errorf("unable to split cidr flag: %w", err) | ||
} | ||
return podCIDR, serviceCIDR, nil | ||
} |
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.
Should we add tests to these functions?
// GetCertificate returns a TLS certificate based on the provided configuration. | ||
// If cert and key files are provided, it uses those. Otherwise, it generates a self-signed certificate. | ||
func GetCertificate(cfg Config) (tls.Certificate, error) { | ||
if cfg.CertFile != "" && cfg.KeyFile != "" { | ||
logrus.Debugf("Using TLS configuration with cert file: %s and key file: %s", cfg.CertFile, cfg.KeyFile) | ||
return tls.LoadX509KeyPair(cfg.CertFile, cfg.KeyFile) | ||
} | ||
|
||
hostname, altNames := generateCertHostnames(cfg.Hostname) | ||
|
||
// Generate a new self-signed cert | ||
certData, keyData, err := certutil.GenerateSelfSignedCertKey(hostname, cfg.IPAddresses, altNames) | ||
if err != nil { | ||
return tls.Certificate{}, fmt.Errorf("generate self-signed cert: %w", err) | ||
} | ||
|
||
cert, err := tls.X509KeyPair(certData, keyData) | ||
if err != nil { | ||
return tls.Certificate{}, fmt.Errorf("create TLS certificate: %w", err) | ||
} | ||
|
||
logrus.Debugf("Using self-signed TLS certificate for hostname: %s", hostname) | ||
return cert, nil | ||
} | ||
|
||
// GetTLSConfig returns a TLS configuration with the provided certificate | ||
func GetTLSConfig(cert tls.Certificate) *tls.Config { | ||
return &tls.Config{ | ||
MinVersion: tls.VersionTLS12, | ||
CipherSuites: TLSCipherSuites, | ||
Certificates: []tls.Certificate{cert}, | ||
} | ||
} |
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.
Should we add tests to these functions?
// ListValidNetworkInterfaces returns a list of valid network interfaces that are up and not | ||
// loopback. | ||
func ListValidNetworkInterfaces() ([]net.Interface, error) { |
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.
We should test this function.
@@ -93,3 +116,32 @@ func firstValidIPNet(i net.Interface) (*net.IPNet, error) { | |||
} | |||
return nil, fmt.Errorf("could not find any non-local, non podnetwork ipv4 addresses") | |||
} | |||
|
|||
func ListAllValidIPAddresses() ([]net.IP, error) { |
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.
We should test this function.
c83276b
to
ec30def
Compare
ec30def
to
50ef28e
Compare
What this PR does / why we need it:
Which issue(s) this PR fixes:
Does this PR require a test?
Does this PR require a release note?
Does this PR require documentation?
NONE