@@ -68,9 +68,10 @@ type ClusterConfig struct {
6868 tmpHelmFilePath string
6969}
7070
71- // Defaults sets default values for the ClusterConfig fields if they are not already set.
72- // It initializes Helm values, file paths, and resource requests and limits with default values.
73- // It returns an error if any file operations fail during the setup process.
71+ // Defaults initializes default settings for the ClusterConfig.
72+ // It populates HelmValues and sets necessary file paths if they are not already configured.
73+ // The parameter a allows for customization during the defaulting process.
74+ // Returns an error if any defaulting operation fails.
7475func (m * ClusterConfig ) Defaults (a int ) error {
7576 // TODO: will it be more clear if we move Helm values to a struct
7677 // TODO: or should it be like that for extensibility of a chart without reflection?
@@ -135,8 +136,8 @@ func (m *ClusterConfig) Defaults(a int) error {
135136 return nil
136137}
137138
138- // Validate checks the ClusterConfig for required fields and returns an error if any are missing .
139- // Specifically, it ensures that the Namespace and HelmValues[ "jobs"] fields are not empty .
139+ // Validate checks that ClusterConfig has all required fields set .
140+ // It returns an error if Namespace is empty or if the "jobs" entry in HelmValues is missing .
140141func (m * ClusterConfig ) Validate () (err error ) {
141142 if m .Namespace == "" {
142143 err = errors .Join (err , ErrNoNamespace )
@@ -147,8 +148,9 @@ func (m *ClusterConfig) Validate() (err error) {
147148 return
148149}
149150
150- // parseECRImageURI parses an Amazon ECR image URI into its constituent parts: registry, repository, and tag.
151- // It returns an error if the URI does not match the expected format `${registry}/${repo}:${tag}`.
151+ // parseECRImageURI parses an ECR image URI and returns the registry, repository, and tag.
152+ // It expects the URI to follow the format ${registry}/${repo}:${tag}.
153+ // If the URI does not match this format, an error is returned.
152154func parseECRImageURI (uri string ) (registry , repo , tag string , err error ) {
153155 re := regexp .MustCompile (`^([^/]+)/([^:]+):(.+)$` )
154156 matches := re .FindStringSubmatch (uri )
@@ -167,10 +169,10 @@ type ClusterProfile struct {
167169}
168170
169171// NewClusterProfile creates a new ClusterProfile using the provided ClusterConfig.
170- // It validates and applies default settings to the configuration. It logs the configuration
171- // and sets a context with a timeout based on the test timeout duration specified in the config .
172- // If UpdateImage is true , it builds and pushes the image. It returns the ClusterProfile and
173- // any error encountered during the process .
172+ // It validates the configuration, sets default values, and initializes the Kubernetes client.
173+ // The function parses the test timeout duration and sets up a context with the specified timeout .
174+ // If UpdateImage is enabled in the configuration , it builds and pushes the image.
175+ // It returns the initialized ClusterProfile or an error if any step fails .
174176func NewClusterProfile (cfg * ClusterConfig ) (* ClusterProfile , error ) {
175177 if err := cfg .Validate (); err != nil {
176178 return nil , err
@@ -196,7 +198,9 @@ func NewClusterProfile(cfg *ClusterConfig) (*ClusterProfile, error) {
196198 return cp , nil
197199}
198200
199- // buildAndPushImage parses the ECR image URI from the configuration and constructs a command to build and push a Docker image. It returns an error if the URI parsing or command execution fails.
201+ // buildAndPushImage builds and pushes a Docker image based on the ClusterProfile configuration.
202+ // It parses the ECR image URI, constructs the Docker build and push command,
203+ // executes the command, and returns any encountered error.
200204func (m * ClusterProfile ) buildAndPushImage () error {
201205 registry , repo , tag , err := parseECRImageURI (m .cfg .HelmValues ["image" ])
202206 if err != nil {
@@ -215,10 +219,10 @@ func (m *ClusterProfile) buildAndPushImage() error {
215219 return ExecCmd (cmd )
216220}
217221
218- // deployHelm installs a Helm chart using the specified testName as the release name .
219- // It constructs the Helm command with the chart path, values, namespace, and timeout
220- // from the ClusterProfile configuration. It returns any error encountered during the
221- // execution of the Helm command .
222+ // deployHelm installs the Helm chart using the provided testName and the ClusterProfile's configuration .
223+ // It sets the necessary Helm values, namespace, and deployment timeout based on the configuration.
224+ // The function constructs the Helm install command, logs the execution, and runs the command.
225+ // Returns an error if the Helm deployment fails .
222226func (m * ClusterProfile ) deployHelm (testName string ) error {
223227 //nolint
224228 defer os .Remove (m .cfg .tmpHelmFilePath )
@@ -233,10 +237,9 @@ func (m *ClusterProfile) deployHelm(testName string) error {
233237 return ExecCmd (cmd .String ())
234238}
235239
236- // Run generates a unique test name, modifies it to comply with Helm naming rules,
237- // and deploys a Helm chart using this name. It retrieves the number of jobs from
238- // the Helm values and tracks these jobs within the specified namespace. It returns
239- // an error if any step in the process fails.
240+ // Run deploys the Helm chart using a generated test name and tracks the specified number of jobs.
241+ // It modifies the test name to ensure it starts with a letter and retrieves job configurations
242+ // from the cluster profile. Returns an error if deployment or job tracking fails.
240243func (m * ClusterProfile ) Run () error {
241244 testName := uuid .NewString ()[0 :8 ]
242245 tn := []rune (testName )
0 commit comments