-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(kuma-cp): pass future meta to Validate when creating a resource (#…
…10927) At the moment the MeshService validator fails when Create is called because the meta is nil and the future name of the resource is missing. Signed-off-by: Mike Beaumont <[email protected]>
- Loading branch information
1 parent
c32eb95
commit d8eb3be
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package manager | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/kumahq/kuma/pkg/core/resources/model" | ||
core_model "github.com/kumahq/kuma/pkg/core/resources/model" | ||
"github.com/kumahq/kuma/pkg/core/resources/store" | ||
) | ||
|
||
type resourceMetaObject struct { | ||
Name string | ||
Version string | ||
Mesh string | ||
CreationTime time.Time | ||
ModificationTime time.Time | ||
Labels map[string]string | ||
} | ||
|
||
var _ core_model.ResourceMeta = &resourceMetaObject{} | ||
|
||
func (r *resourceMetaObject) GetName() string { | ||
return r.Name | ||
} | ||
|
||
func (r *resourceMetaObject) GetNameExtensions() core_model.ResourceNameExtensions { | ||
return core_model.ResourceNameExtensionsUnsupported | ||
} | ||
|
||
func (r *resourceMetaObject) GetVersion() string { | ||
return r.Version | ||
} | ||
|
||
func (r *resourceMetaObject) GetMesh() string { | ||
return r.Mesh | ||
} | ||
|
||
func (r *resourceMetaObject) GetCreationTime() time.Time { | ||
return r.CreationTime | ||
} | ||
|
||
func (r *resourceMetaObject) GetModificationTime() time.Time { | ||
return r.ModificationTime | ||
} | ||
|
||
func (r *resourceMetaObject) GetLabels() map[string]string { | ||
return r.Labels | ||
} | ||
|
||
func metaFromCreateOpts(descriptor model.ResourceTypeDescriptor, fs store.CreateOptions) core_model.ResourceMeta { | ||
if fs.Name == "" { | ||
return nil | ||
} | ||
if fs.Mesh == "" && descriptor.Scope == model.ScopeMesh { | ||
return nil | ||
} | ||
return &resourceMetaObject{ | ||
Name: fs.Name, | ||
Mesh: fs.Mesh, | ||
CreationTime: fs.CreationTime, | ||
Labels: fs.Labels, | ||
} | ||
} |