Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bufmod' into BSR-3326-target-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
doriable committed Mar 5, 2024
2 parents aa283a7 + 7287dad commit d0ed762
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func newUniversalProtoContentForV1Beta1(v1beta1ProtoContent *modulev1beta1.Downl
ModuleID: v1beta1ProtoContent.Commit.ModuleId,
Files: slicesext.Map(v1beta1ProtoContent.Files, newUniversalProtoFileForV1Beta1),
V1BufYAMLFile: newUniversalProtoFileForV1Beta1(v1beta1ProtoContent.V1BufYamlFile),
V1BufLockFile: newUniversalProtoFileForV1Beta1(v1beta1ProtoContent.V1BufYamlFile),
V1BufLockFile: newUniversalProtoFileForV1Beta1(v1beta1ProtoContent.V1BufLockFile),
}
}

Expand Down
9 changes: 0 additions & 9 deletions private/bufpkg/bufmodule/bufmodulestore/module_data_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func (p *moduleDataStore) getModuleDataForModuleKey(
return nil, err
}
var v1BufYAMLObjectData bufmodule.ObjectData
// TODO: make this required
if externalModuleData.V1BufYAMLFile != "" {
// We do not want to use bufconfig.GetBufYAMLFileForPrefix as this validates the
// buf.yaml, and potentially calls out to i.e. resolve digests. We just want to raw data.
Expand All @@ -223,7 +222,6 @@ func (p *moduleDataStore) getModuleDataForModuleKey(
}
}
var v1BufLockObjectData bufmodule.ObjectData
// TODO: make this required
if externalModuleData.V1BufLockFile != "" {
// We do not want to use bufconfig.GetBufLockFileForPrefix as this validates the
// buf.lock, and potentially calls out to i.e. resolve digests. We just want to raw data.
Expand Down Expand Up @@ -257,11 +255,9 @@ func (p *moduleDataStore) getModuleDataForModuleKey(
return declaredDepModuleKeys, nil
},
func() (bufmodule.ObjectData, error) {
// TODO: This may be nil, because we allow it to be nil in putModuleData, this needs to be fixed.
return v1BufYAMLObjectData, nil
},
func() (bufmodule.ObjectData, error) {
// TODO: This may be nil, because we allow it to be nil in putModuleData, this needs to be fixed.
return v1BufLockObjectData, nil
},
), nil
Expand Down Expand Up @@ -365,7 +361,6 @@ func (p *moduleDataStore) putModuleData(
if err != nil {
return err
}
// TODO: This should always be non-nil! This is the case because of a TODO in bufmoduletesting.
if v1BufYAMLObjectData != nil {
v1BufYAMLFilePath := normalpath.Join(externalModuleDataV1BufYAMLDir, v1BufYAMLObjectData.Name())
if err := storage.PutPath(ctx, moduleCacheBucket, v1BufYAMLFilePath, v1BufYAMLObjectData.Data()); err != nil {
Expand All @@ -378,7 +373,6 @@ func (p *moduleDataStore) putModuleData(
if err != nil {
return err
}
// TODO: This should always be non-nil! This is the case because of a TODO in bufmoduletesting.
if v1BufLockObjectData != nil {
v1BufLockFilePath := normalpath.Join(externalModuleDataV1BufLockDir, v1BufLockObjectData.Name())
if err := storage.PutPath(ctx, moduleCacheBucket, v1BufLockFilePath, v1BufLockObjectData.Data()); err != nil {
Expand Down Expand Up @@ -588,9 +582,6 @@ func (e externalModuleData) isValid() bool {
}
return e.Version == externalModuleDataVersion &&
len(e.FilesDir) > 0
// TODO: re-enable
//len(e.V1BufYAMLFile) > 0 &&
//len(e.V1BufLockFile) > 0
}

// externalModuleDataDep represents a dependency.
Expand Down
4 changes: 0 additions & 4 deletions private/bufpkg/bufmodule/bufmoduletesting/bufmoduletesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,9 @@ func (o *omniProvider) getModuleDataForModuleKey(
return declaredDepModuleKeys, nil
},
func() (bufmodule.ObjectData, error) {
// TODO: This may be nil! This doesn't actually fulfill the contract! We need
// to do synthesizing here, or we need to relax the contract.
return module.V1Beta1OrV1BufYAMLObjectData()
},
func() (bufmodule.ObjectData, error) {
// TODO: This may be nil! This doesn't actually fulfill the contract! We need
// to do synthesizing here, or we need to relax the contract.
return module.V1Beta1OrV1BufLockObjectData()
},
), nil
Expand Down
6 changes: 2 additions & 4 deletions private/bufpkg/bufmodule/module_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ type ModuleData interface {

// V1Beta1OrV1BufYAMLObjectData gets the v1beta1 or v1 buf.yaml ObjectData.
//
// This is always present, even if the Module was created from a v2 buf.yaml file. The BSR will
// synthesize a value for v2 buf.yamls.
// This may not be present. It will only be potentially present for v1 buf.yaml files.
//
// This is used for digest calculations. It is not used otherwise.
V1Beta1OrV1BufYAMLObjectData() (ObjectData, error)
// V1Beta1OrV1BufYAMLObjectData gets the v1beta1 or v1 buf.lock ObjectData.
//
// This is always present, even if the Module was created from a v2 buf.yaml file. The BSR will
// synthesize a value for v2 buf.yamls.
// This may not be present. It will only be potentially present for v1 buf.lock files.
//
// This is used for digest calculations. It is not used otherwise.
V1Beta1OrV1BufLockObjectData() (ObjectData, error)
Expand Down
2 changes: 1 addition & 1 deletion private/pkg/shake256/shake256.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewDigest(value []byte) (Digest, error) {
// NewDigest returns a new Digest for the content read from the Reader.
func NewDigestForContent(reader io.Reader) (Digest, error) {
shakeHash := sha3.NewShake256()
// TODO: remove in the future, this should have no effect
// TODO FUTURE: remove in the future, this should have no effect
shakeHash.Reset()
if _, err := io.Copy(shakeHash, reader); err != nil {
return nil, err
Expand Down

0 comments on commit d0ed762

Please sign in to comment.