You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	feat (cpe) introduce a new artifact cpe type (#3763)
* including a artifact cpe type * removing type kind related to PR 3717 * clean up * eliminating local path * go formatting fix Co-authored-by: anilkeshav27 <you@example.com>
This commit is contained in:
		
							
								
								
									
										18
									
								
								pkg/piperenv/artifact.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								pkg/piperenv/artifact.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | |||||||
|  | package piperenv | ||||||
|  |  | ||||||
|  | type Artifact struct { | ||||||
|  | 	Name string `json:"name,omitempty"` | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type Artifacts []Artifact | ||||||
|  |  | ||||||
|  | func (a Artifacts) FindByName(name string) Artifacts { | ||||||
|  | 	var filtered Artifacts | ||||||
|  |  | ||||||
|  | 	for _, artifact := range a { | ||||||
|  | 		if artifact.Name == name { | ||||||
|  | 			filtered = append(filtered, artifact) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return filtered | ||||||
|  | } | ||||||
							
								
								
									
										19
									
								
								pkg/piperenv/artifact_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								pkg/piperenv/artifact_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | package piperenv | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"testing" | ||||||
|  |  | ||||||
|  | 	"github.com/stretchr/testify/assert" | ||||||
|  | 	"github.com/stretchr/testify/require" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func Test_Artifacts_FindByName(t *testing.T) { | ||||||
|  | 	artifacts := Artifacts([]Artifact{{ | ||||||
|  | 		Name: "a.jar", | ||||||
|  | 	}}) | ||||||
|  |  | ||||||
|  | 	assert.Len(t, artifacts.FindByName("garbage"), 0) | ||||||
|  | 	filtered := artifacts.FindByName("a.jar") | ||||||
|  | 	require.Len(t, filtered, 1) | ||||||
|  | 	assert.Equal(t, "a.jar", filtered[0].Name) | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user