Skip to content

Conversation

@mustela
Copy link
Collaborator

@mustela mustela commented Sep 15, 2025

No description provided.

@mustela mustela requested a review from scotwells September 15, 2025 07:53
@joggrbot
Copy link
Contributor

joggrbot bot commented Sep 15, 2025

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: 986c1ef | Powered by Joggr

Copy link
Contributor

@scotwells scotwells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should introduce a new API group for vendors since it's separate from generic resource management. Overall looking good, just a few comments / recommendations.

@mustela
Copy link
Collaborator Author

mustela commented Sep 25, 2025

@scotwells wanna give it another round?

@mustela
Copy link
Collaborator Author

mustela commented Sep 29, 2025

@JoseSzycho wanna take a look?

mustela added a commit that referenced this pull request Sep 30, 2025
## ✨ Autofixed 1 outdated doc(s)

This pull was automatically generated by Joggr to fix 1 outdated doc(s)
due to code changes in pull #275

### Fixed docs

The following docs were fixed:

- `docs/api/resourcemanager.md`: Vendor-related CRDs and APIs have moved
from resourcemanager.miloapis.com to a new vendors.miloapis.com API
group, so the documentation here needed to make this explicitly clear
and refer users to the new vendor API documentation for those types.

### How to fix

To fix the docs, you can either:

1. Merge this pull request into your pull request to fix the docs
2. Wait for your pull request to be merged and then merge this pull
request into your base branch

---

Powered by
[Joggr](https://joggr.ai?utm_source=gh&utm_medium=gh&utm_campaign=ghapr&utm_id=ghapr)
- The documentation assistant for your codebase.
mustela added a commit that referenced this pull request Sep 30, 2025
## ✨ Autofixed 1 outdated doc(s)

This pull was automatically generated by Joggr to fix 1 outdated doc(s)
due to code changes in pull #275

### Fixed docs

The following docs were fixed:

- `docs/api/infrastructure.md`: The documentation was outdated because
it documented 'Vendor' and 'CorporationTypeConfig' in the
'resourcemanager.miloapis.com/v1alpha1' API group, but these resources
have been completely moved and restructured in the new
'vendors.miloapis.com/v1alpha1' group with a new design. All references
to them in this doc must be deleted.

### How to fix

To fix the docs, you can either:

1. Merge this pull request into your pull request to fix the docs
2. Wait for your pull request to be merged and then merge this pull
request into your base branch

---

Powered by
[Joggr](https://joggr.ai?utm_source=gh&utm_medium=gh&utm_campaign=ghapr&utm_id=ghapr)
- The documentation assistant for your codebase.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the task generate command to generate documentation based on the API types instead of manually modifying these files.

Comment on lines 3 to 10
**Important:**

> As of this release, all vendor-related resources—including Vendor, VendorTypeDefinition, VendorVerification, and CorporationTypeConfig—have been moved from the `resourcemanager.miloapis.com/v1alpha1` API group to the new `vendors.miloapis.com/v1alpha1` API group.
>
> This document *only* covers resource types that remain in the `resourcemanager.miloapis.com/v1alpha1` API group (such as Organization, OrganizationMembership, and Project).
>
> For vendor management and vendor type APIs, see the [vendors.miloapis.com API documentation](./vendors-api-group.md).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused by this section of the documentation. Was this something that AI added after moving the vendors stuff to a new API type? This document is automatically generated by task generate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

Comment on lines 14 to 42
func GetTaxIdFromSecret(ctx context.Context, c client.Client, vendor *Vendor, taxIdRef TaxIdReference) (string, error) {
// Determine the namespace for the Secret
namespace := taxIdRef.Namespace
if namespace == "" {
namespace = vendor.Namespace
if namespace == "" {
namespace = "default" // fallback for cluster-scoped resources
}
}

// Get the Secret
secret := &corev1.Secret{}
secretKey := types.NamespacedName{
Name: taxIdRef.SecretName,
Namespace: namespace,
}

if err := c.Get(ctx, secretKey, secret); err != nil {
return "", fmt.Errorf("failed to get secret %s/%s: %w", namespace, taxIdRef.SecretName, err)
}

// Extract the tax ID from the Secret
taxIdBytes, exists := secret.Data[taxIdRef.SecretKey]
if !exists {
return "", fmt.Errorf("key %s not found in secret %s/%s", taxIdRef.SecretKey, namespace, taxIdRef.SecretName)
}

return string(taxIdBytes), nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should leave the pkg/apis/vendors package to API type definitions only. Any helper functions like this should be put in the controller package where they're used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on moving this to a guide document (maybe under docs/guides/vendors/?) and not something in the api reference folder? Seems like this should be a guide on how to create secrets for tax ID numbers to use with vendors. I'd expect a general design document to talk about why we're using secrets for tax IDs.

We should also reduce the usage of the term "Kubernetes" in the document since it's really a concept in Milo we're using.

Comment on lines 212 to 236
## Migration from Plain Text
If you have existing vendors with plain text tax IDs:
1. **Create secrets** for each vendor's tax ID
2. **Update vendor resources** to use `TaxIdRef` instead of `TaxId`
3. **Verify secrets** are accessible and contain correct data
4. **Test validation** to ensure everything works

### Migration Script Example

```bash
#!/bin/bash
# Extract tax IDs and create secrets
kubectl get vendors -o json | jq -r '.items[] | select(.spec.taxInfo.taxId) | "\(.metadata.name) \(.spec.taxInfo.taxId)"' | while read vendor_name tax_id; do
# Create secret
kubectl create secret generic "${vendor_name}-tax-id" \
--from-literal=tax-id="$tax_id" \
--namespace=default
# Add labels
kubectl label secret "${vendor_name}-tax-id" \
vendor.miloapis.com/vendor="$vendor_name" \
vendor.miloapis.com/type=tax-id
done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is needed? There's no migrations needed since this functionality hasn't gone to production yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed!

Comment on lines 239 to 271
## Security Considerations

### 1. **RBAC Configuration**
Ensure proper RBAC for secret access:
```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: vendor-secret-reader
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list"]
resourceNames: ["*-tax-id"] # Restrict to tax ID secrets
```

### 2. **Network Policies**
Consider network policies to restrict secret access:
```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: restrict-secret-access
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: vendor-controllers
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed? Standard k8s RBAC / Network Policies aren't used with Milo. The network policy APIs aren't even available.

Comment on lines 120 to 122
// Whether this verification is required for vendor activation
// +kubebuilder:default=true
Required bool `json:"required"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this field expected to be used?

Comment on lines 148 to 150
// Timestamp when verification was completed
// +optional
CompletedAt *metav1.Time `json:"completedAt,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this match the creation timestamp of the VendorVerification type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed.

Comment on lines +160 to +158
// Last error message if verification failed
// +optional
LastError string `json:"lastError,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be duplicated by data showing up in the status conditions?

Comment on lines 156 to 158
// Number of verification attempts
// +optional
AttemptCount int32 `json:"attemptCount,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the VendorVerification type being created indicate the vendor is verified? How does this value get incremented?

@mustela
Copy link
Collaborator Author

mustela commented Oct 6, 2025

@scotwells would you mind to give it another try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants