Skip to content

Commit

Permalink
Promote Release properties
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
  • Loading branch information
JAORMX committed Dec 12, 2024
1 parent eb64d08 commit 99ce81d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
10 changes: 10 additions & 0 deletions internal/entities/properties/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ const (
// ArtifactPropertyType represents the type of the artifact (e.g 'container')
ArtifactPropertyType = "type"
)

// Release property keys
const (
// ReleasePropertyTag represents the release tag name.
ReleasePropertyTag = "tag"
// ReleasePropertyBranch represents the release branch
ReleasePropertyBranch = "branch"
// ReleaseCommitSHA represents the commit SHA of the release
ReleaseCommitSHA = "commit_sha"
)
19 changes: 8 additions & 11 deletions internal/providers/github/properties/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ const (
ReleasePropertyOwner = "github/owner"
// ReleasePropertyRepo represents the github repo
ReleasePropertyRepo = "github/repo"
// ReleasePropertyTag represents the github release tag name.
ReleasePropertyTag = "github/tag"
// ReleasePropertyBranch represents the github release branch
ReleasePropertyBranch = "github/branch"
)

// ReleaseFetcher is a property fetcher for releases
Expand All @@ -43,8 +39,10 @@ func NewReleaseFetcher() *ReleaseFetcher {
properties.PropertyName,
properties.PropertyUpstreamID,
// general release
ReleasePropertyTag,
ReleasePropertyBranch,
properties.ReleasePropertyTag,
properties.ReleasePropertyBranch,
ReleasePropertyOwner,
ReleasePropertyRepo,
},
wrapper: getReleaseWrapper,
},
Expand All @@ -62,7 +60,7 @@ func (_ *ReleaseFetcher) GetName(props *properties.Properties) (string, error) {
return "", fmt.Errorf("failed to get repo name: %w", err)
}

tag, err := props.GetProperty(ReleasePropertyTag).AsString()
tag, err := props.GetProperty(properties.ReleasePropertyTag).AsString()
if err != nil {
return "", fmt.Errorf("failed to get tag name: %w", err)
}
Expand Down Expand Up @@ -115,8 +113,7 @@ func getReleaseWrapper(
properties.PropertyName: getReleaseNameFromParams(owner, repo, release.GetTagName()),
ReleasePropertyOwner: owner,
ReleasePropertyRepo: repo,
ReleasePropertyTag: release.GetTagName(),
ReleasePropertyBranch: release.GetTargetCommitish(),
properties.ReleasePropertyTag: release.GetTagName(),
}, nil
}

Expand All @@ -127,12 +124,12 @@ func EntityInstanceV1FromReleaseProperties(props *properties.Properties) (*minde
return nil, fmt.Errorf("upstream ID not found or invalid: %w", err)
}

tag, err := props.GetProperty(ReleasePropertyTag).AsString()
tag, err := props.GetProperty(properties.ReleasePropertyTag).AsString()
if err != nil {
return nil, fmt.Errorf("tag not found or invalid: %w", err)
}

_, err = props.GetProperty(ReleasePropertyBranch).AsString()
_, err = props.GetProperty(properties.ReleasePropertyBranch).AsString()
if err != nil {
return nil, fmt.Errorf("branch not found or invalid: %w", err)
}
Expand Down

0 comments on commit 99ce81d

Please sign in to comment.