diff --git a/apis/logging/v1alpha1/link_reference.go b/apis/logging/v1alpha1/link_reference.go index 03136c0ac3..c20c3f2d0d 100644 --- a/apis/logging/v1alpha1/link_reference.go +++ b/apis/logging/v1alpha1/link_reference.go @@ -33,7 +33,7 @@ var _ refsv1beta1.ExternalNormalizer = &LoggingLinkRef{} // holds the GCP identifier for the KRM object. type LoggingLinkRef struct { // A reference to an externally managed LoggingLink resource. - // Should be in the format "projects//locations//links/". + // Should be in the format "projects//locations//buckets//links/". External string `json:"external,omitempty"` // The name of a LoggingLink resource. @@ -162,7 +162,7 @@ type LoggingLinkParent struct { } func (p *LoggingLinkParent) String() string { - return "projects/" + p.ProjectID + "/locations/" + p.Location + return "projects/" + p.ProjectID + "/locations/" + p.Location + "/buckets/" + p.LogBucket } func asLoggingLinkExternal(parent *LoggingLinkParent, resourceID string) (external string) { @@ -172,14 +172,15 @@ func asLoggingLinkExternal(parent *LoggingLinkParent, resourceID string) (extern func parseLoggingLinkExternal(external string) (parent *LoggingLinkParent, resourceID string, err error) { external = strings.TrimPrefix(external, "/") tokens := strings.Split(external, "/") - if len(tokens) != 6 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "link" { - return nil, "", fmt.Errorf("format of LoggingLink external=%q was not known (use projects//locations//links/)", external) + if len(tokens) != 8 || tokens[0] != "projects" || tokens[2] != "locations" || tokens[4] != "bucket" || tokens[6] != "link" { + return nil, "", fmt.Errorf("format of LoggingLink external=%q was not known (use projects//locations//buckets//links/)", external) } parent = &LoggingLinkParent{ ProjectID: tokens[1], Location: tokens[3], + LogBucket: tokens[5], } - resourceID = tokens[5] + resourceID = tokens[7] return parent, resourceID, nil } diff --git a/pkg/test/resourcefixture/testdata/basic/logging/v1alpha1/logginglogginglink/basiclink/create.yaml b/pkg/test/resourcefixture/testdata/basic/logging/v1alpha1/logginglogginglink/basiclink/create.yaml index a2bea2cf9f..1c2bf3e037 100644 --- a/pkg/test/resourcefixture/testdata/basic/logging/v1alpha1/logginglogginglink/basiclink/create.yaml +++ b/pkg/test/resourcefixture/testdata/basic/logging/v1alpha1/logginglogginglink/basiclink/create.yaml @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: logging.cnrm.cloud.google.com/v1beta1 -kind: LoggingLogLink +apiVersion: logging.cnrm.cloud.google.com/v1alpha1 +kind: LoggingLink metadata: - name: loggingloglink-${uniqueId} + name: logginglink-${uniqueId} spec: loggingLogBucketRef: external: "projects/${projectId}/locations/global/buckets/logginglogbucket-${uniqueId}"