mirror of
https://github.com/clearlinux/rkt.git
synced 2026-09-01 11:26:05 +00:00
*: add missing godocs and copyright headers
Also moves pkg/util/aci.go -> pkg/aci/aci.go for simplicity and consistency with the other pkgs.
This commit is contained in:
+3
-3
@@ -25,7 +25,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/appc/spec/schema/types"
|
||||
"github.com/coreos/rocket/pkg/util"
|
||||
"github.com/coreos/rocket/pkg/aci"
|
||||
)
|
||||
|
||||
const tstprefix = "cas-test"
|
||||
@@ -59,7 +59,7 @@ func TestDownloading(t *testing.T) {
|
||||
"name": "example.com/test01"
|
||||
}`
|
||||
|
||||
entries := []*util.ACIEntry{
|
||||
entries := []*aci.ACIEntry{
|
||||
// An empty file
|
||||
{
|
||||
Contents: "hello",
|
||||
@@ -70,7 +70,7 @@ func TestDownloading(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
aci, err := util.NewACI(dir, imj, entries)
|
||||
aci, err := aci.NewACI(dir, imj, entries)
|
||||
if err != nil {
|
||||
t.Fatalf("error creating test tar: %v", err)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package cas implements a content-addressable-store on disk.
|
||||
// It leverages the `diskv` package to store items in a simple
|
||||
// key-value blob store: https://github.com/peterbourgon/diskv
|
||||
package cas
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 cas
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 (
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
package util
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 aci implements helper functions for working with ACIs
|
||||
package aci
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
@@ -38,8 +38,8 @@ type Config struct {
|
||||
SystemPrefixPath string
|
||||
}
|
||||
|
||||
// A Keystore represents a repository of trusted keys which can be used to verify
|
||||
// ACI images.
|
||||
// A Keystore represents a repository of trusted public keys which can be
|
||||
// used to verify PGP signatures.
|
||||
type Keystore struct {
|
||||
*Config
|
||||
}
|
||||
|
||||
+4
-2
@@ -12,9 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package lock implements simple locking primitives on a
|
||||
// directory using flock
|
||||
package lock
|
||||
|
||||
// Package lock implements simple locking primitives on a directory using flock
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
@@ -26,6 +27,7 @@ var (
|
||||
ErrPermission = errors.New("permission denied")
|
||||
)
|
||||
|
||||
// DirLock represents a lock on a directory
|
||||
type DirLock struct {
|
||||
dir string
|
||||
fd int
|
||||
@@ -131,7 +133,7 @@ func (l *DirLock) Unlock() error {
|
||||
return syscall.Flock(l.fd, syscall.LOCK_UN)
|
||||
}
|
||||
|
||||
// Fd returns the lock's file descriptor
|
||||
// Fd returns the lock's file descriptor, or an error if the lock is closed
|
||||
func (l *DirLock) Fd() (int, error) {
|
||||
var err error
|
||||
if l.fd == -1 {
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package tar contains helper functions for working with tar files
|
||||
package tar
|
||||
|
||||
import (
|
||||
@@ -86,7 +87,7 @@ func ExtractFile(tr *tar.Reader, hdr *tar.Header, dir string, overwrite bool) er
|
||||
}
|
||||
}
|
||||
|
||||
// Create parent dir if it doesn't exists
|
||||
// Create parent dir if it doesn't exist
|
||||
if err := os.MkdirAll(filepath.Dir(p), DEFAULT_DIR_MODE); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 rkt (main) implements the command line interface to rocket
|
||||
package main
|
||||
+21
-7
@@ -1,3 +1,17 @@
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 (
|
||||
@@ -13,9 +27,9 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/coreos/rocket/cas"
|
||||
"github.com/coreos/rocket/pkg/aci"
|
||||
"github.com/coreos/rocket/pkg/keystore"
|
||||
"github.com/coreos/rocket/pkg/keystore/keystoretest"
|
||||
"github.com/coreos/rocket/pkg/util"
|
||||
|
||||
"github.com/appc/spec/discovery"
|
||||
)
|
||||
@@ -118,31 +132,31 @@ func TestFetchImage(t *testing.T) {
|
||||
if _, err := ks.StoreTrustedKeyPrefix("example.com/app", bytes.NewBufferString(key.ArmoredPublicKey)); err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
aci, err := util.NewBasicACI(dir, "example.com/app")
|
||||
defer aci.Close()
|
||||
a, err := aci.NewBasicACI(dir, "example.com/app")
|
||||
defer a.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
// Rewind the ACI
|
||||
if _, err := aci.Seek(0, 0); err != nil {
|
||||
if _, err := a.Seek(0, 0); err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
sig, err := util.NewDetachedSignature(key.ArmoredPrivateKey, aci)
|
||||
sig, err := aci.NewDetachedSignature(key.ArmoredPrivateKey, a)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
// Rewind the ACI.
|
||||
if _, err := aci.Seek(0, 0); err != nil {
|
||||
if _, err := a.Seek(0, 0); err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch filepath.Ext(r.URL.Path) {
|
||||
case ".aci":
|
||||
io.Copy(w, aci)
|
||||
io.Copy(w, a)
|
||||
return
|
||||
case ".sig":
|
||||
io.Copy(w, sig)
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright 2014 CoreOS, Inc.
|
||||
//
|
||||
// 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 (
|
||||
|
||||
Reference in New Issue
Block a user