@@ -68,10 +68,8 @@ type ClusterConfig struct {
6868 tmpHelmFilePath string
6969}
7070
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.
71+ // Defaults initializes ClusterConfig with default values for any unset fields.
72+ // It ensures all necessary configuration parameters are provided for proper cluster deployment.
7573func (m * ClusterConfig ) Defaults (a int ) error {
7674 // TODO: will it be more clear if we move Helm values to a struct
7775 // TODO: or should it be like that for extensibility of a chart without reflection?
@@ -136,8 +134,8 @@ func (m *ClusterConfig) Defaults(a int) error {
136134 return nil
137135}
138136
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.
137+ // Validate checks that the ClusterConfig has all required fields set.
138+ // It returns an error if any mandatory configuration is missing.
141139func (m * ClusterConfig ) Validate () (err error ) {
142140 if m .Namespace == "" {
143141 err = errors .Join (err , ErrNoNamespace )
@@ -148,9 +146,9 @@ func (m *ClusterConfig) Validate() (err error) {
148146 return
149147}
150148
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 .
149+ // parseECRImageURI parses an ECR image URI into registry, repository, and tag.
150+ // It returns an error if the URI format is invalid .
151+ // Use it to extract components for building and deploying Docker images .
154152func parseECRImageURI (uri string ) (registry , repo , tag string , err error ) {
155153 re := regexp .MustCompile (`^([^/]+)/([^:]+):(.+)$` )
156154 matches := re .FindStringSubmatch (uri )
@@ -168,11 +166,10 @@ type ClusterProfile struct {
168166 Cancel context.CancelFunc
169167}
170168
171- // NewClusterProfile creates a new ClusterProfile using the provided ClusterConfig.
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.
169+ // NewClusterProfile creates a new ClusterProfile from the provided ClusterConfig.
170+ // It validates the configuration, sets default values, and initializes necessary components.
171+ // Optionally, it builds and pushes images based on the configuration.
172+ // Use this function to initialize cluster management.
176173func NewClusterProfile (cfg * ClusterConfig ) (* ClusterProfile , error ) {
177174 if err := cfg .Validate (); err != nil {
178175 return nil , err
@@ -198,9 +195,8 @@ func NewClusterProfile(cfg *ClusterConfig) (*ClusterProfile, error) {
198195 return cp , nil
199196}
200197
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.
198+ // buildAndPushImage builds a Docker image using the cluster's configuration and pushes it to the specified registry.
199+ // It returns an error if the build or push operation fails.
204200func (m * ClusterProfile ) buildAndPushImage () error {
205201 registry , repo , tag , err := parseECRImageURI (m .cfg .HelmValues ["image" ])
206202 if err != nil {
@@ -219,10 +215,8 @@ func (m *ClusterProfile) buildAndPushImage() error {
219215 return ExecCmd (cmd )
220216}
221217
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.
218+ // deployHelm installs a Helm chart using the provided test name and the ClusterProfile's configuration.
219+ // It constructs the Helm install command with specified values, namespace, and timeout, then executes it.
226220func (m * ClusterProfile ) deployHelm (testName string ) error {
227221 //nolint
228222 defer os .Remove (m .cfg .tmpHelmFilePath )
@@ -237,9 +231,9 @@ func (m *ClusterProfile) deployHelm(testName string) error {
237231 return ExecCmd (cmd .String ())
238232}
239233
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.
234+ // Run deploys the Helm chart and tracks job execution for the ClusterProfile .
235+ // It generates a unique ID, deploys via Helm, and monitors jobs in the namespace.
236+ // Returns an error if deployment or tracking fails.
243237func (m * ClusterProfile ) Run () error {
244238 testName := uuid .NewString ()[0 :8 ]
245239 tn := []rune (testName )
0 commit comments