2011-09-26 00:40:01 +00:00
/ *
Copyright 2011 Google 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 (
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
"errors"
2011-09-26 09:27:21 +00:00
"flag"
2012-07-28 23:32:31 +00:00
"fmt"
2011-09-26 09:27:21 +00:00
"strings"
2012-07-28 23:32:31 +00:00
"time"
2011-09-26 09:27:21 +00:00
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
"camlistore.org/pkg/client"
"camlistore.org/pkg/schema"
2011-09-26 00:40:01 +00:00
)
2011-09-26 09:27:21 +00:00
type permanodeCmd struct {
2012-07-28 23:32:31 +00:00
name string
tag string
key string // else random
sigTime string
2011-09-26 09:27:21 +00:00
}
func init ( ) {
2011-09-27 03:02:35 +00:00
RegisterCommand ( "permanode" , func ( flags * flag . FlagSet ) CommandRunner {
cmd := new ( permanodeCmd )
flags . StringVar ( & cmd . name , "name" , "" , "Optional name attribute to set on new permanode" )
flags . StringVar ( & cmd . tag , "tag" , "" , "Optional tag(s) to set on new permanode; comma separated." )
2012-07-28 23:32:31 +00:00
flags . StringVar ( & cmd . key , "key" , "" , "Optional key to create deterministic ('planned') permanodes. Must also use --sigtime." )
flags . StringVar ( & cmd . sigTime , "sigtime" , "" , "Optional time to put in the OpenPGP signature packet instead of the current time. Required when producing a deterministic permanode (with --key). In format YYYY-MM-DD HH:MM:SS" )
2011-09-27 03:02:35 +00:00
return cmd
} )
2011-09-26 09:27:21 +00:00
}
func ( c * permanodeCmd ) Usage ( ) {
2011-09-27 03:02:35 +00:00
errf ( "Usage: camput [globalopts] permanode [permanodeopts]\n" )
2011-09-26 09:27:21 +00:00
}
2011-09-27 03:02:35 +00:00
func ( c * permanodeCmd ) Examples ( ) [ ] string {
return [ ] string {
" (create a new permanode)" ,
` -name="Some Name" -tag=foo,bar (with attributes added) ` ,
2011-09-26 09:27:21 +00:00
}
2011-09-27 03:02:35 +00:00
}
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
func ( c * permanodeCmd ) RunCommand ( up * Uploader , args [ ] string ) error {
2011-09-26 09:27:21 +00:00
if len ( args ) > 0 {
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
return errors . New ( "Permanode command doesn't take any additional arguments" )
2011-09-26 09:27:21 +00:00
}
var (
permaNode * client . PutResult
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
err error
2011-09-26 09:27:21 +00:00
)
2012-07-28 23:32:31 +00:00
if ( c . key != "" ) != ( c . sigTime != "" ) {
return errors . New ( "Both --key and --sigtime must be used to produce deterministic permanodes." )
}
if c . key == "" {
// Normal case, with a random permanode.
permaNode , err = up . UploadNewPermanode ( )
} else {
const format = "2006-01-02 15:04:05"
sigTime , err := time . Parse ( format , c . sigTime )
if err != nil {
return fmt . Errorf ( "Error parsing time %q; expecting time of form %q" , c . sigTime , format )
}
permaNode , err = up . UploadPlannedPermanode ( c . key , sigTime )
}
2012-04-13 02:36:00 +00:00
if handleResult ( "permanode" , permaNode , err ) != nil {
return err
}
2011-09-26 00:40:01 +00:00
2011-09-26 09:27:21 +00:00
if c . name != "" {
2011-09-30 03:42:31 +00:00
put , err := up . UploadAndSignMap ( schema . NewSetAttributeClaim ( permaNode . BlobRef , "title" , c . name ) )
handleResult ( "claim-permanode-title" , put , err )
2011-09-26 09:27:21 +00:00
}
if c . tag != "" {
tags := strings . Split ( c . tag , "," )
m := schema . NewSetAttributeClaim ( permaNode . BlobRef , "tag" , tags [ 0 ] )
for _ , tag := range tags {
m = schema . NewAddAttributeClaim ( permaNode . BlobRef , "tag" , tag )
put , err := up . UploadAndSignMap ( m )
handleResult ( "claim-permanode-tag" , put , err )
}
}
2011-09-26 00:40:01 +00:00
return nil
}