forked from opencontainers/image-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Use local ref-engine discovery for layouts
Bump the layout to v1.1 to support this. This makes it possible to distribute layouts that use other protocols, for example new ref-engine protocols or a sharded blob store [1]. You can also reference external ref- and CAS-engines, although obviously the utility of such depends on the availability of those external engines. [1]: opencontainers#449 Signed-off-by: W. Trevor King <wking@tremily.us>
- Loading branch information
Showing
4 changed files
with
148 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2016 The Linux Foundation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v1 | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEngineConfigGood(t *testing.T) { | ||
for _, testcase := range []struct { | ||
JSON string | ||
Expected EngineConfig | ||
}{ | ||
{ | ||
JSON: `{"protocol":"oci-image-template-v1","uri":"index.json"}`, | ||
Expected: EngineConfig{ | ||
Protocol: "oci-image-template-v1", | ||
Data: map[string]interface{}{ | ||
"uri": "index.json", | ||
}, | ||
}, | ||
}, | ||
{ | ||
JSON: `{"protocol":"nested-array","x-array":[1.2,3.4]}`, | ||
Expected: EngineConfig{ | ||
Protocol: "nested-array", | ||
Data: map[string]interface{}{ | ||
"x-array": []interface{}{1.2, 3.4}, | ||
}, | ||
}, | ||
}, | ||
} { | ||
t.Run(testcase.JSON, func(t *testing.T) { | ||
var config EngineConfig | ||
json.Unmarshal([]byte(testcase.JSON), &config) | ||
assert.Equal(t, config, testcase.Expected) | ||
marshaled, err := json.Marshal(config) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
assert.Equal(t, string(marshaled), testcase.JSON) | ||
}) | ||
} | ||
} |