github.com/argoproj/argo-events@v1.9.1/sensors/artifacts/inline.go (about) 1 /* 2 Copyright 2018 BlackRock, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package artifacts 18 19 import ( 20 "fmt" 21 22 "github.com/argoproj/argo-events/common/logging" 23 ) 24 25 // InlineReader implements the ArtifactReader interface for inlined artifacts 26 type InlineReader struct { 27 inlineArtifact *string 28 } 29 30 // NewInlineReader creates a new ArtifactReader for inline 31 func NewInlineReader(inlineArtifact *string) (ArtifactReader, error) { 32 // This should never happen! 33 if inlineArtifact == nil { 34 return nil, fmt.Errorf("InlineArtifact does not exist") 35 } 36 return &InlineReader{inlineArtifact}, nil 37 } 38 39 func (reader *InlineReader) Read() ([]byte, error) { 40 log := logging.NewArgoEventsLogger() 41 log.Debug("reading fileArtifact from inline") 42 return []byte(*reader.inlineArtifact), nil 43 }