Skip to content

Commit

Permalink
fix(executor): Fix artifactory saving files. Fixes #5733 (#5775)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored and sarabala1979 committed May 5, 2021
1 parent 6c16cec commit f6493ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,6 @@ type ArtifactLocationType interface {
SetKey(key string) error
}

var keyUnsupportedErr = fmt.Errorf("key unsupported")

// ArtifactLocation describes a location for a single or multiple artifacts.
// It is used as single artifact in the context of inputs/outputs (e.g. outputs.artifacts.artname).
// It is also used to describe the location of multiple artifacts such as the archive location
Expand Down Expand Up @@ -920,7 +918,7 @@ func (a *ArtifactLocation) HasKey() bool {
func (a *ArtifactLocation) SetKey(key string) error {
v := a.Get()
if v == nil {
return keyUnsupportedErr
return fmt.Errorf("key unsupported: cannot set key for artifact location because it is invalid")
}
return v.SetKey(key)
}
Expand Down Expand Up @@ -964,7 +962,7 @@ func (a *ArtifactLocation) IsArchiveLogs() bool {
func (a *ArtifactLocation) GetKey() (string, error) {
v := a.Get()
if v == nil {
return "", keyUnsupportedErr
return "", fmt.Errorf("key unsupported: cannot get key for artifact location, because it is invalid")
}
return v.GetKey()
}
Expand Down Expand Up @@ -1851,11 +1849,11 @@ func (g *GitArtifact) HasLocation() bool {
}

func (g *GitArtifact) GetKey() (string, error) {
return "", keyUnsupportedErr
return "", fmt.Errorf("key unsupported: git artifact does not have a key")
}

func (g *GitArtifact) SetKey(string) error {
return keyUnsupportedErr
return fmt.Errorf("key unsupported: cannot set key on git artifact")
}

func (g *GitArtifact) GetDepth() int {
Expand Down Expand Up @@ -1903,7 +1901,7 @@ func (a *ArtifactoryArtifact) SetKey(key string) error {
}

func (a *ArtifactoryArtifact) HasLocation() bool {
return a != nil && a.URL != ""
return a != nil && a.URL != "" && a.UsernameSecret != nil
}

// HDFSArtifact is the location of an HDFS artifact
Expand Down Expand Up @@ -1976,11 +1974,11 @@ type RawArtifact struct {
}

func (r *RawArtifact) GetKey() (string, error) {
return "", keyUnsupportedErr
return "", fmt.Errorf("key unsupported: raw artifat does not have key")
}

func (r *RawArtifact) SetKey(string) error {
return keyUnsupportedErr
return fmt.Errorf("key unsupported: cannot set key for raw artifact")
}

func (r *RawArtifact) HasLocation() bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/workflow/v1alpha1/workflow_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestArtifactLocation_HasLocation(t *testing.T) {

func TestArtifactoryArtifact(t *testing.T) {
a := &ArtifactoryArtifact{URL: "http://my-host"}
assert.True(t, a.HasLocation())
assert.False(t, a.HasLocation())
assert.NoError(t, a.SetKey("my-key"))
key, err := a.GetKey()
assert.NoError(t, err)
Expand Down

0 comments on commit f6493ac

Please sign in to comment.