From 6d58c1fd1729837a527b0df2fd3911ae63238fb9 Mon Sep 17 00:00:00 2001 From: Jonathan Boulle Date: Sat, 24 Jan 2015 19:03:56 -0800 Subject: [PATCH] *: add missing godocs and copyright headers Also moves pkg/util/aci.go -> pkg/aci/aci.go for simplicity and consistency with the other pkgs. --- cas/cas_test.go | 6 +++--- cas/remote.go | 3 +++ cas/remote_test.go | 14 ++++++++++++++ networking/plugins/bridge/bridge.go | 14 ++++++++++++++ pkg/{util => aci}/aci.go | 17 ++++++++++++++++- pkg/keystore/keystore.go | 4 ++-- pkg/lock/dir.go | 6 ++++-- pkg/tar/tar.go | 3 ++- rkt/doc.go | 16 ++++++++++++++++ rkt/fetch_test.go | 28 +++++++++++++++++++++------- stage1/init/registration.go | 14 ++++++++++++++ 11 files changed, 109 insertions(+), 16 deletions(-) rename pkg/{util => aci}/aci.go (75%) create mode 100644 rkt/doc.go diff --git a/cas/cas_test.go b/cas/cas_test.go index fca89ce..4a471ac 100644 --- a/cas/cas_test.go +++ b/cas/cas_test.go @@ -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) } diff --git a/cas/remote.go b/cas/remote.go index 01875fd..a0cef31 100644 --- a/cas/remote.go +++ b/cas/remote.go @@ -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 ( diff --git a/cas/remote_test.go b/cas/remote_test.go index 7bf35ec..88182c9 100644 --- a/cas/remote_test.go +++ b/cas/remote_test.go @@ -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 ( diff --git a/networking/plugins/bridge/bridge.go b/networking/plugins/bridge/bridge.go index 575e95d..cbea767 100644 --- a/networking/plugins/bridge/bridge.go +++ b/networking/plugins/bridge/bridge.go @@ -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 ( diff --git a/pkg/util/aci.go b/pkg/aci/aci.go similarity index 75% rename from pkg/util/aci.go rename to pkg/aci/aci.go index 14d60f1..c70b6d0 100644 --- a/pkg/util/aci.go +++ b/pkg/aci/aci.go @@ -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" diff --git a/pkg/keystore/keystore.go b/pkg/keystore/keystore.go index 4256650..ad8af11 100644 --- a/pkg/keystore/keystore.go +++ b/pkg/keystore/keystore.go @@ -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 } diff --git a/pkg/lock/dir.go b/pkg/lock/dir.go index 1896f8d..aaec176 100644 --- a/pkg/lock/dir.go +++ b/pkg/lock/dir.go @@ -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 { diff --git a/pkg/tar/tar.go b/pkg/tar/tar.go index 8fc9a1e..fadddac 100644 --- a/pkg/tar/tar.go +++ b/pkg/tar/tar.go @@ -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 } diff --git a/rkt/doc.go b/rkt/doc.go new file mode 100644 index 0000000..704ac2c --- /dev/null +++ b/rkt/doc.go @@ -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 diff --git a/rkt/fetch_test.go b/rkt/fetch_test.go index 96ae65b..d6d7fcd 100644 --- a/rkt/fetch_test.go +++ b/rkt/fetch_test.go @@ -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) diff --git a/stage1/init/registration.go b/stage1/init/registration.go index 0817e27..1db4750 100644 --- a/stage1/init/registration.go +++ b/stage1/init/registration.go @@ -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 (