Split xmltime to new file and update licensing information

This commit is contained in:
Harshavardhana
2015-03-08 19:18:50 -07:00
parent bc0245549a
commit ab01be0e3c
6 changed files with 184 additions and 34 deletions
+37
View File
@@ -1,3 +1,40 @@
// Original license //
// ---------------- //
/*
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.
*/
// All other modifications and improvements //
// ---------------------------------------- //
/*
* Mini Object Storage, (C) 2015 Minio, 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 s3
import (
-28
View File
@@ -46,25 +46,15 @@ import (
"net/http"
"regexp"
"strings"
"time"
"encoding/xml"
)
// Date format
const (
xmlTimeFormat = "2006-01-02T15:04:05.000Z"
)
// Total max object list
const (
MaxKeys = 1000
)
type xmlTime struct {
time.Time
}
// Client is an Amazon S3 client.
type Client struct {
*Auth
@@ -100,24 +90,6 @@ type listBucketResults struct {
CommonPrefixes []*Prefix
}
func (c *xmlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var v string
d.DecodeElement(&v, &start)
parse, _ := time.Parse(xmlTimeFormat, v)
*c = xmlTime{parse}
return nil
}
func (c *xmlTime) UnmarshalXMLAttr(attr xml.Attr) error {
t, _ := time.Parse(xmlTimeFormat, attr.Value)
*c = xmlTime{t}
return nil
}
func (c *xmlTime) format() string {
return c.Time.Format(xmlTimeFormat)
}
func (c *Client) transport() http.RoundTripper {
if c.Transport != nil {
return c.Transport
+37
View File
@@ -1,3 +1,40 @@
// Original license //
// ---------------- //
/*
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.
*/
// All other modifications and improvements //
// ---------------------------------------- //
/*
* Mini Object Storage, (C) 2015 Minio, 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 s3
import (
+37
View File
@@ -1,3 +1,40 @@
// Original license //
// ---------------- //
/*
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.
*/
// All other modifications and improvements //
// ---------------------------------------- //
/*
* Mini Object Storage, (C) 2015 Minio, 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 s3
import (
+71
View File
@@ -0,0 +1,71 @@
// Original license //
// ---------------- //
/*
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.
*/
// All other modifications and improvements //
// ---------------------------------------- //
/*
* Mini Object Storage, (C) 2015 Minio, 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 s3
import (
"time"
"encoding/xml"
)
// Date format
const (
xmlTimeFormat = "2006-01-02T15:04:05.000Z"
)
type xmlTime struct {
time.Time
}
func (c *xmlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var v string
d.DecodeElement(&v, &start)
parse, _ := time.Parse(xmlTimeFormat, v)
*c = xmlTime{parse}
return nil
}
func (c *xmlTime) UnmarshalXMLAttr(attr xml.Attr) error {
t, _ := time.Parse(xmlTimeFormat, attr.Value)
*c = xmlTime{t}
return nil
}
func (c *xmlTime) format() string {
return c.Time.Format(xmlTimeFormat)
}
+2 -6
View File
@@ -26,13 +26,9 @@ import (
"github.com/minio-io/mc/pkg/s3"
)
const (
humanReadableFormat = "2006-01-02 15:04:05"
)
func printBuckets(v []*s3.Bucket) {
for _, b := range v {
msg := fmt.Sprintf("%v %9s %s", b.CreationDate.Format(humanReadableFormat), "", b.Name)
msg := fmt.Sprintf("%v %9s %s", b.CreationDate.Local(), "", b.Name)
info(msg)
}
}
@@ -47,7 +43,7 @@ func printObjects(v []*s3.Item) {
}
func printObject(date time.Time, v int64, key string) {
msg := fmt.Sprintf("%v %9s %s", date.Format(humanReadableFormat), pb.FormatBytes(v), key)
msg := fmt.Sprintf("%v %9s %s", date.Local(), pb.FormatBytes(v), key)
info(msg)
}