Skip to content

Commit

Permalink
working on dynamic tests, resolving some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wTylerReid committed Dec 4, 2024
1 parent 83ebd48 commit 49b5b95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions apis/logging/v1alpha1/link_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/<projectID>/locations/<location>/links/<linkID>".
// Should be in the format "projects/<projectID>/locations/<location>/buckets/<bucketID>/links/<linkID>".
External string `json:"external,omitempty"`

// The name of a LoggingLink resource.
Expand Down Expand Up @@ -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) {
Expand All @@ -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/<projectId>/locations/<location>/links/<linkID>)", 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/<projectId>/locations/<location>/buckets/<bucketID>/links/<linkID>)", external)
}
parent = &LoggingLinkParent{
ProjectID: tokens[1],
Location: tokens[3],
LogBucket: tokens[5],
}
resourceID = tokens[5]
resourceID = tokens[7]
return parent, resourceID, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 49b5b95

Please sign in to comment.