MCPcopy Create free account
hub / github.com/conforma/cli / DetermineInputSpec

Function DetermineInputSpec

internal/applicationsnapshot/input.go:93–183  ·  view source on GitHub ↗
(ctx context.Context, input Input)

Source from the content-addressed store, hash-verified

91}
92
93func DetermineInputSpec(ctx context.Context, input Input) (*app.SnapshotSpec, *ExpansionInfo, error) {
94 var snapshot snapshot
95 provided := false
96
97 if input.Images != "" {
98 var content []byte
99 var err error
100 fs := utils.FS(ctx)
101 content, err = afero.ReadFile(fs, input.Images)
102 if err != nil {
103 log.Debugf("could not read images from file: %v", err)
104 // could not read as file so expecting string
105 content = []byte(input.Images)
106 }
107
108 file, err := readSnapshotSource(content)
109 if err != nil {
110 return nil, nil, err
111 }
112 snapshot.merge(file)
113 provided = true
114 }
115
116 // read Snapshot provided as a file
117 if input.File != "" {
118 fs := utils.FS(ctx)
119 content, err := afero.ReadFile(fs, input.File)
120 if err != nil {
121 return nil, nil, err
122 }
123 file, err := readSnapshotSource(content)
124 if err != nil {
125 return nil, nil, err
126 }
127 snapshot.merge(file)
128 provided = true
129 }
130
131 // read Snapshot provided as a string
132 if input.JSON != "" {
133 json, err := readSnapshotSource([]byte(input.JSON))
134 if err != nil {
135 return nil, nil, err
136 }
137 snapshot.merge(json)
138 provided = true
139 }
140
141 // create Snapshot with a single image
142 if input.Image != "" {
143 log.Debugf("Generating application snapshot from image reference %s", input.Image)
144 imageSnapshot := app.SnapshotSpec{
145 Components: []app.SnapshotComponent{
146 {
147 Name: unnamed,
148 ContainerImage: input.Image,
149 },
150 },

Callers 4

runValidateVSAFunction · 0.92
validateImageCmdFunction · 0.92
Test_determineInputSpecFunction · 0.92
Test_DetermineInputSpecFunction · 0.85

Calls 6

mergeMethod · 0.95
FetchSnapshotMethod · 0.95
FSFunction · 0.92
NewClientFunction · 0.92
readSnapshotSourceFunction · 0.85
expandImageIndexFunction · 0.85

Tested by 2

Test_determineInputSpecFunction · 0.74
Test_DetermineInputSpecFunction · 0.68