Skip to content

Commit

Permalink
look for MinIO release tag from container labels (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Jun 21, 2022
1 parent 5c837bc commit 6c18137
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions pkg/controller/cluster/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
package cluster

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
"strings"
"time"

Expand All @@ -43,21 +41,6 @@ import (
miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
)

func (c *Controller) fetchTag(path string) (string, error) {
cmd := exec.Command(path, "--version")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return "", err
}
op := strings.Fields(out.String())
if len(op) < 3 {
return "", fmt.Errorf("incorrect output while fetching tag value - %d", len((op)))
}
return op[2], nil
}

// minioKeychain implements Keychain to pass custom credentials
type minioKeychain struct {
authn.Keychain
Expand Down Expand Up @@ -140,6 +123,20 @@ func (c *Controller) fetchArtifacts(tenant *miniov2.Tenant) (latest time.Time, e
return latest, err
}

cfg, err := img.ConfigFile()
if err != nil {
return latest, err
}

tag, ok := cfg.Config.Labels["release"]
if !ok {
tag, ok = cfg.Config.Labels["version"]
}
tag = strings.TrimSpace(tag)
if !ok || tag == "" {
return latest, errors.New("missing tag")
}

ls, err := img.Layers()
if err != nil {
return latest, err
Expand Down Expand Up @@ -199,11 +196,6 @@ func (c *Controller) fetchArtifacts(tenant *miniov2.Tenant) (latest time.Time, e
srcShaSum := "minio.sha256sum"
srcSig := "minio.minisig"

tag, err := c.fetchTag(basePath + srcBinary)
if err != nil {
return latest, err
}

latest, err = miniov2.ReleaseTagToReleaseTime(tag)
if err != nil {
return latest, err
Expand Down

0 comments on commit 6c18137

Please sign in to comment.