-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image: Add image-layout directory based CAS and ref engines
These are much nicer than the tar engines (hooray atomic renames :), so switch the manifest tests tests back to using the directory-backed engines. I also switched the man-page examples over to directory-backed layouts, now that they're what oci-image-init generates by default. And I added command-line wrappers for the delete methods, now that we have a backend that implements it. I do with there was a paginated, callback-based directory lister we could use instead of ioutils.ReadDir. On the other hand, by the time directories get big enough for that to matter we may be sharding them anyway. Signed-off-by: W. Trevor King <wking@tremily.us>
- Loading branch information
Showing
25 changed files
with
716 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 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 main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/opencontainers/image-tools/image/cas/layout" | ||
"github.com/spf13/cobra" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type deleteCmd struct { | ||
path string | ||
digest string | ||
} | ||
|
||
func newDeleteCmd() *cobra.Command { | ||
state := &deleteCmd{} | ||
|
||
return &cobra.Command{ | ||
Use: "delete PATH DIGEST", | ||
Short: "Remove a blob from from the store", | ||
Run: state.Run, | ||
} | ||
} | ||
|
||
func (state *deleteCmd) Run(cmd *cobra.Command, args []string) { | ||
if len(args) != 2 { | ||
fmt.Fprintln(os.Stderr, "both PATH and DIGEST must be provided") | ||
if err := cmd.Usage(); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
} | ||
os.Exit(1) | ||
} | ||
|
||
state.path = args[0] | ||
state.digest = args[1] | ||
|
||
err := state.run() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
|
||
os.Exit(0) | ||
} | ||
|
||
func (state *deleteCmd) run() (err error) { | ||
ctx := context.Background() | ||
|
||
engine, err := layout.NewEngine(ctx, state.path) | ||
if err != nil { | ||
return err | ||
} | ||
defer engine.Close() | ||
|
||
return engine.Delete(ctx, state.digest) | ||
} |
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,27 @@ | ||
% OCI(1) OCI-IMAGE-TOOL User Manuals | ||
% OCI Community | ||
% SEPTEMBER 2016 | ||
# NAME | ||
|
||
oci-cas-get \- Remove a blob from the store | ||
|
||
# SYNOPSIS | ||
|
||
**oci-cas delete** [OPTIONS] PATH DIGEST | ||
|
||
# DESCRIPTION | ||
|
||
`oci-cas delete` removes the blob referenced by `DIGEST` from the store at `PATH`. | ||
|
||
# OPTIONS | ||
|
||
**--help** | ||
Print usage statement | ||
|
||
# SEE ALSO | ||
|
||
**oci-cas**(1), **oci-cas-get**(1), **oci-cas-put**(1) | ||
|
||
# HISTORY | ||
|
||
September 2016, Originally compiled by W. Trevor King (wking at tremily dot us) |
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
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,72 @@ | ||
// 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 main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/opencontainers/image-tools/image/refs/layout" | ||
"github.com/spf13/cobra" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type deleteCmd struct { | ||
path string | ||
name string | ||
} | ||
|
||
func newDeleteCmd() *cobra.Command { | ||
state := &deleteCmd{} | ||
|
||
return &cobra.Command{ | ||
Use: "delete PATH NAME", | ||
Short: "Remove a reference from the store", | ||
Run: state.Run, | ||
} | ||
} | ||
|
||
func (state *deleteCmd) Run(cmd *cobra.Command, args []string) { | ||
if len(args) != 2 { | ||
fmt.Fprintln(os.Stderr, "both PATH and NAME must be provided") | ||
if err := cmd.Usage(); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
} | ||
os.Exit(1) | ||
} | ||
|
||
state.path = args[0] | ||
state.name = args[1] | ||
|
||
err := state.run() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) | ||
} | ||
|
||
os.Exit(0) | ||
} | ||
|
||
func (state *deleteCmd) run() (err error) { | ||
ctx := context.Background() | ||
|
||
engine, err := layout.NewEngine(ctx, state.path) | ||
if err != nil { | ||
return err | ||
} | ||
defer engine.Close() | ||
|
||
return engine.Delete(ctx, state.name) | ||
} |
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,27 @@ | ||
% OCI(1) OCI-IMAGE-TOOL User Manuals | ||
% OCI Community | ||
% SEPTEMBER 2016 | ||
# NAME | ||
|
||
oci-refs-delete \- Remove a reference from the store | ||
|
||
# SYNOPSIS | ||
|
||
**oci-refs delete** [OPTIONS] PATH NAME | ||
|
||
# DESCRIPTION | ||
|
||
`oci-refs delete` removes reference `NAME` from the store at `PATH`. | ||
|
||
# OPTIONS | ||
|
||
**--help** | ||
Print usage statement | ||
|
||
# SEE ALSO | ||
|
||
**oci-refs**(1), **oci-refs-get**(1), **oci-refs-list**(1), **oci-refs-put**(1) | ||
|
||
# HISTORY | ||
|
||
September 2016, Originally compiled by W. Trevor King (wking at tremily dot us) |
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
Oops, something went wrong.