~comcloudway/builds.sr.ht

d910c2317fc095c92e04976859366f1a5f794d48 — Jakob Meier 9 months ago ef846fc
Allow maximum artifact count to be customized

Falls back to 8 artifacts per job if the config key max-artifacts isn't
set
1 files changed, 16 insertions(+), 3 deletions(-)

M worker/tasks.go
M worker/tasks.go => worker/tasks.go +16 -3
@@ 624,14 624,27 @@ func (ctx *JobContext) UploadArtifacts() error {
	if len(ctx.Manifest.Artifacts) == 0 {
		return nil
	}
	if len(ctx.Manifest.Artifacts) > 8 {
	var (
		ok            bool
		err           error
		artifactCount string
		maxArtifacts  int
	)

	if artifactCount, ok = config.Get("builds.sr.ht::worker", "max-artifacts"); !ok {
		// default to old hardcoded value if the key wasn't found in the config file
		artifactCount = "8"
	}
	if maxArtifacts, err = strconv.Atoi(artifactCount); err != nil {
		return errors.New("The maximum build-artifact count could not be read")
	}
	if len(ctx.Manifest.Artifacts) > maxArtifacts {
		ctx.Log.Println("Error: no more than 8 artifacts " +
			"per build are accepted.")
		return nil
	}

	var (
		ok        bool
		upstream  string
		accessKey string
		secretKey string


@@ 639,7 652,7 @@ func (ctx *JobContext) UploadArtifacts() error {
		prefix    string
		location string
	)
	err := errors.New("Build artifacts were requested, but S3 " +
	err = errors.New("Build artifacts were requested, but S3 " +
		"is not configured for this build runner.")
	if upstream, ok = config.Get("objects", "s3-upstream"); !ok || upstream == "" {
		return err