예제 #1
0
func (delegate *delegate) saveImplicitOutput(logger lager.Logger, plan atc.GetPlan, info exec.VersionInfo) {
	if plan.Pipeline == "" {
		return
	}

	metadata := make([]db.MetadataField, len(info.Metadata))
	for i, md := range info.Metadata {
		metadata[i] = db.MetadataField{
			Name:  md.Name,
			Value: md.Value,
		}
	}

	_, err := delegate.db.SaveBuildOutput(delegate.buildID, db.VersionedResource{
		PipelineName: plan.Pipeline,
		Resource:     plan.Resource,
		Type:         plan.Type,
		Version:      db.Version(info.Version),
		Metadata:     metadata,
	}, false)
	if err != nil {
		logger.Error("failed-to-save", err)
		return
	}

	logger.Info("saved", lager.Data{"resource": plan.Resource})
}
예제 #2
0
func vrFromOutput(pipelineName string, putted event.FinishPut) db.VersionedResource {
	return db.VersionedResource{
		Resource:     putted.Plan.Resource,
		PipelineName: pipelineName,
		Type:         putted.Plan.Type,
		Version:      db.Version(putted.CreatedVersion),
		Metadata:     atcMetadataToDBMetadata(putted.CreatedMetadata),
	}
}
예제 #3
0
func vrFromInput(plan atc.GetPlan, fetchedInfo exec.VersionInfo) db.VersionedResource {
	return db.VersionedResource{
		Resource:     plan.Resource,
		PipelineName: plan.Pipeline,
		Type:         plan.Type,
		Version:      db.Version(fetchedInfo.Version),
		Metadata:     atcMetadataToDBMetadata(fetchedInfo.Metadata),
	}
}
예제 #4
0
func vrFromOutput(pipelineName string, putted event.FinishPut) db.VersionedResource {
	metadata := make([]db.MetadataField, len(putted.CreatedMetadata))
	for i, md := range putted.CreatedMetadata {
		metadata[i] = db.MetadataField{
			Name:  md.Name,
			Value: md.Value,
		}
	}

	return db.VersionedResource{
		Resource:     putted.Plan.Resource,
		PipelineName: pipelineName,
		Type:         putted.Plan.Type,
		Version:      db.Version(putted.CreatedVersion),
		Metadata:     metadata,
	}
}
예제 #5
0
func vrFromInput(pipelineName string, got event.FinishGet) db.VersionedResource {
	metadata := make([]db.MetadataField, len(got.FetchedMetadata))
	for i, md := range got.FetchedMetadata {
		metadata[i] = db.MetadataField{
			Name:  md.Name,
			Value: md.Value,
		}
	}

	return db.VersionedResource{
		Resource:     got.Plan.Resource,
		PipelineName: pipelineName,
		Type:         got.Plan.Type,
		Version:      db.Version(got.FetchedVersion),
		Metadata:     metadata,
	}
}
				Source: atc.Source{"some": "source"},
			}

			versions = nil
			expectedVersions = nil
			for i := 0; i < 10; i++ {
				version := atc.Version{"version": fmt.Sprintf("%d", i+1)}
				versions = append(versions, version)
				expectedVersions = append(expectedVersions,
					db.SavedVersionedResource{
						ID:      i + 1,
						Enabled: true,
						VersionedResource: db.VersionedResource{
							Resource:     resource.Name,
							Type:         resource.Type,
							Version:      db.Version(version),
							Metadata:     nil,
							PipelineName: pipelineDB.GetPipelineName(),
						},
					})
			}

			err := pipelineDB.SaveResourceVersions(resource, versions)
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when there are no versions to be found", func() {
			It("returns the versions, with previous/next pages", func() {
				historyPage, pagination, err := pipelineDB.GetResourceVersions("nope", db.Page{})
				Expect(err).ToNot(HaveOccurred())
				Expect(historyPage).To(Equal([]db.SavedVersionedResource{}))