Locally define protobuf Any to fix serialization issues.

pull/2724/head
tamal 8 years ago
parent e8d80729ac
commit 808de3f56b

@ -40,5 +40,15 @@ message Chart {
// Miscellaneous files in a chart archive, // Miscellaneous files in a chart archive,
// e.g. README, LICENSE, etc. // e.g. README, LICENSE, etc.
repeated google.protobuf.Any files = 5; repeated Any files = 5;
}
// Copied from https://github.com/golang/protobuf/blob/master/ptypes/any/any.proto
message Any {
// A resource name whose content describes the type of the
// serialized data.
string type_url = 1;
// Data for file.
bytes value = 2;
} }

@ -26,7 +26,7 @@ import (
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/gobwas/glob" "github.com/gobwas/glob"
"github.com/golang/protobuf/ptypes/any" any "k8s.io/helm/pkg/proto/hapi/chart"
) )
// Files is a map of files in a chart that can be accessed from a template. // Files is a map of files in a chart that can be accessed from a template.

@ -18,8 +18,8 @@ package chartutil
import ( import (
"testing" "testing"
"github.com/golang/protobuf/ptypes/any"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
any "k8s.io/helm/pkg/proto/hapi/chart"
) )
var cases = []struct { var cases = []struct {

@ -29,7 +29,6 @@ import (
"strings" "strings"
"github.com/facebookgo/symwalk" "github.com/facebookgo/symwalk"
"github.com/golang/protobuf/ptypes/any"
"k8s.io/helm/pkg/ignore" "k8s.io/helm/pkg/ignore"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
@ -139,7 +138,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
c.Templates = append(c.Templates, &chart.Template{Name: f.Name, Data: f.Data}) c.Templates = append(c.Templates, &chart.Template{Name: f.Name, Data: f.Data})
} else if strings.HasPrefix(f.Name, "charts/") { } else if strings.HasPrefix(f.Name, "charts/") {
if filepath.Ext(f.Name) == ".prov" { if filepath.Ext(f.Name) == ".prov" {
c.Files = append(c.Files, &any.Any{TypeUrl: f.Name, Value: f.Data}) c.Files = append(c.Files, &chart.Any{TypeUrl: f.Name, Value: f.Data})
continue continue
} }
cname := strings.TrimPrefix(f.Name, "charts/") cname := strings.TrimPrefix(f.Name, "charts/")
@ -151,7 +150,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
scname := parts[0] scname := parts[0]
subcharts[scname] = append(subcharts[scname], &BufferedFile{Name: cname, Data: f.Data}) subcharts[scname] = append(subcharts[scname], &BufferedFile{Name: cname, Data: f.Data})
} else { } else {
c.Files = append(c.Files, &any.Any{TypeUrl: f.Name, Value: f.Data}) c.Files = append(c.Files, &chart.Any{TypeUrl: f.Name, Value: f.Data})
} }
} }

@ -23,7 +23,7 @@ import (
"testing" "testing"
"text/template" "text/template"
"github.com/golang/protobuf/ptypes/any" any "k8s.io/helm/pkg/proto/hapi/chart"
kversion "k8s.io/apimachinery/pkg/version" kversion "k8s.io/apimachinery/pkg/version"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"

@ -24,7 +24,7 @@ import (
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"github.com/golang/protobuf/ptypes/any" any "k8s.io/helm/pkg/proto/hapi/chart"
) )
func TestSortTemplates(t *testing.T) { func TestSortTemplates(t *testing.T) {

@ -12,6 +12,7 @@ It is generated from these files:
It has these top-level messages: It has these top-level messages:
Chart Chart
Any
Config Config
Value Value
Maintainer Maintainer
@ -23,7 +24,7 @@ package chart
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
import fmt "fmt" import fmt "fmt"
import math "math" import math "math"
import google_protobuf "github.com/golang/protobuf/ptypes/any" import _ "github.com/golang/protobuf/ptypes/any"
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
@ -49,7 +50,7 @@ type Chart struct {
Values *Config `protobuf:"bytes,4,opt,name=values" json:"values,omitempty"` Values *Config `protobuf:"bytes,4,opt,name=values" json:"values,omitempty"`
// Miscellaneous files in a chart archive, // Miscellaneous files in a chart archive,
// e.g. README, LICENSE, etc. // e.g. README, LICENSE, etc.
Files []*google_protobuf.Any `protobuf:"bytes,5,rep,name=files" json:"files,omitempty"` Files []*Any `protobuf:"bytes,5,rep,name=files" json:"files,omitempty"`
} }
func (m *Chart) Reset() { *m = Chart{} } func (m *Chart) Reset() { *m = Chart{} }
@ -85,35 +86,66 @@ func (m *Chart) GetValues() *Config {
return nil return nil
} }
func (m *Chart) GetFiles() []*google_protobuf.Any { func (m *Chart) GetFiles() []*Any {
if m != nil { if m != nil {
return m.Files return m.Files
} }
return nil return nil
} }
// Copied from https://github.com/golang/protobuf/blob/master/ptypes/any/any.proto
type Any struct {
// A resource name whose content describes the type of the
// serialized data.
TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"`
// Data for file.
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}
func (m *Any) Reset() { *m = Any{} }
func (m *Any) String() string { return proto.CompactTextString(m) }
func (*Any) ProtoMessage() {}
func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Any) GetTypeUrl() string {
if m != nil {
return m.TypeUrl
}
return ""
}
func (m *Any) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
func init() { func init() {
proto.RegisterType((*Chart)(nil), "hapi.chart.Chart") proto.RegisterType((*Chart)(nil), "hapi.chart.Chart")
proto.RegisterType((*Any)(nil), "hapi.chart.Any")
} }
func init() { proto.RegisterFile("hapi/chart/chart.proto", fileDescriptor0) } func init() { proto.RegisterFile("hapi/chart/chart.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 242 bytes of a gzipped FileDescriptorProto // 276 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0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7e, 0x4b, 0x55,
0xb9, 0x9a, 0x18, 0x04, 0xf8, 0x0f, 0xe9, 0x68, 0x88, 0x19, 0xe4, 0x55, 0xd3, 0x92, 0x93, 0x79, 0x61, 0xc9, 0x2f, 0x68, 0x35, 0x76, 0x12, 0xa0, 0x17, 0x12, 0xad, 0xc1, 0xee, 0xc0, 0x8b, 0x53,
0xac, 0x14, 0xae, 0x57, 0xe9, 0x7a, 0xf5, 0x6a, 0x76, 0x3a, 0x28, 0x6f, 0x67, 0x5f, 0x39, 0xef, 0x85, 0x25, 0xf7, 0xa8, 0xfb, 0xaa, 0xaf, 0x6e, 0x74, 0x2d, 0x2c, 0x5d, 0x3e, 0x83, 0xbb, 0xd1,
0x58, 0x8c, 0x99, 0x3e, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x70, 0x34, 0x75, 0x9e, 0x01, 0x35, 0x9b, 0xc3, 0xd8, 0xd4, 0x39, 0x7e, 0x55, 0x85, 0xa2, 0x6b, 0x4f, 0xc4, 0xa8, 0x99, 0x3f,
0x00, 0x00, 0x0a, 0xc5, 0x66, 0xe0, 0x51, 0x25, 0x1f, 0xf8, 0xce, 0x6a, 0x2a, 0xec, 0xf0, 0x32, 0xfa, 0xf4,
0xa8, 0x6b, 0x3b, 0xa4, 0x17, 0x7c, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x06, 0x23, 0x45, 0x93,
0xd1, 0x01, 0x00, 0x00,
} }

Loading…
Cancel
Save