harness-drone/plugin/config/repo.go
2019-02-19 15:56:41 -08:00

31 lines
798 B
Go

// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
package config
import (
"context"
"github.com/drone/drone/core"
)
// Repository returns a configuration service that fetches the yaml
// directly from the source code management (scm) system.
func Repository(service core.FileService) core.ConfigService {
return &repo{files: service}
}
type repo struct {
files core.FileService
}
func (r *repo) Find(ctx context.Context, req *core.ConfigArgs) (*core.Config, error) {
raw, err := r.files.Find(ctx, req.User, req.Repo.Slug, req.Build.After, req.Build.Ref, req.Repo.Config)
if err != nil {
return nil, err
}
return &core.Config{
Data: string(raw.Data),
}, err
}