go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/roller-configurator/proto/resolvers.go (about) 1 // Copyright 2023 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package proto 6 7 import ( 8 "context" 9 ) 10 11 // ResolveParams represents additional parameters that get passed into each 12 // roller type's `Resolve` function. 13 type ResolveParams struct { 14 RepoRoot string 15 DefaultCheckoutJiriManifest string 16 } 17 18 func (s *GitSubmodule) Resolve(ctx context.Context, params ResolveParams) (map[string]any, error) { 19 res, err := ProtoToMap(s) 20 if err != nil { 21 return nil, err 22 } 23 res["remote"], err = s.url(ctx, params.RepoRoot) 24 if err != nil { 25 return nil, err 26 } 27 res["type"] = "submodule" 28 return res, nil 29 } 30 31 func (c *CIPDEnsureFile) Resolve(ctx context.Context, params ResolveParams) (map[string]any, error) { 32 res, err := ProtoToMap(c) 33 if err != nil { 34 return nil, err 35 } 36 res["type"] = "cipd_ensure_file" 37 return res, nil 38 } 39 40 func (p *JiriProject) Resolve(ctx context.Context, params ResolveParams) (map[string]any, error) { 41 me, err := p.manifestEntry(params.RepoRoot) 42 if err != nil { 43 return nil, err 44 } 45 res, err := ProtoToMap(p) 46 if err != nil { 47 return nil, err 48 } 49 res["remote"] = me.Remote 50 res["remote_branch"] = me.RemoteBranch 51 res["checkout_manifest"] = params.DefaultCheckoutJiriManifest 52 res["type"] = "jiri_project" 53 return res, nil 54 } 55 56 func (p *JiriPackages) Resolve(ctx context.Context, params ResolveParams) (map[string]any, error) { 57 if p.Ref == "" { 58 p.Ref = "latest" 59 } 60 res, err := ProtoToMap(p) 61 if err != nil { 62 return nil, err 63 } 64 res["checkout_manifest"] = params.DefaultCheckoutJiriManifest 65 res["type"] = "jiri_packages" 66 return res, nil 67 }