Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(library): add ServiceFromBuildContainer() #226

Merged
merged 3 commits into from
Jan 18, 2022

Conversation

jbrockopp
Copy link
Contributor

Essentially a copy of #205

This adds a ServiceFromBuildContainer() function to the github.com/go-vela/types/library package:

types/library/service.go

Lines 503 to 528 in 240fd4a

// ServiceFromBuildContainer creates a new Service based on a Build and pipeline Container.
func ServiceFromBuildContainer(build *Build, ctn *pipeline.Container) *Service {
// create new service type we want to return
s := new(Service)
// default status to Pending
s.SetStatus(constants.StatusPending)
// copy fields from build
if build != nil {
// set values from the build
s.SetHost(build.GetHost())
s.SetRuntime(build.GetRuntime())
s.SetDistribution(build.GetDistribution())
}
// copy fields from container
if ctn != nil && ctn.Name != "" {
// set values from the container
s.SetName(ctn.Name)
s.SetNumber(ctn.Number)
s.SetImage(ctn.Image)
}
return s
}

Similar to StepFromBuildContainer(), that was added in the above PR, this will be used in the go-vela/worker codebase.

Also, following along with the above PR, ServiceFromContainer was renamed to ServiceFromContainerEnvironment.

@jbrockopp jbrockopp added the feature Indicates a new feature label Jan 8, 2022
@jbrockopp jbrockopp requested a review from a team as a code owner January 8, 2022 06:32
@jbrockopp jbrockopp self-assigned this Jan 8, 2022
@codecov
Copy link

codecov bot commented Jan 8, 2022

Codecov Report

Merging #226 (f151e08) into master (c491e96) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #226      +/-   ##
==========================================
+ Coverage   97.03%   97.04%   +0.01%     
==========================================
  Files          53       53              
  Lines        5729     5750      +21     
==========================================
+ Hits         5559     5580      +21     
  Misses        125      125              
  Partials       45       45              
Impacted Files Coverage Δ
library/step.go 100.00% <ø> (ø)
library/service.go 86.84% <100.00%> (+0.86%) ⬆️

Copy link
Member

@cognifloyd cognifloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎 LGTM

Copy link

@kneal kneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐬

Copy link
Contributor

@KellyMerrick KellyMerrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jbrockopp jbrockopp merged commit 5877b05 into master Jan 18, 2022
@jbrockopp jbrockopp deleted the feature/library/serviceFromContainer branch January 18, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants