Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/v2/k8s-go-deps-79bf825c00
Browse files Browse the repository at this point in the history
  • Loading branch information
super-harsh committed Dec 20, 2024
2 parents 9ef7857 + 6806e21 commit b888835
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 55 deletions.
2 changes: 1 addition & 1 deletion docs/hugo/content/contributing/aso-codegen-structure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/hugo/content/contributing/aso-v1-structure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/hugo/content/contributing/aso-v2-structure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/hugo/content/contributing/asoctl-structure.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions v2/internal/duration/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Duration marshalling
TODO: remove after go v2: https://github.com/golang/go/issues/10275
*/

func (d ISO8601) MarshalJSON() ([]byte, error) {
func (d *ISO8601) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, d.String())), nil
}

Expand All @@ -55,7 +55,7 @@ func (d *ISO8601) UnmarshalJSON(b []byte) error {
}
}

func (d ISO8601) String() string {
func (d *ISO8601) String() string {
if d.Duration == time.Duration(0) {
return "PT0S"
}
Expand Down
12 changes: 6 additions & 6 deletions v2/internal/genericarmclient/cloud_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func NewTestCloudError(code string, message string) *CloudError {

// Error implements the error interface for type CloudError.
// The contents of the error text are not contractual and subject to change.
func (e CloudError) Error() string {
func (e *CloudError) Error() string {
return e.error.Error()
}

// Code returns the error code from the message, if present, or UnknownErrorCode if not.
func (e CloudError) Code() string {
func (e *CloudError) Code() string {
if e.code != nil && *e.code != "" {
return *e.code
}
Expand All @@ -61,7 +61,7 @@ func (e CloudError) Code() string {
}

// Message returns the message from the error, if present, or UnknownErrorMessage if not.
func (e CloudError) Message() string {
func (e *CloudError) Message() string {
if e.message != nil && *e.message != "" {
return *e.message
}
Expand All @@ -70,7 +70,7 @@ func (e CloudError) Message() string {
}

// Target returns the target of the error, if present, or an empty string if not.
func (e CloudError) Target() string {
func (e *CloudError) Target() string {
if e.target != nil && *e.target != "" {
return *e.target
}
Expand All @@ -79,7 +79,7 @@ func (e CloudError) Target() string {
}

// Details returns the details of the error, if present, or an empty slice if not
func (e CloudError) Details() []*ErrorResponse {
func (e *CloudError) Details() []*ErrorResponse {
return e.details
}

Expand Down Expand Up @@ -117,6 +117,6 @@ func (e *CloudError) UnmarshalJSON(data []byte) error {
return nil
}

func (e CloudError) Unwrap() error {
func (e *CloudError) Unwrap() error {
return e.error
}
14 changes: 7 additions & 7 deletions v2/internal/testcommon/kube_per_test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type KubePerTestContext struct {
tracker *ResourceTracker
}

func (tc KubePerTestContext) CreateTestNamespace(namespaceName string) error {
func (tc *KubePerTestContext) CreateTestNamespace(namespaceName string) error {
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespaceName,
Expand All @@ -72,22 +72,22 @@ func (tc KubePerTestContext) CreateTestNamespace(namespaceName string) error {
return nil
}

func (tc KubePerTestContext) createTestNamespace() error {
func (tc *KubePerTestContext) createTestNamespace() error {
return tc.CreateTestNamespace(tc.Namespace)
}

func (tc KubePerTestContext) MakeObjectMeta(prefix string) ctrl.ObjectMeta {
func (tc *KubePerTestContext) MakeObjectMeta(prefix string) ctrl.ObjectMeta {
return tc.MakeObjectMetaWithName(tc.Namer.GenerateName(prefix))
}

func (tc KubePerTestContext) MakeObjectMetaWithName(name string) ctrl.ObjectMeta {
func (tc *KubePerTestContext) MakeObjectMetaWithName(name string) ctrl.ObjectMeta {
return ctrl.ObjectMeta{
Name: name,
Namespace: tc.Namespace,
}
}

func (tc KubePerTestContext) MakeObjectMetaWithNameAndCredentialFrom(name string, credentialFrom string) ctrl.ObjectMeta {
func (tc *KubePerTestContext) MakeObjectMetaWithNameAndCredentialFrom(name string, credentialFrom string) ctrl.ObjectMeta {
return ctrl.ObjectMeta{
Name: name,
Namespace: tc.Namespace,
Expand All @@ -97,7 +97,7 @@ func (tc KubePerTestContext) MakeObjectMetaWithNameAndCredentialFrom(name string
}
}

func (tc KubePerTestContext) MakeReferenceFromResource(resource client.Object) *genruntime.ResourceReference {
func (tc *KubePerTestContext) MakeReferenceFromResource(resource client.Object) *genruntime.ResourceReference {
gvk, err := apiutil.GVKForObject(resource, tc.scheme)
if err != nil {
tc.T.Fatal(err)
Expand All @@ -110,7 +110,7 @@ func (tc KubePerTestContext) MakeReferenceFromResource(resource client.Object) *
}
}

func (tc KubePerTestContext) NewTestResourceGroup() *resources.ResourceGroup {
func (tc *KubePerTestContext) NewTestResourceGroup() *resources.ResourceGroup {
return &resources.ResourceGroup{
ObjectMeta: tc.MakeObjectMeta("rg"),
Spec: resources.ResourceGroup_Spec{
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/testcommon/test_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type TestLogger struct {
ignoredPanicMax int
}

func (_ TestLogger) Init(info logr.RuntimeInfo) {
func (_ *TestLogger) Init(info logr.RuntimeInfo) {
}

// kvListFormat was adapted from the klog method of the same name and formats a keysAndValues list into
Expand Down
11 changes: 6 additions & 5 deletions v2/pkg/genruntime/conditions/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const (
var _ fmt.Stringer = Condition{}

// Condition defines an extension to status (an observation) of a resource
// nolint:recvcheck
// +kubebuilder:object:generate=true
type Condition struct {
// Type of condition.
Expand Down Expand Up @@ -117,7 +118,7 @@ type Condition struct {

// IsEquivalent returns true if this condition is equivalent to the passed in condition.
// Two conditions are equivalent if all of their fields EXCEPT LastTransitionTime are the same.
func (c Condition) IsEquivalent(other Condition) bool {
func (c *Condition) IsEquivalent(other Condition) bool {
return c.Type == other.Type &&
c.Status == other.Status &&
c.Severity == other.Severity &&
Expand All @@ -127,7 +128,7 @@ func (c Condition) IsEquivalent(other Condition) bool {
}

// ShouldOverwrite determines if this condition should overwrite the other condition.
func (c Condition) ShouldOverwrite(other Condition) bool {
func (c *Condition) ShouldOverwrite(other Condition) bool {
// Safety check that the two conditions are of the same type. If not they certainly shouldn't overwrite
if c.Type != other.Type {
return false
Expand Down Expand Up @@ -161,7 +162,7 @@ func (c Condition) ShouldOverwrite(other Condition) bool {
//
// Keep in mind that this priority is specifically for comparing Conditions with the same ObservedGeneration. If the ObservedGeneration
// is different, the newer one always wins.
func (c Condition) priority() int {
func (c *Condition) priority() int {
switch c.Status {
case metav1.ConditionTrue:
return 5
Expand All @@ -188,10 +189,10 @@ func (c Condition) priority() int {
}

// Copy returns an independent copy of the Condition
func (c Condition) Copy() Condition {
func (c *Condition) Copy() Condition {
// NB: If you change this to a non-simple copy
// you will need to update genruntime.CloneSliceOfCondition
return c
return *c
}

// String returns a string representation of this condition
Expand Down
1 change: 1 addition & 0 deletions v2/pkg/genruntime/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

// ConfigMapReference is a reference to a Kubernetes configmap and key in the same namespace as
// the resource it is on.
// nolint:recvcheck
// +kubebuilder:object:generate=true
type ConfigMapReference struct {
// Name is the name of the Kubernetes configmap being referenced.
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/genruntime/core/destination_expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ type DestinationExpression struct {
Value string `json:"value,omitempty"`
}

func (s DestinationExpression) String() string {
func (s *DestinationExpression) String() string {
return fmt.Sprintf("Name: %q, Key: %q, Value: %q", s.Name, s.Key, s.Value)
}
33 changes: 17 additions & 16 deletions v2/pkg/genruntime/resource_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type KnownResourceReference struct {
}

// AsResourceReference transforms this KnownResourceReference into a ResourceReference
func (ref KnownResourceReference) AsResourceReference(group string, kind string) *ResourceReference {
func (ref *KnownResourceReference) AsResourceReference(group string, kind string) *ResourceReference {
if ref.Name == "" {
group = ""
kind = ""
Expand All @@ -63,7 +63,7 @@ type KubernetesOwnerReference struct {
}

// AsResourceReference transforms this KnownResourceReference into a ResourceReference
func (ref KubernetesOwnerReference) AsResourceReference(group string, kind string) *ResourceReference {
func (ref *KubernetesOwnerReference) AsResourceReference(group string, kind string) *ResourceReference {
return &ResourceReference{
Group: group,
Kind: kind,
Expand All @@ -90,7 +90,7 @@ type ArbitraryOwnerReference struct {
}

// AsResourceReference transforms this ArbitraryOwnerReference into a ResourceReference
func (ref ArbitraryOwnerReference) AsResourceReference() *ResourceReference {
func (ref *ArbitraryOwnerReference) AsResourceReference() *ResourceReference {
return &ResourceReference{
Group: ref.Group,
Kind: ref.Kind,
Expand All @@ -102,6 +102,7 @@ func (ref ArbitraryOwnerReference) AsResourceReference() *ResourceReference {
var _ fmt.Stringer = ResourceReference{}

// ResourceReference represents a resource reference, either to a Kubernetes resource or directly to an Azure resource via ARMID
// nolint:recvcheck
// +kubebuilder:object:generate=true
type ResourceReference struct {
// Group is the Kubernetes group of the resource.
Expand Down Expand Up @@ -131,12 +132,12 @@ func CreateResourceReferenceFromARMID(armID string) ResourceReference {
}

// IsDirectARMReference returns true if this ResourceReference is referring to an ARMID directly.
func (ref ResourceReference) IsDirectARMReference() bool {
func (ref *ResourceReference) IsDirectARMReference() bool {
return ref.ARMID != "" && ref.Name == "" && ref.Group == "" && ref.Kind == ""
}

// IsKubernetesReference returns true if this ResourceReference is referring to a Kubernetes resource.
func (ref ResourceReference) IsKubernetesReference() bool {
func (ref *ResourceReference) IsKubernetesReference() bool {
return ref.ARMID == "" && ref.Name != "" && ref.Group != "" && ref.Kind != ""
}

Expand All @@ -155,7 +156,7 @@ func (ref ResourceReference) String() string {

// TODO: We wouldn't need this if controller-gen supported DUs or OneOf better, see: https://github.com/kubernetes-sigs/controller-tools/issues/461
// Validate validates the ResourceReference to ensure that it is structurally valid.
func (ref ResourceReference) Validate() (admission.Warnings, error) {
func (ref *ResourceReference) Validate() (admission.Warnings, error) {
if ref.ARMID == "" && ref.Name == "" && ref.Group == "" && ref.Kind == "" {
return nil, eris.Errorf("at least one of ['ARMID'] or ['Group', 'Kind', 'Namespace', 'Name'] must be set for ResourceReference")
}
Expand All @@ -172,22 +173,22 @@ func (ref ResourceReference) Validate() (admission.Warnings, error) {
}

// AsNamespacedRef creates a NamespacedResourceReference from this reference.
func (ref ResourceReference) AsNamespacedRef(namespace string) NamespacedResourceReference {
func (ref *ResourceReference) AsNamespacedRef(namespace string) NamespacedResourceReference {
// If this is a direct ARM reference, don't append a namespace as it reads weird
if ref.IsDirectARMReference() {
return NamespacedResourceReference{
ResourceReference: ref,
ResourceReference: *ref,
}
}

return NamespacedResourceReference{
ResourceReference: ref,
ResourceReference: *ref,
Namespace: namespace,
}
}

// GroupKind returns the GroupKind of the resource reference
func (ref ResourceReference) GroupKind() schema.GroupKind {
func (ref *ResourceReference) GroupKind() schema.GroupKind {
return schema.GroupKind{
Group: ref.Group,
Kind: ref.Kind,
Expand All @@ -214,13 +215,13 @@ func LookupOwnerGroupKind(v interface{}) (string, string) {
}

// Copy makes an independent copy of the KnownResourceReference
func (ref KnownResourceReference) Copy() KnownResourceReference {
return ref
func (ref *KnownResourceReference) Copy() KnownResourceReference {
return *ref
}

// Copy makes an independent copy of the ArbitraryOwnerReference
func (ref ArbitraryOwnerReference) Copy() ArbitraryOwnerReference {
return ref
func (ref *ArbitraryOwnerReference) Copy() ArbitraryOwnerReference {
return *ref
}

// Copy makes an independent copy of the ResourceReference
Expand All @@ -229,8 +230,8 @@ func (ref ResourceReference) Copy() ResourceReference {
}

// Copy makes an independent copy of the KubernetesOwnerReference
func (ref KubernetesOwnerReference) Copy() KubernetesOwnerReference {
return ref
func (ref *KubernetesOwnerReference) Copy() KubernetesOwnerReference {
return *ref
}

// ValidateResourceReferences calls Validate on each ResourceReference
Expand Down
2 changes: 2 additions & 0 deletions v2/pkg/genruntime/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

// SecretReference is a reference to a Kubernetes secret and key in the same namespace as
// the resource it is on.
// nolint:recvcheck
// +kubebuilder:object:generate=true
type SecretReference struct {
// Name is the name of the Kubernetes secret being referenced.
Expand Down Expand Up @@ -62,6 +63,7 @@ func (s NamespacedSecretReference) String() string {

// SecretMapReference is a reference to a Kubernetes secret in the same namespace as
// the resource it is on.
// nolint:recvcheck
// +kubebuilder:object:generate=true
type SecretMapReference struct {
// Name is the name of the Kubernetes secret being referenced.
Expand Down
2 changes: 1 addition & 1 deletion v2/tools/generator/internal/astmodel/allof_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func BuildAllOfType(types ...Type) Type {
// Types returns what types the AllOf can be.
// Exposed as ReadonlyTypeSet so caller can't break invariants.
func (allOf *AllOfType) Types() ReadonlyTypeSet {
return allOf.types
return &allOf.types
}

// References returns any type referenced by the AllOf types
Expand Down
2 changes: 1 addition & 1 deletion v2/tools/generator/internal/astmodel/oneof_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (oneOf *OneOfType) WithTypes(types []Type) *OneOfType {
// Types returns what subtypes the OneOf may be.
// Exposed as ReadonlyTypeSet so caller cannot break invariants.
func (oneOf *OneOfType) Types() ReadonlyTypeSet {
return oneOf.types
return &oneOf.types
}

// PropertyObjects returns all the ObjectTypes that define the properties of this OneOf
Expand Down
Loading

0 comments on commit b888835

Please sign in to comment.