32 lines
798 B
Go
32 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
|
||
|
}
|