github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/runtime/asdf/metadata/metadata.go (about) 1 // Copyright 2025 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package metadata defines a metadata struct for Asdf Tools. 16 package metadata 17 18 import ( 19 pb "github.com/google/osv-scalibr/binary/proto/scan_result_go_proto" 20 ) 21 22 // Metadata holds parsing information for an Asdf tool. 23 type Metadata struct { 24 ToolName string 25 ToolVersion string 26 } 27 28 // SetProto sets the AsdfMetadata field in the Package proto. 29 func (m *Metadata) SetProto(p *pb.Package) { 30 if m == nil { 31 return 32 } 33 if p == nil { 34 return 35 } 36 37 p.Metadata = &pb.Package_AsdfMetadata{ 38 AsdfMetadata: &pb.AsdfMetadata{ 39 ToolName: m.ToolName, 40 ToolVersion: m.ToolVersion, 41 }, 42 } 43 } 44 45 // ToStruct converts the AsdfMetadata proto to a Metadata struct. 46 func ToStruct(m *pb.AsdfMetadata) *Metadata { 47 if m == nil { 48 return nil 49 } 50 51 return &Metadata{ 52 ToolName: m.GetToolName(), 53 ToolVersion: m.GetToolVersion(), 54 } 55 }